Elcon/TC Charger Firmware: The Facts

How do you store and manage your electricity?
User avatar
coulomb
Site Admin
Posts: 3398
Joined: Thu, 22 Jan 2009, 20:32
Real Name: Mike Van Emmerik
Location: Brisbane
Contact:

Re: Elcon/TC Charger Firmware: The Facts

Post by coulomb » Mon, 23 Jul 2018, 12:20

Calibrator

Here is the first full firmware file set that you can assemble for free.

It's the Calibrator program, which is a temporary stand-alone firmware that you can program into any charger to change the EEPROM values. When would you need to use this? One time is if you have to replace the microcontroller chip. Its flash, but also its EEPROM, will be completely blank. This software will calculate approximate initial values for the EEPROM, then allow you to change them so that they do their jobs more accurately.

You should also use this whenever you change a component whose value is calibrated, for example one of the (usually) four voltage divider resistors for measuring the battery and charger output voltages, or any resistor that would affect the gain or quiescent output voltage of the current shunt amplifier, including the actual current shunt resistor(s).

You might also want to run the calibrator if you suspect that the voltage or current that the charger outputs is inaccurate. Finally, it might be useful for debugging a charger that isn't working properly, or that you are testing after a repair. You have good control over what the charger is doing with this software.

Requirements

The main hardware requirement is the same as for reading and writing other firmware. See Hardware for Reading/Writing the Firmware. That's either a USB in-circuit programmer, or an Arduino board with a small veroboard circuit.

You'll also need a way to connect to the serial port of the charger. This is detailed in Reading the serial data. That's something like a Prolific USB to serial adapter and a small circuit with a 7-pin round connector on the end.

A decent multimeter is needed to calibrate against. It needs to measure the battery voltage and current. A DC clamp meter is adequate for the latter, as long as the reading doesn't drift too much. You will need a battery to test the charger with. It doesn't have to be in a car; I use a set of 8 CALB cells that I have in the workshop that run some lights in my home. It's best if the battery voltage is near the upper limit of the charger, but anything down to 24 V nominal is adequate even for a 144 V nominal charger.

You'll also need a Windows computer with at least 2 USB ports. A communications program such as Tera Term is needed to send and receive serial data. Finally, you need Embedded Workbench for 8051, a free (no cost, not open source) development environment for 8051. It's only free for uses with certain restrictions, for example you can't use the C compiler unless the output file is under 4 KiB, but that doesn't matter as we only need the assembler and editor.

One last requirement: you'll need Cygwin installed with the BinUtils package. That's so that the post-build step can run the objcopy utility. See below for how to customise orderhex.bat to call it.

User Interface
When you run the Calibrator the serial port is connected at 2400 bps, 8 bits, no parity, 1 stop bit, and the "h" key is pressed:

Code: Select all

Calibrator V1.2.22 Type h for help
h Help           Space Emergency stop
b Battery volts  c Current reading
v DC volts       s current Setting
                 z base current
e eeprom dump    r relay toggle
< less           > more
+ more current   - less current
0 zero current   d data dump
p Program eeprom o overWrite w/defaults
rb026.7 V
It is a simple menu based program like the program for programming the firmware (see other posts for details on that). The output at the bottom ("rb026.7 V") is dynamic, updated once per second. So make sure that your communications program processes carriage return without a linefeed.

The first "r" is lower case, indicating that the output relay is off. The second letter, "b", indicates that it's in "battery voltage" mode (use the "b" key to get back to this display if needed). The "026.7 V" indicates that the battery voltage reading is 26.7 V. If this agrees exactly with your multimeter reading, great. If not, use the "<" and ">" keys to correct the reading. This will change the values in RAM that will eventually be written to the EEPROM.

You can experiment with the other modes, e.g. "v" to read the charger output. If this is a high value, it might be because the base current reading is too high. Use the "z" key to enter base current mode, and adjust the base current down with the "<" key. Flip back to the "v" mode to see if it's affecting the charger output voltage. When it does, you'll know, as the output voltage will start falling from say 95% of maximum output towards zero, though it might take a minute to get there. As soon as it's lower than the battery voltage plus 10 volts, you will be allowed to turn out the output relay.

