Page 1 of 2

Latest Firmware Version

Posted: Tue Aug 06, 2013 1:04 pm
by Mark
This latest version is now pretty much feature complete - I'm not planning to add in any more major improvements at this stage.

Please view the following post for a quick guide on how to flash the charger with this firmware:

Please read the above guide if you have any problems with compiling the firmware!

Please post discussion about this firmware in the following topic:

Note: an easier way to update the firmware can be found in the following thread:

Re: Progress on Charger Firmware with Virtual Machine

Posted: Sat Aug 10, 2013 3:43 pm
by Mark
I've just finished doing some work on the charger firmware:

  • Fixed a bug where the shift registers were swapped - the wrong LED would be lit, and the charger would be charging the wrong cell!
  • Added support for the 3 position mode switch. The middle position will now charge as expected and the outer positions will both do a discharge into the 3.9 ohm resistor - no difference between outside positions at the moment.
  • Added support for the charging current switch. High will give 1000 mA, Medium 500 mA and Low 200 mA. -dV termination probably won't work at 200 mA.
  • When logging is started, it will now log the hardware and firmware version to the log file/serial port.
  • Fixed a bug that caused data corruption on the SD card when the LCD board was connected.
  • Added a new ReadAndLog opcode to combine reading Voltage, Current and Temperature and then logging the results with a single byte instruction.

I've attached the latest version of the source to the first post. Initial testing on the latest board that I've got seems to be good, but keep in mind that I haven't spent that much time testing it yet!

I'll write up some instructions on general use for this firmware some time later. For the moment, I'm heading off to bed since it's now 1:40am!

Re: Progress on Charger Firmware with Virtual Machine

Posted: Mon Aug 19, 2013 3:42 pm
by Mark
I've just uploaded Version 0.502 to the first post - changes with this version include:

  • Added Already Full Check - LED will light up purple if cell is at or over 1.4V Prevent accidentally overcharging a full cell and also helps to reject Alkalines.
  • Added Resistance Check - does a brief charge and discharge to estimate cell resistance. Will refuse to charge cells with more than 300 milliohms resistance - should reject most alkalines, but not guaranteed.
  • Implemented Inflection termination method - initial test results seem to be good, but needs more testing.
  • Fixed bug which caused the elapsed time to be incremented even during pauses between charging.
  • Added Refresh & Analyze mode: Discharge, Charge, Discharge, Charge. 30 minute rest between each charge and discharge. Good to check remaining capacity, recharge and discharge to get actual capacity and then finally recharge to leave battery ready for use.
  • Added Header line to output.
  • Fixed a bug that prevented the over temperature check from working.
  • Modified charging currents: High mode will now charge at 1amp and the charge will only charge one cell at a time - if a second cell is inserted, it will automatically start charging it once the first one has finished. Medium mode will charge at 1amp as well, but with a pause to give an effective rate of 500mA. In this mode, if 2 cells are inserted, the charger will alternate between them. Low mode will charge at 400mA with a pause to give an effective rate of 200mA - again, in this mode it can charge 2 cells by alternating between them.
  • Added register for firmware version.
  • Reduced the number of long registers and replaced them with byte registers to save memory.
  • Reduce duration of off period when fast charging a single cell. Effective charge rate should now work out to about 950mA.
  • Increased maximum temperature for Revision 4 charger due to proximity of temperature sensors to charging circuit.
  • Fixed a problem with compiling with the Arduino IDE version 1.5.2

I've also updated the list of outstanding items listed in the first post.

Re: Progress on Mark's Firmware (Latest Version Attached)

Posted: Tue Aug 20, 2013 12:37 pm
by Mark
I've just updated the firmware to 0.504:

  • Fixed a bug causing a Panic (SOS LED flashes) when trying to do an Analyze.
  • Fixed some problems with EEPROMEx Class: regained some RAM and fixed an incorrect error message.
  • Added code to set EEPROM memory size - I had assumed that this would be automatically set based on chip type selected in the IDE.
  • Fixed (hopefully) inconsistent filename case names.

