rasProject_01 / weSweetHome  R. 240
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
weEcarLd.h File Reference

Some functions for E-Car loading on a Raspberry Pi using pigpiod. More...

#include "weGPIOd.h"
#include "sweetHome2.h"

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...
 

Detailed Description

Some functions for E-Car loading on a Raspberry Pi using pigpiod.

Copyright (c) 2023 Albrecht Weinert
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_

Revision history

Rev. 253 7.10.2023
Rev. 253 07.09.2023 : new

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:

CHS_CURRENT_LIM_MAX 34.0 A per phase (CHS_CURRENT_LIM_MIN fixed 6.0 A)
CHS_CURRENT_LIM_BEG 8.7 A per phase
CHS_BEG_PHASES 3 phases start value
CHS_MAX_PHASES 3 phases maximum
CHS_CP_OFF_LEV 1 1: +12V is constant off, -1: -12V
CHS_CP_OFFSET 0 ‰ or ¶æs
CHS_CP_INVERTED 0 not inverted TTL hi outputs +12V
#define CHS_CP_OFFSET
CP signal PWM correction offset.
Definition: sweetHome2.h:286
#define CHS_CP_OFF_LEV
loading off CP state (1: +12V, 0: -12V)
Definition: weEcarLd.c:33

Macro Definition Documentation

◆ DEF_CP_OFFSET

#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.

◆ DEF_CP_INVERTED

#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.

Function Documentation

◆ initAsCPilot()

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.

Parameters
thePithe Raspberry's identifier as got from initialising gpio(d)
gpiothe GPIO number (0..53)
init0: off (-12V) 1: on (+12V)

◆ setCPilot()

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.

Parameters
set0: off (-12V) 1: on (+12V)

◆ setCPilotPWM()

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).

Parameters
dutydutycycle in ‰ (parts per mille)

◆ chsItoDutyC()

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).

Parameters
ldCurrLimthe current limit
Returns
dutycycle in ‰ (per mille)

◆ setChStControl()

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.

Parameters
ldCurrLimcurrent limit in A per phase

◆ setChStNoPhases()

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!

Parameters
assumedNofPhasesnumber of phases 1.. CHS_MAX_PHASES
Returns
the (new) number of phases

◆ setChStLimit()

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.

Parameters
ldCurrLimload current in A (per phase)
Returns
the (new) current limit