Honda Insight Forum banner

DIY Simple Arduino Discharger for IMA battery

6517 Views 50 Replies 7 Participants Last post by  Jonny69
This is a DIY guide how to build a simple IMA battery discharger controlled by an Arduino for around $20. It will automatically discharge your IMA battery to a predetermined voltage and disconnect itself. You'll need some basic electronics skills and be able to solder, but not a lot more. I am calling it the SAD discharger, because that’s how we feel when our batteries are playing up.

One of the frustrating things about charge/discharge cycling the IMA battery with a ‘dumb’ charger and simple bulb discharger is having to regularly check the battery voltage during discharge. It would be much easier if you could hook up a discharger which would simply discharge the battery to a particular voltage and disconnect itself.

This is currently work in progress. If you've seen my posts on the IMA Boost or LSAS threads, you'll have noticed that my projects operate on a glacially slow timeline. I thought I'd post this up now because the cold weather is coming and that means P1449 season is upon us. It might mean some folks can get one of these made quickly in their own time and make their charge/discharge cycling easier and might kick my *** in gear to get my own one finished. Also gives folk a chance to improve it, correct my mistakes etc. I have come up with two setups. One simply discharges to a single set voltage and shuts off, the other has 3 selectable voltage presets. Either of these can be modified to include switching your dumb charger in and out and doing full automatic charge/discharge cycling to various voltages in as many steps as you like.

The circuit to do this with an Arduino is quite simple with basic electronics. The Arduino reads the IMA battery voltage through a potential divider. A 100k Ohm trimming potentiometer across the IMA battery is used for this, set so that one side is 2.5k Ohms and the other side is 97.5k Ohms. The Arduino reads a 0-5V range on the potential divider which is equivalent to 0-200V at the IMA battery end. It is therefore relatively easy to use the Arduino to calculate the battery voltage and use it as a controller to discharge the battery and shut it off when it reaches a certain voltage.

The main components are shown in the attached pic. I'm using an Arduino Uno. Why an Arduino and not something 'better'? Sometimes good enough really is good enough and these couldn't be simpler to use. There are bigger and smaller Arduinos you can use and much cheaper clone versions. I'll be discharging through resistors. The ones shown are 100 Watt 500 Ohm resistors, which will discharge the IMA battery at 320mA at 160V, dropping down to 200mA at 100V, 150mA at 75V and 100mA at 50V if used singly. The current is doubled if wired in parallel, halved if wired in series. Aluminium extrusion is for mounting the resistors and providing some rudimentary heatsinking. The Arduino needs a 5V power supply and ideally the resistors want a fan on them, so I opted to use a cheap ATX computer power supply with a switch. This conveniently provides the case, power and cooling, plus an additional 12V line to power the battery fan if needed..

88272


I'm going to gut much of the power supply and move the fan to the outside of the case to make space for the Arduino and resistors. It needs the green lead on the ATX connector connected to 0V so that it switches on and off when the power switch is flicked. I'll replace the bundle of leads with just the connector to my battery charging harness, which is conveniently one end of a 4-pin computer CPU power extension cable. 12V is available to power the battery fan if needed. For a more stable 5V supply, I've read that a 5-10 Ohm resistor should be put across the 0V and 5V rails so that there is a basic load at all times. You could also do this with a 6V bulb.

The discharge resistors will have to be switched in and out with a relay. The Arduino won't be able to power a relay directly, so you'll have to drive the relay through a small NPN transistor with a diode across the relay coil. I'm planning to mount all these small components on a small piece of prototyping board.

The only additional components on the single voltage discharge box are a couple of LEDs to say that discharge is in progress and discharge is complete. For the 3-preset box, I intend to use a 3-position switch with some resistors to tell the Arduino which voltage to go to.

Code is in the next two posts and works on the bench with a 0-5V variable supply as a doing the triggering. Next step for me is to wire it up for real.
See less See more
  • Like
Reactions: 5
41 - 51 of 51 Posts
8
Here are some components I've used that will help the DIY builder. You'll find all these on eBay. As with most things on eBay, if you can wait for the long delivery time from China, everything is cheaper.

A genuine Arduino "Genuino" Uno will be about £15. Chinese Arduino Uno clones can be had for £4-£5 delivered with a USB cable. I haven't tried one yet but I probably will. Watch out if you specifically want a genuine one, because the wording is sometimes a bit ambiguous on eBay listings. £4.30 delivered from China example:
88547


I soldered up an input/output board out of stripboard and PCB screwdown terminals. I find it's way more flexible using screwdown terminals than soldering wires straight in the board. Turns out you don't need to make one - you can buy them for £2-£6 depending on the type. They're called Screw Shields.

