Saturday, 16 February 2013

Simple, but it works

I have now removed the INA219 breakout board from my Arduino. It took quite a bit of work with the soldering iron to get it off. It is definitely toast. Putting 5v across it and it gets finger-burningly hot pretty quickly. So, I've ordered another one which should be here in a few days.

In the meantime I still wanted to try and get some more charge at 14.4V into my battery. As you may remember the last attempt to charge the battery stopped shortly into the constant 14.4v 'absorption' phase.

So I went old-skool and built a simple voltage divider using a 24K and 10K resistor on a breadboard. I calibrated in software against my digital voltmeter. I wrote a simple Arduino sketch to read the voltage from the analog input connected to the middle of the voltage divider and adjust a PWM pin connected to my MOSFET board accordingly.

I tuned the algorithm a bit to try and stop the oscillation I was seeing before:

void loop() {
  last_voltage = voltage;
  // 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):
  voltage = sensorValue * (5.0 / 1023.0) * ((25+10.0)/10.0) * 0.989;
  // print out the value you read:

  if (voltage > 14.4 && voltage >= last_voltage) {
    output_level -= 1;
    if (output_level < 0) {
      output_level = 0;
  } else {
     output_level += 1;
     if (output_level > 255) {
      output_level = 255;
  analogWrite(6, output_level);

It seems to work and when the charger got to 14.40V it kept pretty close to that value and only oscillated by about 0.01V.

Arduino and breadboard with voltage divider on it to read voltage from battery

I am not able to log the current and voltage like before, so can't produce any graphs, but at least I can give the battery a good absorption charge. I can hear a bit of bubbling going on, so will check in a bit and may adjust the voltage down a bit if it gets too much.

No comments:

Post a Comment