For the other calibrations, you will need to turn on the output relay with the "r" command. It takes about 3 seconds, during which time there will be no dynamic output. Use the "+" and "-" keys to increase and decrease the charge current. The "c" command will display the current reading, which can be calibrated with the "<" and ">" commands as before. There is also the "s" command, which shows what the charger is requesting. This can also be calibrated to agree with the multimeter reading. It's confusing at first, but this is necessary to separately calibrate the ADC and PWM EEPROM constants. You don't need to do this for voltage readings, because the same voltage divider is used for reading and setting voltage.

There are also commands to dump the EEPROM contents (really the RAM copy with the possibly changed values), and also some runtime data, mainly for debugging the Calibrator program itself.

When all is done, or to "save your work", use the "p" command to program the EEPROM. If you want to start from scratch with all guessed values, use the "o" command to overwrite the RAM copies with default values.

If the EEPROM contents aren't valid (e.g. a blank chip), or after you've used the "o" command, the data are marked as "not calibrated". All this means is that the first byte is other than hex C5. When the Calibrator starts, it will read the EEPROM values, and if the first byte is C5, it won't overwrite with guesses. If the first byte is other than C5, it will effectively do an "o" command and fill the RAM with guesses.

These guesses mainly come from some include files, so you have to assemble up a Calibrator program specific for your particular charger. I've come up with many values for many models, but you might be unlucky and have to write your own. The only two lines in Calibrator.asm you should need to change are near the start. At present, they look like this:

Code: Select all

#define Model 145		// Mike's present test model
#include "Models_2000.inc"      // Use Models_1500.inc or 2000 or 2500
I've classified the models by power (1500, 2000, or 2500 watts), and the nominal maximum voltage, which seems to be the half-power maximum output voltage. For example, a 1500 W charger for a nominal 144 V battery has a half-power maximum output voltage of 203 V. If it's for a lead-acid battery, it will be called a 144 V charger. However, if it's a CAN model or a Lithium model, it will be called a 203 V max charger.

The first line specifies this voltage as a #define (here 145 V), and the power is specified as part of the include file name (here it's a 2000 W charger, so Models_2000.inc is used).

When you "compile" the software, it runs the assembler, and if there are no errors, it runs a post-compile build step. This is needed to "massage" the hex output into a contiguous format required by the ISP.INO program. If you are using a third party ICP programmer, you may not need this step.

Unfortunately, you might need to customise the batch file that implements this post-build step. It's called orderhex.bat, and it contains a line that must point to the folder where objcopy.exe resides. For most people, this will be in c:\cygwin64\bin, in which case no change is required. If you have a 32-bit computer or chose to install Cygwin in a different directory or drive, then edit orderhex.bat to point to the correct directory. If the post-build step works correctly, you'll have a file called Calibrator_ordered.hex in the Debug\Exe directory relative to where Calibrator.asm is located. This is the final firmware file to send to the charger. It should have a timestamp the same or later than Calibrator.asm and Calibrator.hex (the latter is also in the Debug\Exe directory). If you're not using the Arduino software, you can use Calibrator.hex and delete the post-build step (Project / Options / Build Actions / Post-build command line).

To get started, unzip the attached Calibrator.zip into a suitable directory and use File / Open Workspace to open the Calibrator.eww file.

Please direct any questions to the Elcon/TC Charger Firmware: Discussion thread. Remember to have the power off when using ICP.INO to connect to the charger with the "R" command.
Attachments
Calibrator1.2.22.zip
(65.33 KiB) Downloaded 7 times
Learning how to patch and repair PIP-4048 inverter-chargers and Elcon chargers.

User avatar
coulomb
Site Admin
Posts: 3398
Joined: Thu, 22 Jan 2009, 20:32
Real Name: Mike Van Emmerik
Location: Brisbane
Contact:

Re: Elcon/TC Charger Firmware: The Facts

Post by coulomb » Mon, 23 Jul 2018, 12:39

"UniCAN" Firmware