Re: Progress on Mark's Firmware (Latest Version Attached)

Posted: Wed Aug 21, 2013 8:42 am
by Mark
I've just updated the code to version 0.506:

  • Fixed a weird problem when inserting a second battery if charge rate was set to Medium or Low.

Re: Progress on Mark's Firmware (Latest Version Attached)

Posted: Fri Aug 30, 2013 4:13 pm
by Mark
I've just uploaded version 0.508:

  • Fixed defines for Charger revision 5 - was previously defined incorrectly as revision 6.
  • Added support for charger revision 6 - using the 18 bit ADC to read current in and out of batteries.
  • Added code to load byte code programs from SD card into EEPROM and run them from there.
  • Added code to enable WatchDog Timer Reset
  • Added code to log last reset reason.
  • Added Interrupt Service Routine to handle LED sequences.
  • Added new op code to make use of LED ISR above.
  • SOS is now run by this ISR, so timing should now always be good.
  • Will now flash green instead of solid purple if cell is detected as full.
  • Made reg_LED readable.
  • Added reg_LEDPrescale to allow control of LED Sequence speed.
  • Fixed a bug with op_JE op.
  • Fixed a bug that could prevent fast charging from starting.
  • Modified Read_ADC to allow selection of resolution and gain.
  • Fixed an error in mcp342xRead that could cause invalid data to be returned when measuring with less than 18 bits of resolution.
  • Added registers to control ADC resolution.
  • Modified Internal Resistance check to use lower resolution measurements - should actually make the check more accurate.
  • Fixed timing issues that could cause early termination when starting or finished charge on a second cell and charge rate set to medium or low.
  • Freed up some RAM and Flash by not including the SoftwareSerial library if not needed.
  • Added flashing blue indication when there is a problem starting the logging feature - e.g. if the SD card is missing or not inserted properly.
  • Added mini light show on startup.

Re: Progress on Mark's Firmware (Latest Version Attached)

Posted: Tue Sep 17, 2013 8:30 am
by Mark
I've just uploaded version 0.510:

  • Added op_LOGMF - Logs a preset message followed by total time, capacity and energy.
  • Fixed cells not being detected if their voltage was below 0.9V Cells now need to be at least 0.3V to be detected.
  • Added (a modified version of) Paul's light show at startup.
  • Disabled debugging messages in the EEPROMEx library to free up some flash - modified the code to still keep the write limiting feature enabled.
  • Renamed reg_CycleSwitch to reg_ModeSwitch
  • Added reg_StartupCode - allows byte code program to determine whether the MCU has been powered on, or if it was reset due to an external reset, brown out or watch dog.
  • Changed message "min dV detected" to "Inflection detected"
  • Changed maximum allowed current from 1 amp to 2 amps - use with caution - not actually used by current firmware.
  • Cut some fat from the EEPROMEx library to save some Flash.
  • Removed logging of free memory to save some Flash.
  • Replaced MultiAnalogRead with analogRead to save some Flash.
  • Added support for the push button.
  • Added check to make sure that each VM doesn't run for more than 1.7 seconds at a time - otherwise that channel will panic - this should pre-empt the watch dog unless the whole controller has crashed.
  • Added multiple modes depending on duration of button press.
  • Added precharge feature to revive dead cells before doing internal resistance check and then main charge.
  • Numerous other minor changes.

Assuming that there aren't any bugs, this version should be good enough for Paul to start sending out to the first batch of customers! There are a lot of changes though and I haven't fully tested them all, so this does need to be tested quite a bit before then.

Note that this will most likely be the last firmware version to support hardware revisions 5 and earlier. Paul has asked me to clean up the code to make it easier for others to understand.

Re: Progress on Mark's Firmware (Latest Version Attached)