This one +£2 if bought with the Chinese Arduino above:
88548

This type is two separate boards for either side, £2.39 delivered from China, with nice wobbly looking soldering:
88549


This one £5.99 from a local (UK) seller and comes with connection pins which you can't see:
88551


A bumper case makes it easier to mount the Arduino in something and the open top lets you stack up the shield boards if you want. These ones £2.49 from a local seller:

88552


I've also changed my fan for a 5V 0.15A USB-powered one. About £5 delivered for this one from a local seller, but cheaper if you can wait for one from China:
88553


I paid way over the odds for my SSR modules. Here's an example of a 4-relay version of mine with the same relays for £10.79, which is less than I paid for one of my modules. Fewer wires to wire in, too, as they all share the same +5V power line. They come in 1, 2, 4 and 8-relay versions:
88554

Attachments

See less See more
I really enjoyed this thread and thanks for going the extra mile to explain things and show where to get them. Glad i could be of service even if for a small bit of code.

I must add if anyone were inclined to get into any arduino's that cheaper ones, like Jonny mentioned, are out there but i must implore you to grab a random "led blink code" and attempt to upload that code immediately to test if the arduino is good. I have dealt with non-genuine (almost always china made) arduinos and have dealt with numerous DOA arduinos. An insane amount actually. So while its viable just beware!

Still anxious to see how you encase your final product Jonny. Good job again on all of this!
2
Still waiting for my Arduino bumper case to arrive in the post before I can proceed to final build. I've fitted the fan on the case and tested it with the resistor heatsink and the flow is good, in fact unexpectedly good for a low power fan and the compromised position of the heatsink.

In the meantime, I've got a little ahead of myself and modified my RB Batteries charger so it can be triggered by the Arduino. The idea is I can automate the charger as well as the discharger and essentially let it sit there and cycle the battery automatically.

Inside the charger is just a 12V PSU and two constant current LED drivers, like you'd make with a simple home-made grid charger. I made up a little extension board for the 5V relay unit with a 5V regulator, powered by the 12V PSU, which switches the LED drivers on and off. I also made up a trigger line to connect between the relay and the Arduino so it can turn the charger on and off.

88653


88654


On the charger case I also added a switch so I can switch between triggered mode and manual charging.

If you do this too, make sure your relay unit is trigger HIGH, ie +5V turns the relay on. Mine is trigger LOW, so 0V turns the relay on. It still works, it's just a bit more faff to set up and you have to be more careful with stray voltages when you switch things on.
See less See more
3
Ok, here we go. This was a proper squash and a squeeze. I probably won't use a PSU case again for this sort of thing, it's a bit too small for a DIY project!

88756


Arduino is at the back behind that mess of wires. 90° USB lead stuck in the side. Then the two SSR relay modules in a small plastic case in the middle. The resistors are on the back of the heatsink. Values are now 500R for the lower rate discharge and a 250R switching in for the higher rate discharge. 120mm fan in the top of the case has been replaced with the 5V USB fan. A blob of hot-melt stops the LEDS wiggling around.

I couldn't fit the voltmeter in so it's temporarily on a flying lead. The other leads are the USB to run it (it can run on a laptop or just on a USB phone charger), output plug to IMA battery, input plug from charger, charger trigger line.

With the case closed:

88757


Printed some Dymo labels for the front:

88758


I added in a test point on the front panel where I can either measure the 0-5V voltage range on the potential divider, or put 0-5V on it for testing the box.

See I've also got a 'charge' LED in the panel. The circuit works but I haven't managed to make this trigger the charger satisfactorily by itself when fully wired in. I don't really like the 'low trigger' relay board as a concept here, because it means when the relay is disconnected there is always a stray +5V floating on on the wire which needs to be tied low with a resistor. It also makes me quite nervous that stray static or poor grounding might trigger it, so I'm going to swap it out for a relay that triggers high since it's controlling mains voltage and puts out 200V DC. I don't feel like it's safe. At least with a trigger high relay it won't turn anything on unless you put +5V on it.

So. If I did this again what would I do differently?
1) I'd use a larger case so everything can lay flat. Upright like this means it all fits but I have to assemble it in a particular order, it's REALLY fiddly and the wires all have to be quite short else they won't go in. Having to mount things in the lid is also a nuisance.
2) A case with thicker metal would be easier to work with, too, preferably aluminium or even plastic instead of steel.
3) I underestimated the number of wires and it could do with a lot more screwdown terminals, particularly +5V and 0V points. Using a 2x relay board instead of two singles would mean one less 5V and 0V connection - worth thinking about that sort of thing in advance.
4) Trigger high relays. It's just safer because they stay off no matter what.
5) External reset button would be useful. I will probably add one next time I've got it apart because there's not enough space to get to the pins now it's assembled.
Edit: 6) Longer leads. Longer leads are your friend.

