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

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

#include "weEcarLd.h"
#include "sweetHome.h"

Macros

#define CHS_CP_OFF_LEV
 loading off CP state (1: +12V, 0: -12V)
 

Functions

int chsItoDutyC (float const ldCurrLim)
 Calculate CP dutycycle for current limit per phase. More...
 
void initAsCPilot (int const thePi, unsigned const gpio, uint8_t init)
 Initialise a GPIO pin as pilot drive. More...
 
void setChStControl (float const 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.18.2023 : new

cross-compile by:

arm-linux-gnueabihf-gcc -DF_CPU=1500000000 -DPLATFORM=raspberry_04
-DMCU=BCM2711 -I./include -c -o weRasp/weGPIOd.o weRasp/weEcarLd.c

This is a supplementary library basic library to be used in conjunction with the pigpio library (link: -lpigpiod_if2 -lrt). For documentation see the include file weEcarLd.h and also http://abyz.me.uk/rpi/pigpio/pdif2.html by Joan NN.

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)

◆ 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

◆ 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