Function blocks and Mosaic libraries 17.07.2020 14:03 17.07.2020 14:03

The function block enables operation and control of electric vehicle charging by AC module C-EV-0302M. This FB is based on the involvement in the following article.

The unit can be operated in several charging modes.

  1. Automatic - after connecting the vehicle, the contactor closes and the vehicle charges.
  2. Manual (Manual HDO) - Charging takes place only at the request of the user: Start input or interruption by Stop input.

Block structure

FB is directly connected by variables EV_In and EV_OUT with module C-EV-0203M. Parameters for setting settings and behavior properties are defined in the EVSE structure.

TEVSE.SET - It sets the behavior of the block in real time and it is possible to easily link this structure with another program in the PLC.

TEVSE.Cfg - structure for FB configuration and block default parameters

TEVSE.MODE - By setting the required bit, it is possible to select the default behavior of FB, ie manual or automatic mode.

TEVSE.State - FB status information


Using a block

The FB is immediately ready for the charging function. It is preset in the automatic control mode, ie after connecting the charger head to the car, it activates the Connect output and if the car requires charging, the Charge and Lock. output is closed. This starts charging the electric car. When the vehicle is fully charged, it adds to the interruption of charging and disconnection of the contactor.

In Manual mode, after connecting the vehicle, it is necessary to start charging manually via the Start input or TEVSE.SET.ChargeON. The current value can be continuously changed using the Up/Dw inputs which increase/decrease the current charging current by a defined step (1A) or write the required value to TEVSE.SET.ChargePower


Charging current

The charging current in automatic mode is preset to 32A and can be changed in the TEVSE.Cfg.ChargePowerAuto variable. For manual mode, the value is in the separate TEVSE.Cfg.ChargePowerMan and TEVSE.Cfg.ChargePowerManHDO.

Inputs Up and Dw  can be regulated max. Charging current by the user from the web. The step size is defined in TEVSE.Cfg.ChargePowerStep (Default is 1A).

The variable TEVSE.Cfg.ChargePowerMax indicates the maximum charging current, is preset to 56A and it is advisable to adjust it with respect to the breaking current of the circuit breaker.


Switching FB mode

Switching the charging mode uses the byte TEVSE.MODE,  according to the desired mode, to True (“1”). Attention! It is necessary to observe only one thrown bit - ie the selected mode.


Example of using FB in CFC code

First we add the library EVSE_AC_lib to the project and then we choose the alias for input and output data of the C-EV-0302M module. The example uses the aliases EV_In and EV_Out.

Then we insert FB, it is absolutely necessary to correctly assign all input and output variables, ie EV_IN, EV_OUT and EVSE. The EVSEData variable is declared here as GLOBAL.


Example of using FB in ST

As in CFC, we add a library to the project and choose an alias for the I/O structures of the module. The FB call would then look like this: