-
Notifications
You must be signed in to change notification settings - Fork 159
Contactor Control via GPIO pins
Caution
Working with high voltage is dangerous. Always follow local laws and regulations regarding high voltage work. If you are unsure about the rules in your country, consult a licensed electrician for more information.
Caution
Contactors can weld themselves together if handled improperly, which may result in high voltage being present on connectors even when the system is powered down. Always assume high voltage is present on any high voltage wiring. To ensure safety, unplug the wiring from the battery or remove safety disconnect switches before working on the system. Then measure with a multimeter to confirm the system is off
Start by familiarizing yourself with how contactor and precharge circuits work. Here is a good whitepaper that explains how precharging works in great detail
The Battery-Emulator simulates an entire car to get EV batteries to turn themselves on. Some batteries have CAN controlled contactors (e.g. Tesla,Kia,Hyundai), but some require hardwired signals (e.g. LEAF, Zoe) to turn on contactors and the precharge sequence. Instead of having to wire manual on/off switches for these signals, you can have the emulator hardware perform this (feature called CONTACTOR_CONTROL
). This will automatically handle precharge, contactor closing, and optional economization. It will also turn off when a critical error is encountered. This improves safety for batteries that require manual control over the contactors, compared to manual on/off switches that will stay in their set state when a critical FAULT occurs. So to summarize, if you have a battery that needs hardwired signals for contactors, this is highly recommended
This is done via the 3.3V digital output header that is located on the board. To use these, you need to solder a 2x6 row connector onto the board (Easier with the Stark CMR, no soldering needed there). After the row connector is fitted, you can connect cables between the pins, and the relays.
For instance, 3x ASR-10DD can be used. ASR-M02DD is a din mounted version.
Caution
Be sure to get a DC SSR. Using an AC triggered SSR will not work, these will latch while waiting for zero crossing.
To enable the feature in the software, uncomment the following line in the USER_SETTINGS.h
file
#define CONTACTOR_CONTROL
The precharge duration can also be configured by tuning the:
#define PRECHARGE_TIME_MS 500
By default a 500 millisecond long precharge is performed. This value should be set to account for the resistance and capacitance of the inverter you use.
Note
Normally EVs perform a much more robust precharge, measuring motor inverter voltage and basing precharge duration based on this info, but since we dont have this info available a simple timer is used. Not optimal, but better than nothing!
To keep things simple, it is recommended to use Solid State Relays (SSR). These can be activated with 3Volt, and control large DC currents. Follow this schematic to complete the circuit:
- (LilyGo) Precharge pin 25 - Precharge SSR + input
- (LilyGo) Positive Contactor pin 32 - Positive SSR + input
- (LilyGo) Negative Contactor pin 33 - Negative SSR + input
- (LilyGo) GND - All 3x SSR - input
(Easier with the Stark CMR, no SSR needed on this hardware since the outputs are rugged)
Before the contactors turn on, both Inverter and Battery needs to give OK ✅ signal. This can be verified via the Webinterface. In this screenshot, battery is preventing startup:
Warning
In case the whole Emulator goes into Fault state, the contactors will open, and latch. To get them to close again, you need to restart the entire Battery-Emulator (after having analysed the fault)
You can check the Event view in the webserver, to see if any critical Error has been encountered
Incase the current draw on the GPIO pins is exceeded, for instance incase you use an unsupported SSR, the webserver will appear this way:
Note the "X" on both contactors, even though the emulator is in active state and should have contactors engaged. If you see this, remove the wires and restart the emulator, to confirm that activation of the pins is possible. Then switch to a supported SSR.
NOTE: with some Leaf BMS (so far only noticed on the 30kWh 2016) the line batteryAllowsContactorClosing = true is never set: https://github.com/dalathegreat/Battery-Emulator/blob/d759946cc41882576b6c27be095fffe0f47ba191/Software/src/battery/NISSAN-LEAF-BATTERY.cpp#L745 . This prevents the automatic contactor sequence. A workaround is to force the value to always true. So if you are having problems with the contactor sequence, change the above line to datalayer.system.status.battery_allows_contactor_closing = true;
Optional: It is also possible to reduce power consumption of keeping the big contactors engaged via PWM control. This requires Solid State Relays (SSR). The PWM signal will very quickly turn on/off the SSR, and still keep the contactor engaged. Do be careful, and test this properly before using it. It is very much depending on what SSR and battery contactor combination you use. PWM values can be tweaked in the Software.ino file
To use the PWM function, uncomment both of these lines in the USER_SETTINGS.h
file.
#define CONTACTOR_CONTROL
#define PWM_CONTACTOR_CONTROL
- Less load on the 12V supply
- Better for offgrid solutions where every Watt counts
- Less heat inside battery is good for summer