This is another firmware file set. It will replace any CAN model firmware, or convert any fixed voltage charger to a "CAN" model. It is almost "universal" in that no changes are needed to the firmware if the charger is a single unit (i.e. it's a 1500, 2000, or 2500 W model). The firmware automatically makes adjustments based on the EEPROM values. A single byte can be changed (and of course the associated checksum) to make this suitable for a 2, 3, or 4 unit charger (3 kW to 8 kW models have 2, 3, or 4 1500-2500 W units paralleled in one enclosure). Alternatively, the firmware can be re-assembled for a 3000+ W charger. This firmware is suitable only for models with the NXP processor, which I believe is any 1500 / 2500 / 2000 W Elcon branded charger, and TC branded chargers manufactured before 2014.

NOTE: These Elcon chargers do NOT have a real CAN bus in the main enclosure; they implement control via a 2400 bps serial interface, using part of the 7-pin round connector. An external "CAN box" is required to convert these serial signals into real CAN bus signals. Some Battery Management Systems dispense with the actual CAN bus, and control these chargers directly via the serial interface on the 7-pin round connector.

NOTE: The serial signals are NOT RS-232. They are an opto-coupler interface, where idle = off/dark.

NOTE: At least older versions of the external "CAN box" could only handle up to about two CAN messages per second. That meant that the charger had to be the only device on the CAN bus (i.e. the charger required a dedicated CAN bus, and can't share the CAN bus with e.g. a motor controller). I do not know if later versions of the "CAN box" removed that restriction.

Requirements

The main hardware requirement is the same as for reading and writing other firmware. See Hardware for Reading/Writing the Firmware. That's either a USB in-circuit programmer, or an Arduino board with a small Veroboard circuit.

You'll also need a way to connect to the serial port of the charger. This is detailed in Reading the serial data. That's something like a Prolific USB to serial adapter and a small circuit with a 7-pin round connector on the end.

You'll also need a Windows computer with at least 1, preferably 2, USB ports. A communications program such as Tera Term is needed to send and receive serial data. Finally, IF you need to reassemble the firmware, then you also need Embedded Workbench for 8051, a free (no cost, but not open source) development environment for 8051. It's only free for uses with certain restrictions, for example you can't use the C compiler unless the output file is under 4 KiB, but that doesn't matter as we only need the assembler and editor.

One last requirement if you need to re-assemble the firmware: you'll need Cygwin installed with the BinUtils package. That's so that the post-build step can run the objcopy utility. See below for how to customise orderhex.bat to call it. Cygwin is also needed if you want to run the test program "elconsend".

Building

It is not necessary to build this software unless you want to make changes, or you have a 3000+ W model with more than one charge unit in one enclosure. (Even in the latter case, you could edit the ordered hex file for more than one charge unit. )

When you build the software, it runs the assembler, and if there are no errors, it runs a post-compile build step. This is needed to "massage" the hex output into a contiguous format required by the ISP.INO program. If you are using a third party ICP programmer, you may not need this step.

Unfortunately, you might need to customize the batch file that implements this post-build step. It's called orderhex.bat, and it contains a line that must point to the folder where objcopy.exe resides. For most people, this will be in c:\cygwin64\bin, in which case no change is required. If you have a 32-bit computer or chose to install Cygwin in a different directory or drive, then edit orderhex.bat to point to the correct directory. If the post-build step works correctly, you'll have a file called UniCANV1_1_ordered.hex in the Debug\Exe directory relative to where UniCAN_V1_1.asm is located. This is the final firmware file to send to the charger. It should have a timestamp the same or later than UniCAN_V1_1.asm and UniCAN_V1_1.hex (the latter is also in the Debug\Exe directory). If you're not using the Arduino software, you can use UniCAN_V1_1.hex and delete the post-build step (Project / Options / Build Actions / Post-build command line).

To get started, unzip the attached UniCAN_V1_1.zip into a suitable directory and use File / Open Workspace to open the UniCAN_V1_1.eww file.

Testing
I've also attached a simple program called "elconsend" that is useful for testing. It's a Cygwin application that allows you to send voltage and current requests to a serial port once per second. For example, to send 52.8 V and 1.8 A to the charger on COM6, use

./elconsend.exe COM6 52.8 1.8 enter

Use control-C to exit. C source code is provided; compile with gcc for Cygwin. To find out what serial port your USB to serial adapter is on, use a communications program such as Cygwin (but exit it before using elconsend).

Please direct any questions to the Elcon/TC Charger Firmware: Discussion thread. Remember to have the power off when using ICP.INO to connect to the charger with the "R" command.
Attachments
UniCAN_V1_1.zip
(58.86 KiB) Downloaded 6 times
elconsend.zip
(19.22 KiB) Downloaded 7 times
Learning how to patch and repair PIP-4048 inverter-chargers and Elcon chargers.

Post Reply