Active switching devices in each mode.
Transportation electrification is happening at a rapid pace around the globe in response to the climate change mitigation measures taken by the regulatory agencies to curb tailpipe emissions. As the electric vehicle technology evolved, the size of on-board storage units has increased, which require charging from an external energy source. Renewable charging of electric vehicles is an attractive option to reduce the carbon footprint of an electric vehicle. The intermittent nature of the renewables necessitates a storage unit to provide continuous power. With a battery complementing solar generation, a power converter is deployed to interface these sources and storage units with the electric vehicle for charging. The converter shall now have to operate to quench the charging requirements by sourcing power from solar generation and storage elements. The converter also has to capture the generated solar power during the non-charging period and store it in the battery. All these functional requirements demand a robust energy management strategy to utilize all available sources and storage units efficiently without compromising load requirements. A Stateflow-based energy management algorithm for a three-port converter is proposed in this work. The proposed algorithm is implemented using OPAL-RT, and the real-time simulation results are presented.
- energy management
- electric vehicle
- renewable charging
- multiport converter
- real-time simulation
Transportation accounts for more than 30% of the atmospheric particulate emissions around the globe. The unprecedented increase in environmental pollution leads to climate change which affects the biodiversity and environment of this planet. Sensing the ill effects of global warming, several steps have been taken to minimize the effect of environmental pollutants. Several governments and organizations have imposed stringent emission norms for newly manufactured and old vehicles to curb tailpipe emissions from automobiles . Since fossil fuel-based vehicles cannot be made free from emissions, automotive manufacturers are looking to electrify the transportation section to improve energy efficiency and reduce vehicular emissions.
An electric vehicle (EV) is often seen as a viable option to curb atmospheric emission. At the same time, the dependence of charging power sourced from fossil fuels increases the carbon footprint of an electric vehicle. The heated debate is continuing [2, 3, 4] in the backdrop of the increase in the global trend in the acceptance of electric vehicle which is reflected in the sales of electric vehicles . As the EV market grows, so is the need for the electric vehicle supply equipment (EVSE). The EVSE, mainly the charger for EVs, is a necessary ancillary growing along with the EV market. The EVSE may be supplying power in AC or DC  from different levels. Additionally, there are different charging connectors  which need standardization. Most of the charger power is sourced from the grid, which affects the grid stability . The grid connected chargers are predominantly fast chargers  which may be inductive  or conductive . The dependence of the EV on the grid can be reduced by charging the vehicle from renewable energy sources . The intermittent nature of renewable sources demands the inclusion of storage for improved reliability . The charging station may be a stand-alone charging unit or may be a part of a microgrid [14, 15] which requires an energy management controller . A vast majority of the charger topologies are still grid dependent which undermine the clean energy image of the electric vehicle. This work propose an off-grid stand-alone renewable charger suitable for slow charging. A typical off-grid charger topology is shown in Figure 1 . The design phase of the charger can be accelerated by deploying real-time simulation  which could be used to validate the energy management algorithms in real-time scenarios and generate field-deployable code for rapid prototyping.
2. Electric vehicle chargers and energy management
2.1 Charger topology
A typical charging station with a rooftop solar photovoltaic (PV) generation and a battery considered in this work is shown in Figure 2 . This topology is modified from an onboard multiport converter proposed in  which can be categorized as a level 1 or level 2 charger  which supports prolonged charging periods for the vehicular battery. As fast charging is not considered, the grid connection has not been considered. Additionally, the original topology presented in  could be used with the front-end rectifier-based grid connected port to support fast charging. The battery-supported solar PV could be operated as an active generator that could be used to power the charging station . The charger topology is non-isolated, suitable for top-up charging of an EV in the workplace and commercial establishments.
2.2 Operating modes
The three-port converter considered in this works has three different operating modes as shown in Figure 3 . The PV-based active generator has a solar PV unit and a battery. The load port is connected to an EV through an appropriate charging connector. The connector is also used for exchanging the battery system parameters with the charger.
2.2.1 Mode 1: solar charging mode
In this mode, the solar power is directly utilized for charging the EV batteries. In the first switching state, the switch is turned ON and the inductor gets charged. The charging current slope is given by
where is the solar PV voltage and is the value of the inductor. In the second switching state, the is turned off, and the source voltage combined with the inductor stored voltage is transferred to the load port. The discharging slope for the inductor current is given by
where is the output voltage.
2.2.2 Mode 2: storage charging mode
In this mode, the energy stored in the off-board battery is utilized for charging the EV battery. This mode is suitable when solar PV generation is not sufficient to satisfy the load demand or when the solar power is not available. In the first switching state of Mode 2, the switching devices and are turned on simultaneously. The battery voltage (is used to charge the inductor in the first switching state which is given by
In the subsequent switching state, the switching device is turned off, while the switching device is kept on continuously. The discharging slope of the inductor current is given by
2.2.3 Mode 3: surplus storage mode
In this mode, the surplus energy generated by the solar PV is stored in the associated storage batteries, while the charger is idle. These modes serve the dual purpose of energy storage capture during the idle period and support charging when the solar PV generation is not adequate to prove the necessitated charging power. This mode shall be instigated when the charger is not utilized and a charger status variable is assigned to read the utilization of charger. This variable is then utilized in the mode selection algorithm to select an appropriate mode.
In the first switching state, the switching device is turned on and the inductor current equation is given by
The storage battery gets charged during the second switching state when the switching device is turned off and the battery charging port switch is turned on. The inductor current discharging slope is given by
In these three operating modes, the active switching devices and ports involved are listed in Table 1 based on which the control variable for closed loop control may be chosen.
|Mode||Source port||Load port||Active switching devices||Duty cycle|
|Mode 1: solar charging mode|
|Mode 2: storage charging mode||,||,|
|Mode 3: surplus storage mode||,||, (complementary)|
2.3 Mode selection
The availability of the multiple modes opens up the possibility of optimal usage of the sources and storage units with minimum cost and user preference by choosing an optimal mode. The primary challenge in a multiport charger is to choose a source depending on the different generation and power supply capability at any given time. Such a source selection algorithm has to measure all the relevant parameters for the source and storage units and decide a specific source based on the available measured data. The source selection should also account for the usage history, energy cost, time of charging, and user preference. A Stateflow-based algorithm is designed to choose an appropriate mode at any given time.
There are three possible modes as listed in Table 1 . At any time instant, a specific mode has to be chosen based on the system parameters like availability of power, time of charging, and user preference. A flowchart for mode selection and transition is presented in Figure 4 .
2.3.1 Stateflow-based source selection
Stateflow® is a toolbox available with MATLAB/Simulink that enables one to design state transition tables/diagrams or flowcharts graphically . The mode selection algorithm is developed using the Stateflow tool, and it integrated with the charger modeled with Simulink. Each mode is modeled as a state and the developed diagram is shown in Figure 5 . The default mode is set to Mode 1 where the solar power is used to charge the vehicular battery. The reference variable for mode selection is the energy demand of the battery (). At any given instant, the energy demand is compared with the power generated from the source and storage units available in the charger, based on which the mode decision is taken. The third mode, which is idle energy capture mode used to store the generated solar power in the charger battery, needs a separate variable to know whether the charger is engaged with a vehicle or not ().
The state of charge (SoC) of the charger battery () is actively monitored, and it has to be maintained within the safety limits to ensure the safety of the charger battery. While charging, the SOC of the battery shall not cross the maximum (), and the minimum limit () is monitored while the battery is discharged. A similar condition shall be available for the vehicular battery () which would be monitored by the onboard battery management system (BMS).
Considering a case in which both the solar-generated power () and the available battery power () are capable of supplying the vehicular battery demand individually, the cost factor () is accounted. The charger battery shall have a degradation cost associated with it, which lead to the selection of as it is the low-cost supplier at the given time instant. On the other hand, if the user prefers to top up the vehicular battery soon for a ride, the user preference () is considered, and the source capable of quenching the battery demand is selected.
In case there is no preference set up for the charger, it shall automatically choose the feasible mode based on the measured system variables. While the state chart is running, the user can visually see the active state and the measured data variables that lead to the activation of the current state, as shown in Figure 5 . The state chart outputs are just Boolean variables and there have to be integrated with the closed loop controller which is shown in Figure 6 .
2.4 Closed loop controller
In the previous section, the source selection algorithm is covered in detail. Once the source selection is made, the subsequent task is to obtain the regulated power from the available sources. A source selected to charge a vehicular battery unit has to supply regulated power to the batteries irrespective of the time which demands a robust closed loop control algorithm. A predictive control algorithm proposed for a multiport converter to regulate inductor current  is considered in this work. The inductor current waveform for the converter in Mode 1 (solar charging mode) shown in Figure 7 follows a periodic pattern throughout the operation of the converter. The magnitude of the inductor current in the upcoming switching cycle can be precisely predicted with the measured values and duty cycle from the current switching cycle. Conversely, by adjusting the duty cycle corresponding to the instantaneous value, the inductor current can be made to reach a prefixed value. The method of predicting the duty cycle in the upcoming switching period based on the measurements in the present switching cycle is implemented in predictive controller. The inductor current reaches a prefixed magnitude () as shown in Figure 7 as the measured variable at previous switching instant is utilized for duty cycle prediction.
The converter considered in this work has three different operating modes, and each mode has two switching states. In each of these switching states, the inductor current charge and discharge slopes are derived in the previous section. For Mode 1, the inductor charge and discharge slopes for the switching state are shown in Figure 7 . By knowing the past measured inductor current , charge and the discharge slope, the inductor current can be predicted using Eq. 8 given the duty cycle is known:
The duty cycle summation for a switching cycle considering the on and off period should be unity (). The prime objective of the controller is to make the inductor current to reach the target current objective within the minimum possible switching states and maintain the same irrespective of the change in the load or source variations. Now, considering the current measured variable , the current in the next switching time instant can be accurately predicted:
The above equation is rearranged as
The duty cycle is the variable to be computed, and the above equation is rearranged as
Conversely, if the current at the next timing instant is set to the reference variable , then the corresponding duty cycle to obtain the can be accurately predicted as :
The above equation is the control law for predicting the duty cycle in Mode 1. The control law depends on the measurement of the system variables (,). The control law for the other two modes can be obtained by modifying the measured variables relevant to the corresponding mode. The inductor current and the past duty cycle are measured from the corresponding active switch corresponding to each mode listed in Table 1 . A generic structure for the duty cycle prediction obtained from the control law in Eq. 12 is built in MATLAB/Simulink as shown in Figure 6 . The mode selection controller decides the mode, and then the predictive controller decides the corresponding duty cycle for the corresponding active switch and thereby the output of the converter is regulated.
3. System modeling and simulation results
3.1 System modeling
3.1.1 Modeling the mode selection controller and charger
The charger topology is modeled using MATLAB/Simulink. The solar PV model from the renewable library is used to model the charger solar generating station. To perform an extensive simulation, the solar irradiance and temperature data is fed into the solar PV model, and the simulation is performed. The charger battery is modeled as a Ni-MH battery, and the vehicle battery is modeled as a Li-ion battery.
3.1.2 Modeling the predictive current controller
The predictive current controller structure is presented in Figure 6 . The controller designed is a generic one and depends on the measurement of input and output parameters to predict the duty cycle. For instance, in , the solar PV is available at the input port and the vehicular battery at the output port. Subsequently, in Mode 3, the solar PV is still at the input port and the charger battery is at the output port. The predictive controller depends on the input and output voltage measurements of the converter to predict the duty cycle, and the proper measurements are routed to the corresponding measured variable ports as and when the modes are changed. A look-up table is built from open-loop simulations to identify the inductor current reference under different operating conditions. The predictive current controller is also dependent on the inductor value, and it is assumed that the inductor value remains constant throughout the operation of the converter.
3.1.3 Integrating the predictive current controller with the Stateflow controller
It can be identified from Figure 8(b) that the output of the mode selection controller are only boolean variables that help actuate a switching device based on the input and status variables. On the other hand, the predictive current controller generates pulse width modulation (PWM) signals suitable for switching the converter at an appropriate duty cycle to achieve the control target. The Stateflow controller and the predictive current controller are integrated as shown in Figure 8(b) . The Boolean mode selection Stateflow output is AND gated with the PWM output from the predictive current controller output. As a result of this, the PWM output from the closed loop controller is directed to the appropriate switching device based on the mode chosen by the Stateflow controller. The Simulink model of the proposed charger topology is shown in Figure 8(a) . This model shows the solar PV, charger, and vehicular battery. The gate terminal of switching devices in the charger topology is connected to the controller through “goto” blocks in Simulink.
3.2 MATLAB simulation
The complete charger system thus modeled using MATLAB/Simulink is simulated in parts initially to assess the feasibility of the individual building blocks. The specification of the charger used in simulation is listed in Table 2 . The input parameters for the Stateflow controllers are modified at first to test the different operating conditions and the corresponding mode election is verified. The different conditions for mode transition are listed in Table 3 whose variables are defined in Section 2.3.1. For the change in the status variables, manual switches and sliders are used at this stage which is replaced with the actual user input and status variables from the modeled system at the later stage while performing system level simulation.
|Primary source||Solar PV (2 kWp)|
|Storage||Battery (20 kWh)|
|Vehicular battery||Li-manganese (16 kWh)|
|Maximum charging current||15 A|
|Type||Level 1 DC charger |
|S. no||Mode 1||Mode 2||Mode 3|
|Mode 1||—||[soc_batt_char>50 && user_pref==1]||[charger_status==0]|
|Mode 3||[charger_status==1&&soc_batt_char<50]||[charger_status==1 &&soc_batt_char>50]||—|
Similarly, the predictive current controller is tested by applying a load step variation at the load port. The emulated load step variation using the resistance of different values shall make the load current to change, but the predictive current controller modifies the duty cycle to make the inductor current constant irrespective of the load conditions. Once these individual simulations are done, the model has to be modified to run the system level simulation.
3.2.1 Real-time simulation using OPAL-RT
A simulation model represents the physical behavior of a system through the operation or use of another. With the advent of mathematical modeling and digital tools, digital simulation has become prevalent. In any discrete-time simulation, a set of equations are solved at every time step which may be fixed or variable. Specifically, in a fixed-step simulation that is running on a generic purpose computer, the fixed time step taken to compute the system of equations may be longer or shorter than the actual time step.
On the other hand, the real-time simulation required must perform similar computation with the duration similar to the physical world . For simulating nonlinear systems like power electronic systems, the change in the actual time step may lead to erroneous or inaccurate results. Hence, performing a real-time simulation with small time steps help the simulation to represent the physical behavior of nonlinear systems accurately. Among the different real-time simulators, OPAL-RT is an FPGA platform that supports real-time simulation and is fully integrated with MATLAB/Simulink.
3.2.2 Preparing MATLAB model for real-time simulation
The OPAL-RT real-time simulation requires that the whole MATLAB/Simulink model be made into two subsystems, namely, master and console. It should be noted that the “powergui” block should be placed on the top model and not inside any subsystems. Initially, the model is prepared for RT-LAB simulation which is later used for real-time simulation. The steps for conversion are shown in Figure 9(a) . As specified in the previous section, the simulation should be run using a discrete fixed-step time solver. The time step should be carefully chosen and the other simulation parameters related to time should be an integral multiple of the time step. Additionally, in the MATLAB settings under the “Model configuration parameter,” the block reduction settings should be turned off. The optimization and signal reuse should be turned off. Once the model is prepared, a free run should be done with the simulation time set to infinity.
3.2.3 Master subsystem
The master subsystem shall be named with a prefix “SM_” which is an identifier for the OPAL-RT to identify what has to be taken to OPAL-RT simulator. Apart from the MATLAB built model, the “OpCtrl” block has to be included in the model. This enables the pin configuration of the OPAL-RT to be flashed into the simulator, and the configuration file should be placed in the project folder. For every signal whose monitoring is required from OPAL-RT platform, an “AnalogOut” block is added. The analog outputs of the OP4500 can produce only up to 5 V; hence all signals should be accompanied along with a suitable multiplier to scale up/down the signal.
3.2.4 Console subsystem
The console subsystem is intended for acquiring and monitoring the signals from the OPAL-RT platform back to MATLAB and to view the signals in MATLAB scope. Each signal entering into this subsystem shall be prefixed with an “OpComm” block which shall help in matching the fetching rates of the MATLAB computer along with the OPAL-RT platform. The final prepared model is shown in Figure 10 .
3.3 Simulation results
3.3.1 Simulating in OPAL-RT platform
The MATLAB model is now ready to be simulated with the OPAL-RT platform. The steps for performing the real-time simulation on OPAL-RT platform are shown in Figure 9(b) . The developed model is imported in the OPAL-RT tool, and the model is built which is then loaded into the OPAL-RT platform for real-time simulation. The proposed charger topology has to be tested for regulated output and mode selection. The load step variation is induced on the load port, and the variations the inductor current and the output voltage are presented in Figure 11 . It can be observed that the predictive current controller regulates the inductor current within the prefixed limits.
The charger power profile is shown in Figure 12 which gives the 24-hour charger power output. A typical household with an overnight slow charging is considered, and the EV is not available for charging from 09.00 to 19.00 hours. The charger power output is capped at 1 kW, and depending on the power available from the sources and the load requirement, different modes are instantiated.
3.3.2 Viewing results from MATLAB console
Once the OPAL-RT model is executed, a system generated MATLAB console opens, which is used to monitor and log the signals running from the OPAL-RT platform. The effectiveness of the predictive current controller is observed by introducing a load step variation. The current controller tightly regulates the current irrespective of the load step at 0.025 s, and the results are shown in Figure 11 .
3.3.3 Viewing results from hardware pinout
In addition to the MATLAB console, the model output can be directly read from the hardware pins available in OPAL-RT platform. This work was performed on an OP4500 platform that supports up to 96 input/output channels. The MATLAB running computer is interfaced with the OP4500 using a 5-Giga bit optical fiber cable, and the real-time simulation is performed on a XILINX Kintex 7 FPGA present inside the OP4500. A typical steady-state condition corresponding to is captured in Figure 13 which shows the PWM outputs of the two switching devices in the charger. Subsequently, the Stateflow controller is tested by changing the variable. The current mode is as highlighted in Figure 5 and the change in the status of this variable shall change the active mode to based on the conditions listed in Table 3 . The mode transition results in the change in the switching pulse signals as shown in Figure 14 .
The Stateflow controller is an efficient method to monitor the state variables and the system parameters which could be used to choose an appropriate mode based upon the operating conditions. The inductor current waveform during the normal operating conditions follows a typical charge and discharge pattern as shown in Figure 15 .
This work present the real-time simulation of a three-port electric vehicle charger with solar PV assisted battery as energy sources. With three different operating modes, the prime objective of the energy management controller is to choose an appropriate mode based on the system parameters. A Stateflow-based mode selection controller is adopted, and its development is briefed in this chapter. Once the mode selection is done, the secondary function of the energy management controller is to regulate the system variable and obtain the control objective irrespective of the load variations. A predictive current controller is introduced and the control law for duty cycle prediction is derived. The two individual controllers for mode selection and output regulation are integrated to form the energy management algorithm for the three-port EV charger. A MATLAB/Simulink model is developed to simulate the proposed charger topology and simulated. Finally, the developed charger model is loaded into the OPAL-RT platform, and real-time simulation is performed. The methodology proposed in this chapter shall be extended to any charger topology, and the steps explained in this chapter may be useful in performing real-time simulation of nonlinear systems. The major limitation of this charger topology is lack of bidirectional power flow. By changing the topology suitable for vehicle-to-grid, the battery power from the vehicle could be used for grid load demand reduction and peak shaving in load profiles. The future work in this domain shall integrate the charting infrastructure with the information communication technology for efficient power delivery and monitoring.
The authors wish to acknowledge the support provided by Electric Vehicle Engineering and Robotics (EVER Labs) Laboratory at SASTRA Deemed University, Thanjavur, India, to utilize the OPAL-RT platform for performing experiments related to this work. The support provided by Mr. Venkatavasan is instrumental in running the experiments on OPAL-RT platform. The authors would like to express their heartfelt gratitude for the sponsorship provided by IntechOpen and Knowledge Unlatched, which covered the open-access publication fee for this chapter.
inductor current input voltage inductor output voltage battery voltage switching devices 1, 2, and 3 duty cycle of the switching devices 1, 2, and 3 state of charge (SoC) of the charger battery maximum state of charge (SoC) of the charger battery state of charge (SoC) vehicular battery user preference for mode selection reference inductor current inductor current during the previous switching cycle inductor current during the next switching cycle switching time duty cycle during the present switching cycle
switching devices 1, 2, and 3
duty cycle of the switching devices 1, 2, and 3
state of charge (SoC) of the charger battery
maximum state of charge (SoC) of the charger battery
state of charge (SoC) vehicular battery
user preference for mode selection
reference inductor current
inductor current during the previous switching cycle
inductor current during the next switching cycle
duty cycle during the present switching cycle