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.
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.
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
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
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.