rasProject_01 / weSweetHome
R. 240
process control / RasPi software by weinert-automation
|
Some functions for E-Car loading on a Raspberry Pi using pigpiod. More...
Macros | |
#define | DEF_BEG_PHASES |
E-Car AC loading start value: 3 phases. | |
#define | DEF_CP_INVERTED |
CHS_CP_INVERTED: CP signal PWM is inverted. More... | |
#define | DEF_CP_OFFSET |
CHS_CP_OFFSET: CP signal PWM correction offset. More... | |
#define | DEF_CURRENT_LIM_BEG |
E-Car start loading imit 8.7A per phase. | |
#define | DEF_MAX_PHASES |
current station offers (max.) 3 phases 6 for test | |
Functions | |
int | chsItoDutyC (float ldCurrLim) |
Calculate CP dutycycle for current limit per phase. More... | |
void | initAsCPilot (int thePi, unsigned gpio, uint8_t init) |
Initialise a GPIO pin as pilot drive. More... | |
void | setChStControl (float ldCurrLim) |
Control E-Car charging current limit per phase by PWM. More... | |
float | setChStLimit (float ldCurrLim) |
Set and get E-Car charging current limit per phase. More... | |
uint8_t | setChStNoPhases (uint8_t assumedNofPhases) |
Set and get charging E-Car's actual number of phases. More... | |
void | setCPilot (uint8_t set) |
Set CP signal to constant ON or OFF. More... | |
void | setCPilotPWM (int duty) |
Set CP signal PWM. More... | |
Some functions for E-Car loading on a Raspberry Pi using pigpiod.
Revision history
GPIO usage
an input: connected to the charging station and not ready for charging
an input: line power fed to car by a contactor
an output: CP signal as TTL to be amplified to +/-12V ba EVSE)
Note: All three signals between Pi and the load controller (EVSE, Electric Vehicle Supply Equipment) should be fed over optocouplers. Those might (preferably) be integrated in the EVSE.
Values for the loading equipment are defined by default macros defined here with named starting by DEF_ (like e.g. DEF_CURRENT_LIM_MAX 34.0). This default can be overridden in earlier include file by defining a marcro starting with CHS_ instead (like e.g. CHS_CURRENT_LIM_MAX 16.0).
Default values:
#define DEF_CP_OFFSET |
CHS_CP_OFFSET: CP signal PWM correction offset.
The CP signal's duty cycle to E-car (+/-12V) might deviate from the ¶æC's control signal (TTL).
Example: If the CP's On state is 3.3% resp. 33‰ or 33¶æs wider than the TTL signal, the latter will have to be corrected by 33‰. This number (-33) would then be the value of CHS_CP_OFFSET.
The default 0 assumes (almost) perfect symmetry of the signal change propagation. Note: CHS_CP_OFFSET 0 will slightly shorten the code.
#define DEF_CP_INVERTED |
CHS_CP_INVERTED: CP signal PWM is inverted.
In the not inverted case (0) CP signal = LO would output -12V and hi +12V. In the inverted case (1) it's the over way round. This is a fixed property of the EVSE electronic and the connection to the PI.
The default for CHS_CP_INVERTED is 0 = not inverted.
If otherwise define CHS_CP_INVERTED as 1 in an earlier include file.
void initAsCPilot | ( | int | thePi, |
unsigned | gpio, | ||
uint8_t | init | ||
) |
Initialise a GPIO pin as pilot drive.
This function initialises the GPIO pin like initAsHiDrive() and (additionally) sets the PWM frequency to 1kHz and the duty cyle range to 0..1000. The parameter init when 0 (FALSE) sets the CP output to -12V signalling EVSE being not ready. init when 1 (TRUE) sets the CP output to +12V signalling EVSE ready.
This function must be called before all other CP control functions, as it sets the CP's GPIO henceforth.
A value outside this range will turn the 1kHz CP signal off; see CHS_CP_OFF_LEV.
thePi | the Raspberry's identifier as got from initialising gpio(d) |
gpio | the GPIO number (0..53) |
init | 0: off (-12V) 1: on (+12V) |
void setCPilot | ( | uint8_t | set | ) |
Set CP signal to constant ON or OFF.
This function sets the CP either constant ON (+12V) or OFF (-12V). It will stop any 1kHz square wave.
set | 0: off (-12V) 1: on (+12V) |
void setCPilotPWM | ( | int | duty | ) |
Set CP signal PWM.
This function sets the CP duty cycle in the range 0..1000‰ applying offset (CHS_CP_OFFSET) and inversion (CHS_CP_INVERTED) if applicable.
Note: 50‰ (5%) signals the of a digital protocol (not implemented here).
The range for signalling current limit per phase is 10..970‰; see chsItoDutyC(float).
duty | dutycycle in ‰ (parts per mille) |
int chsItoDutyC | ( | float | ldCurrLim | ) |
Calculate CP dutycycle for current limit per phase.
The IEC CP dutycycle(current) curve will be applied and the outcome limited to 100..970‰ resp. 6..80A per phase.
This function just implements the standard and its limits, that is without offsets or inversion in the CP signal handling. Those, if applicable will be handled by setCPilotPWM(int) and setChStControl(float).
ldCurrLim | the current limit |
void setChStControl | ( | float | ldCurrLim | ) |
Control E-Car charging current limit per phase by PWM.
This function sets the the control pilot (CP) PWM signal to the charging station.
This function should only be called with a current value within actual limits (6...32A, e.g.). It only limits the CP duty cycle to the range 10..97% corresponding to 6..80A.
ldCurrLim | current limit in A per phase |
uint8_t setChStNoPhases | ( | uint8_t | assumedNofPhases | ) |
Set and get charging E-Car's actual number of phases.
This function sets the (assumed) number of phases for E-Car AC charging in the range 1..CHS_MAX_PHASES. The default is CHS_BEG_PHASES.
The value set will be used to calculate and eventually limit the maximum loading power. The real number of phases depends on the car(s) connected.
Warning: There exist E-car types using only one phase even when offered three!
assumedNofPhases | number of phases 1.. CHS_MAX_PHASES |
float setChStLimit | ( | float | ldCurrLim | ) |
Set and get E-Car charging current limit per phase.
This function sets the charging stations current limit in the range 6.0 ... CHS_CURRENT_LIM_MAX.
Note: This function just sets/changes the internal limit value. It will not influence any signal (CP) to the EVSE.
ldCurrLim | load current in A (per phase) |