Next job is to modify V3.1 of the code so it doesn't spit out quite as much data, but this is just a tweak.
See less See more
Last pic. With the voltmeter and wire secured to the case.

88759
See less See more
  • Like
Reactions: 1
2
Working update. Most of this is not relevant for anyone building just a discharger as it relates to the possible future charger connection and automation. For the discharger bit, I contacted RB Batteries to find out what fuse was fitted to their battery harness to check I’m not drawing too much current, and it’s a 2A fast blow 3AG 1-1/4 x 1/4 fuse. I’m drawing about 1A at max discharge. All fine. Just putting that there for reference.

I pulled the discharger apart the other night to re-work the charger relay trigger wires. Previously it was a single switched 5V/0V line from the Arduino and the relay was powered by the 12V PSU in the charger, all on a common ground. This worked on the bench but was problematic when fully connected up. I swapped it to a dedicated set of 0V/5V/trigger lines directly powered by the 5V power from the USB line. This had the additional benefit of making it a lot harder to accidentally trigger it and it can be easily swapped between high or low trigger in the software. I have a high trigger relay module in the post.

As is typical, the wires I needed to change were right at the back:

88872


Then I was working through a hole, looking down the screwdriver shaft:

88873


Also re-wired the charger relay and changed the wiring on the manual/trigger mode switch. That done, wrote a bit of software to just cycle the outputs and the relay fired each time as expected. However, with the mains supply connected, the relay started sticking on occasionally...

Not 100% sure what the problem is yet. The relay is rated to 250V and 10A, probably optimistic for a small Chinese relay, but I’m drawing maybe 1A max. It could be a surge at power-on. It could be a back emf on switch-off, so it might need a resistor-capacitor snubber across the terminals. I have some high voltage capacitors in the loft I can try for this. It could of course just be a faulty relay. I have another one coming anyway so I’ll try that as well.
See less See more
3
I wasn't completely happy with how hot this got discharging at full whack. I found a new case with space to lay everything out flat and for a second heatsink. This is Mk2:

90462


90463


90464
See less See more
  • Like
Reactions: 1
Also, latest code:

Code:
/*
  switchCase IMA discharger V3.2

  Code is based on the switch statement. The switch statement allows you
  to choose from among a set of discrete values of a variable. It's like a
  series of if statements.

  The circuit:
  - 4 resistor array between 0V and +5V (0V, 2.2k, 10k, 10k, 2.2k +5V works). 3 position selector switch to analog in 1 switches between the centre point and either side of the 10k resistors
  - A 100k trimming potentiometer goes across the IMA battery, set to 2500R on the 0V side and 97.5k on the +ve side. On a 0-200V scale, this creates a 0-5V range on the potential divider that the Arduino can read. Arduino pin A0 goes between 0V and the 2500R tap.

  Changes from switchCase IMA discharger V3.1:
  The following are to reduce the data output for improved data logging:
  1) Setup prints the switchCase IMA Discharger version to the Serial Monitor
  2) Changed the loop outputs to the Serial Monitor to a single csv formatted line (time,voltage) instead of 5 lines of text
  3) Changed the loop delay from ~1 second to 10 seconds to reduce data
  4) Added a loop counter for the 'time' field

  Original SwitchCase code by Tom Igoe and is in the public domain:

  http://www.arduino.cc/en/Tutorial/SwitchCase
*/

// these constants won't change. They are the lowest and highest readings you
// get from your sensor:
const int sensorMin = 0;      // sensor minimum, defined in original SwitchCase code
const int sensorMax = 900;    // sensor maximum, discovered through experiment (600 in original SwitchCase code)

const int DischargeOutput1 =  4;      // pin number for discharge output 1
const int DischargeOutput2 =  5;      // pin number for discharge output 2
const int FinishedLED =  6;      // pin number for finished discharging LED

int count = 0;

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  pinMode(DischargeOutput1, OUTPUT);
  pinMode(DischargeOutput2, OUTPUT);
  pinMode(FinishedLED, OUTPUT);
  digitalWrite(DischargeOutput1, LOW);
  digitalWrite(DischargeOutput2, LOW);
  digitalWrite(FinishedLED, LOW);
  Serial.println("switchCase IMA discharger V3.2");
  Serial.println("Time,Voltage");
}