Posted: Thu Sep 26, 2013 1:57 am
by Mark
I've just uploaded Version 0.512:

  • Added feature to bypass loading of program from SD card if switch is held down during startup.
  • Added EEPROM setting to switch above behaviour so that programs are loaded from SD only if button is held down during startup.
  • Added feature to load from "charge.bin" "dischrge.bin" or "analyze.bin" depending on mode switch position. If file not found, will try for "charger.bin" then default to built in program.
  • Added in random light show if charger is inactive for more than a minute.
  • Improved accuracy of internal resistance check.
  • Rewrote EEPROMEx library to save some flash space.
  • Moved many parameters to EEPROM so that they can be changed without replacing the entire default program.
  • Made a change to hopefully prevent a brown out condition occuring when starting charging after a full discharge.
  • Fixed a bug preventing a rest from being given between charging and discharging.
  • Default Hardware version will now be set for the revision 7 charger. Older versions are still supported for the time being.
  • Other minor bug fixes.

The next major job to do is to switch over to the SdFat16 library to free up some space for other features.

Re: Progress on Mark's Firmware (Latest Version Attached)

Posted: Sat Oct 12, 2013 2:25 pm
by Mark
I've just uploaded Version 0.514:

  • Fixed a file name case error affecting Linux users.
  • Optimized Logging code to reduce flash usage.
  • Changed to white with brief red flashes whilst waiting to charge.
  • Changed Internal Resistance Check to only use resistance measured whilst charging. Resistance during discharges is still measured for informational purposes.
  • If cells have a resistance of over 1 ohm, the charger will now reduce charging current to 200mA and the LED will alternate between red and purple whilst charging.
  • Replaced standard Arduino SD library with fat16lib - this reduced compiled program size by almost 6KB! This does mean however that cards greater than 2GB are no longer supported.
  • Fixed a bug with loading alternate byte code programs based on switch position.
  • Changed behaviour with pressing button whilst starting - pressing and holding the button will now cause the charger to load a mode specific file, otherwise it will attempt to load the main charger.bin file.
  • Modified logging to show PWM value that was used prior to the measurement rather than the updated PWM value.
  • Added Voltage limit for constant voltage charging.
  • Added support for detecting and charging NiZn cells.
  • Added support for discharging into an external load.
  • Fixed a problem with random light show not being shown under certain circumstances.
  • Moved most of the byte code program into a separate area of flash so that byte code programs on SD can be a lot smaller to fit into the available EEPROM space.

Note that due to some of these changes and the fact that I haven't had much time to fully test it, there's a good chance that there will be bugs in this version - please let me know if you run into anything!

I'd consider this version mostly feature complete. There's just a few more minor changes that I want to make.

Re: Progress on Mark's Firmware (Latest Version Attached)

Posted: Wed Oct 23, 2013 11:54 pm
by Mark
I've just uploaded Version 0.516:

  • Added optional top off charge. (Default is to do it only when running analyze and discharge modes - not normal charging)
  • Improved support for NiZn cells.
  • Added capability to use PWM to vary discharge current through the internal load resistor.
  • Reinstated more verbose error messages since we've not got some flash space to spare.
  • Increased number of general registers by 25%
  • Doubled number of EEPROM registers.
  • Added code to reset EEPROM write count after loading program from SD card.
  • Changed Channel numbers in output to be 1 & 2 instead of 0 & 1.
  • Added display of estimated internal resistance at start of discharges.
  • Added redirection table to allow SD card programs to replace up to 10 support routines - similar to virtual methods.
  • Changed Waiting to charge from White/Red combination to Blue/Red combination.
  • A few other minor changes.
  • Fixed a few minor bugs.
  • General code clean up.

I'm not planning to add any more new features before Paul starts sending out the non LCD boards. If there aren't any bugs found in this version, it will most likely be the version that goes out to everyone who is getting a non LCD board.

If you've already got a charger, I'd appreciate it if you could start seriously testing this new version so that we can be reasonably sure that there are no bugs before it's sent out to the masses!