Skip to content

Conversation

@DimitryP6
Copy link
Contributor

…ng a given struct to given values, another one for running in an infinite loop.

Changes

Function that takes an empty struct and initializes it with given values + function that runs an infinite loop for voltages.

To Do

Any remaining things that need to get done

  • delays during infinite loop?
  • is the check for dipping below a lower bound ratio necessary for capacitor?
  • not sure about arrangement of function parameters.

Checklist

It can be helpful to check the Checks and Files changed tabs.
Please reach out to your Project Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.

  • [ *] No merge conflicts
  • [ *] All checks passing
  • [ *] Remove any non-applicable sections of this template
  • [ *] Assign the PR to yourself
  • [ *] Request reviewers & ping on Slack
  • [* ] PR is linked to the ticket (fill in the closes line below)

Closes #5

…ng a given struct to given values, another one for running in an infinite loop.
@DimitryP6 DimitryP6 self-assigned this Nov 14, 2025
Copy link
Contributor

@caiodasilva2005 caiodasilva2005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

float lower_ratio;
nertimer_t debounce_timer;
uint32_t debounce_time;
} prechargeconfig_t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the struct for this, could you maybe add some docs for what each field is for?

* @param precharge_config is the empty configuration to configure.
* @return a precharge configuration for running the precharge thread.
*/
prechargeconfig_t *precharge_init(cell_asic_2950 ic, SPI_HandleTypeDef *hspi,
Copy link
Contributor

@caiodasilva2005 caiodasilva2005 Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an assert that the transition ration is <= 1 and >= 0 and that hspi is not null

* @brief Runs the pre-charge until the threshold-ratio is reached, after which the AIR switch is set to open.
* @param precharge_config is the configuration to run.
*/
void precharge_run(prechargeconfig_t *precharge_config); No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to vPrecharge like the tasks defined in shep_tasks.c and define it there. You can also set the thread parameters like delays (let's probably do about 500 ms to start) and other settings there. Use other tasks as a reference

/**
* @brief Given the cell, SPI, AIR switch, initializes the pre-charge structure for the given BATT/TS voltage capacitor threshold ratio,
* and with the given debounce time to wait when the AIR opens before closing again.ADI1_delay_ms
* @param ic idk what this is T-T.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the struct for the 2950 chipon hv plate for docs

* @brief Given the cell, SPI, AIR switch, initializes the pre-charge structure for the given BATT/TS voltage capacitor threshold ratio,
* and with the given debounce time to wait when the AIR opens before closing again.ADI1_delay_ms
* @param ic idk what this is T-T.
* @param hspi idk what this is either T-T.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the struct for the spi handler that goes into the isospi channel wae are using to comm to the chip for docs


void precharge_run(prechargeconfig_t *precharge_config)
{
if (precharge_config == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this an assert here, the code should crash if something critical like this is missing

&precharge_config->debounce_timer)) {
cancel_timer(&precharge_config->debounce_timer);
} else {
// SOME SORT OF DELAY?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment for delay timings, but yes a delay here is necessary

precharge_config->debounce_time);
}
}
// DELAY?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment about delay time.

precharge_config->hspi,
precharge_config->gpo);
air_switch_closed = false;
// I would assume there could be a voltage spike here as well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good logic, comment can be removed

}
} else if (!air_switch_closed) {
// Check if charged up until threshold.
// Should there be another check for depleted battery voltage?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah do you mean like welded AIR check? Let's not have that here now (not really in scope). This comment can be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Software-Controlled Pre-Charge

3 participants