void loop() {
  // read the sensor:
  int sensorReading = analogRead(A1);
  // map the sensor range to a range of three options:
  int range = map(sensorReading, sensorMin, sensorMax, 0, 2);

  // select discharge voltage depending on the range value:
  switch (range) {
    case 0:    // switch position is between 2.2k and 10k at 0V end of array, reads approx 0.45V
      // Discharge to 140V
      {
        // read the input on analog pin 0:
        int sensorValue = analogRead(A0);
        // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 200V):
        float voltage = sensorValue * (200.0 / 1023.0);
        // print out data on one line for logging:
        Serial.print(count);
        Serial.print(",");
        Serial.println(voltage);

        // if the voltage value is high enough, turn on the discharge outputs:
        if (voltage > 145.0) {
          highDischarge();
        }
        else if (voltage > 140.0) {
          lowDischarge();
        }
        else {
          endDischarge();
          stopSketch();
        }
      }
      //delay(1000);
      break;

    case 1:    // switch position is at middle of array, reads approx 2.5V
      // Discharge to 120V
      {
        // read the input on analog pin 0:
        int sensorValue = analogRead(A0);
        // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 200V):
        float voltage = sensorValue * (200.0 / 1023.0);
        // print out data on one line for logging:
        Serial.print(count);
        Serial.print(",");
        Serial.println(voltage);

        // if the voltage value is high enough, turn on the discharge outputs:
        if (voltage > 145.0) {
          highDischarge();
        }
        else if (voltage > 120.0) {
          lowDischarge();
        }
        else {
          endDischarge();
          stopSketch();
        }
      }
      //delay(1000);
      break;

    case 2:    // switch position is between 10k and 2.2k at 5V end of array, reads approx 4.55V
      // Discharge to 100V
      {
        // read the input on analog pin 0:
        int sensorValue = analogRead(A0);
        // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
        float voltage = sensorValue * (200.0 / 1023.0);
        // print out data on one line for logging:
        Serial.print(count);
        Serial.print(",");
        Serial.println(voltage);

        // if the voltage value is high enough, turn on the discharge outputs:
        if (voltage > 145.0) {
          highDischarge();
        }
        else if (voltage > 100.0) {
          lowDischarge();
        }
        else {
          endDischarge();
          stopSketch();
        }
      }
      //delay(1000);
      break;

  }
  delay(10000);        // 10 second delay in between reads
  count = count+10;    // increment the time counter

}

void highDischarge() {
  digitalWrite(DischargeOutput1, HIGH);
  digitalWrite(DischargeOutput2, HIGH);
  //Serial.println("High rate discharge on");
  //Serial.println(" ");
}

void lowDischarge() {
  digitalWrite(DischargeOutput1, HIGH);
  digitalWrite(DischargeOutput2, LOW);
  //Serial.println("Low rate discharge on");
  //Serial.println(" ");
}

void endDischarge() {
  digitalWrite(DischargeOutput1, LOW);
  digitalWrite(DischargeOutput2, LOW);
  Serial.println("Discharge off");
  Serial.println(" ");
  Serial.println("Cycle finished, end of discharge");
  digitalWrite(FinishedLED, HIGH);
  delay(1000);
}

void stopSketch(void) {
  // this is used to stop the code indefinitely after discharging
  noInterrupts();
  while (1) {}
}
See less See more
  • Like
Reactions: 1
And here it is hard at work, powered by a USB adaptor. Runs waaaaay cooler like this!

Attachments

See less See more
  • Like
Reactions: 1
Very interesting project, especially as I recently starting playing around with Arduinos.

One thing I would suggest is not to rely on just the potentiometer as your voltage divider. I'd suggest using fixed resistors to do most/all the work, since potentiometers are one of the least reliable components around and could move if the unit gets knocked. You could still include the potentiometer for fine tuning, and if it failed the effect would be much smaller, but you could also use fixed resistors on their own by either selecting/combining values to hit the exact ratio you need (since you wont want to change the ratio), or you could calibrate in the software. The Arduino input impedance is very high so I think a potential divider with a higher resistance would be fine and if you wanted to stick with the 100k potentiometer you could connect it in series with say a 150k resistor between the +HV and Arduino input and then have have 4.7k resistor from the Arduino input to ground. This would give a range of ratios from about 30:1 to 50:1 for the full potentiometer travel and if the potentiometer fails the 4.7k will pull the input to zero.
See less See more
^ Thanks, I have seen it drift a bit actually. The drift is also a combination of temperature and the actual supply voltage to the Arduino. Fixed resistors would eliminate one issue and I like your idea of it being pulled to zero in case of failure.
41 - 51 of 51 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top