CUER
/
charger_code
Code to run on the charger board (used to charge the car from the mains).
charger.h
- Committer:
- drajan
- Date:
- 2017-05-06
- Revision:
- 0:6d930d0d13a1
- Child:
- 1:0c77e20b4d4c
File content as of revision 0:6d930d0d13a1:
#include "mbed.h" #define MAX_VOLTAGE 155.0 #define MAX_CURRENT 10.0 #define KI_CHARGE 2.5 #define KI_BALANCE 0.6 #define TIME_STEP 500 #define TEMP_RAMP_START -5.0 #define TEMP_RAMP_FINISH -1.5 #define CHARGER_MSG_TIMEOUT 6000 //ms #define BMS_MSG_TIMEOUT 2000 //ms //change to whichever pins LEDs are connected to. DigitalOut green_led(p21); DigitalOut yellow_led(p22); DigitalOut red_led(p23); Timer chargerboard_timer; void get_charger_data(void); void get_voltage_data(void); void get_bms_data(void); void calculate_current(float voltage_error, float temp_margin, float *current, float *voltage); int chrg_status_recv_time; int bms_minmax_cell_volts_recv_time; int bms_pack_status_recv_time; bool bms_timeout; bool charger_timeout; bool charge_finished; float voltage_error=0; //(V) float temp_margin = 0; float discharge_error; float capacity; float min_cell_voltage; //(V) float max_cell_voltage;//(V) float rising_voltage_threshold; //(V) float falling_voltage_threshold;//(V) int bms_status; float charger_current, charger_voltage; float desired_current = 0, desired_voltage = MAX_VOLTAGE;