Arduino cell cycle tester project

How do you store and manage your electricity?
User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 03:58

Hmmm, just realised the AREF pin is not tied to the 5 V rail - would this help?
AEVA National Secretary, WA branch vice-chair

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 04:54

I've updated the wiring diagram so it better reflects what I have on my bench:

Image
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Sun, 19 Jun 2016, 06:55

Hi jonescg.
You really need to put a resistor in series with the top of the pot to prevent the analogue input exceeding 5v if ever you crank the pot up full.
I think that when you tested this without the Uno powered up, the internal protection diode on the analogue input (inside the cpu) made the 5v supply get close to 5v and therefore the board powered up.
I don't know why both relays would operate at power up, but can you replace the relays with LEDs and 1k resistors to ground to see what happens, as this is how I tested the code.
neilg

User avatar
evric
Site Admin
Posts: 500
Joined: Sun, 20 Jul 2008, 01:57
Real Name: Eric
Location: Adelaide SA
Contact:

Arduino cell cycle tester project

Post by evric » Sun, 19 Jun 2016, 16:03

Hi Chris,
In your flow chart - add under "Start", "Turn both relays off" as the first command.
Eric
Prius Plug-in Conversion: http://www.evplus.com.au ...Holden Barina EV: http://www.evric.kestar.com.au

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 17:39

Easy fix on the pot.I knew there was a risk of overshooting 5 V hence I was turning it slowly. Still, I don't think I've damaged it. The relay board has LEDs on it indicating if the relay is active, that's how I know its on or off. I'll have another play with it today but the pot shouldn't need adjusting now.
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Sun, 19 Jun 2016, 18:44

Hi again jonescg

Have been thinking about the relay problem. When the cpu is reset all digital pins are set as inputs and I suspect that weak pullups are turned on. This is enough for the transistor driver on the relay board to turn on and operate the relay. Easy fix - just put a resistor of about 4k7 from each relay input pin to ground.

Next - I think you do need to connect the AREF pin to +5v.

Voltage display - In the loop() function just put the following two lines after the two instances of "cellVolts = readVoltage();"

Serial.print("Voltage = ");        // Logging
Serial.println(cellVolts);

This will log the voltage every second.

Testing - Sorry I forgot to give you a description of how it should work. The following will simulate the charge and discharge cycle.

Before powering up, turn the pot down so the analog input pin will be less that 3 volts.
After reset, the charge relay should operate.
The log should show the voltage which should increase as the pot is slowly turned up.
When the voltage is around 4 volts, the charge relay should release.
About 30 seconds later the discharge relay should operate.
Slowly wind down the pot until the discharge relay releases.
About 30 seconds later the charge relay should operate and the cycle repeats.

On my AtMega I found that the +5v was actually 4.8v and as this is the A2D reference voltage it affects the actual voltage as shown in the log. You may need to change the value for VCCVOLTS to whatever your +5v is.

The times and voltages are configurable to whatever you need.

Hope this helps
neilg

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 19:05

Thanks neil, I found one obvious error in my circuit where 12 and 13 were reversed. I fired it up and so far its discharging. Will watch when it hits LVC to see what happens. But I will tie Aref to 5 volts in shortly. I alsoalso moved the analog inputs to 2 and 3 just in case there was any damage to A0 and A1.
AEVA National Secretary, WA branch vice-chair

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 19:25

Well it didn't stop discharging when the pot output read 2.5 volts so something is amiss. Will tie Aref to 5 V and see if that helps.
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Sun, 19 Jun 2016, 20:15

If you moved A0 and A1 to A2 and A3 did you also change these in the code?
Did you implement the logging to see the voltage and does this change when altering the pot?

neilg

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 20:18

Updated circuit diagram:
Image

Aref is now tied to the 5 V rail.

Also, I should point out that the discharge relay is only rated to 10 A, so I have it's output driving a larger automotive relay which is good for 15 amps. Said relay is powered by the 12 V power supply feeding the Arduino.

I added the Serial.print lines and it appears to be reading the battery voltage correctly. It just won't turn the discharge relay off when it's supposed to.

Edited to add - yes I did change the Analog inputs in the code.
Edited again - I measured 8.3 mV across the shunt when discharging. The load is about 1 ohm, so that's almost directly comparable to amps.
Last edited by jonescg on Sun, 19 Jun 2016, 10:21, edited 1 time in total.
AEVA National Secretary, WA branch vice-chair

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 20:49

Might have found the problem with the definitions. I had the voltages in milivolts set for a single cell. Perhaps these should have been set for the two cell voltages? That is, Vmax = 8400 and Vmin = 6000. Since made these changes and I'm now able to wind the pot up to the correct voltage without it kicking into discharge mode. Will see what happens now when it reads 8400 mV.
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Sun, 19 Jun 2016, 21:22

Re the voltages - my bad, I had set single cell voltages as you said but forgot about the 2:1 divider, so yes 8400 should work.

Just had a look at my scaling logic and I got it wrong but by changing the voltages it should work.

Glad you are getting there.
neilg

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 21:33

It works! Image

As soon as it hit 8400 it stopped charging and started discharging. However the two relays are on at the same time for about 10 seconds (I think you had set it to 30 seconds, but I think 10 is fine). Right now it's discharging. I will upload a video to show this event Image
AEVA National Secretary, WA branch vice-chair

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 21:52

And it stopped discharging at 6000 mV and started charging again. Winning! Image
Thanks Neil!
Last edited by jonescg on Sun, 19 Jun 2016, 11:53, edited 1 time in total.
AEVA National Secretary, WA branch vice-chair

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Sun, 19 Jun 2016, 22:26

Video link here:
https://www.youtube.com/watch?v=vsNd78qrlvY

Edit - I had some strange cookie related messages, so hopefully this makes it easier to view.
Last edited by jonescg on Thu, 23 Jun 2016, 10:43, edited 1 time in total.
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Sun, 19 Jun 2016, 23:32

Congratulations, now you can hours of fun.

I can't see any reason why both relays are on together.
I'll have to have a think about that one.

neilg

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Mon, 20 Jun 2016, 04:20

I just wonder if we can simplify some of the code so that there's no need for adding dividers to the calculations. So, say I had a 4 cell battery, I could just turn the pot down to a particular spot and change a couple of settings in the code...

All in good time. So far it's charging in 54 minutes and discharging in 34 minutes. I figure the shunt is reading an average of 9 mV (out of a 50 mV maximum, which is apparently good for 50). So that's probably about right. The cells were 5.1 Ah last time I checked.
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Mon, 20 Jun 2016, 05:50

In the readVoltage() function simply change the last line to:
"return temp/4;"
You would then need to adjust the pot so the wiper is at 4.2v (assuming that is what V_MAX is set to) when the battery is at it's max value. You shouldn't need to change V_MIN.

Looks like 20 cycles isn't going to take too long.

neilg

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Tue, 21 Jun 2016, 02:52

Almost done 20 cycles now. I stopped and restarted a couple times so more like 25. Keen to see how the performance has changed.
AEVA National Secretary, WA branch vice-chair

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Tue, 21 Jun 2016, 05:08

Okay so I decided to put my multimeter set to amps in series with the load. This added to the overall resistance of the circuit, so the discharge current was actually a bit less than what it cycles at.

After about 25 cycles, the resulting plot (in pink) looks to have experienced some significant capacity loss!

Image

However take a look at the first part of the discharge - notice how it's dropping a bit faster than the open circles (much earlier in the cell's life). I suspect this is because the cells aren't getting a "full capacity charge". When I plotted the original (open circles) discharge, I balance charged to 4.2 volts for an hour before starting. I suspect this extra time helped push a bit more charge in.

I guess the way to test it would be to repeat as per the original test, but for now, I'm stoked I can charge at 1 C and discharge at 1.5 C without even having to think about it!

AEVA National Secretary, WA branch vice-chair

User avatar
Johny
Senior Member
Posts: 3729
Joined: Mon, 23 Jun 2008, 16:26
Real Name: John Wright
Location: Melbourne
Contact:

Arduino cell cycle tester project

Post by Johny » Tue, 21 Jun 2016, 05:21

I reckon it's cell balance. It'll be interesting to do a proper balance and retest. Nice work Chris.

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Tue, 21 Jun 2016, 22:11

I've watched the discharge via the CellLog8 device on the battery and both cells hit 4.19-4.21 volts before the dishcarge starts. Then one of the cells bombs out at 2.9 volts before the recharge starts. Amazingly, I've never seen more than 50 mV between them. But yes, a good balance charge would help.

However a critical issue with the code is the end of the 20 cycles - the cells are in a discharged state but I came in to check and saw both the discharge and the recharge relays were on! So the cells were at 2.5 and 1.4 volts each as the load tried to drain the 5 amps the charger was putting in!

Perhaps we can set it up to finish on a recharge cycle? And make sure the relays are both off...
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Wed, 22 Jun 2016, 06:17

I have rearranged the code so it finishes with a charge cycle.
You will need to modify the code as shown in blue below
      case STATE_CHARGING:
        cellVolts = readVoltage();      // Do a read
        Serial.print("Charge Voltage = ");        // Logging
        Serial.println(cellVolts);

        if (cellVolts > V_MAX)
        {

          digitalWrite(RECHARGE, OFF);   // Turn charge relay off

          if (numberCycles > NUMBEROFCYCLES)
          {
             currentState = STATE_DONE;     // Next state is done
             digitalWrite(DISCHARGE, OFF); // Ensure discharge relay is off
             Serial.println("Cycles finished"); // Logging
          }
          else
          {
            // Voltage exceeds set threshold
            currentState = STATE_DISWAIT; // Next state is wait before discharge      
       
            delayTimer = RECOVERYTIME;    // Inter state delay time
            Serial.print("Charging Time: (mS) ");   // Logging
            Serial.println(now - cycleTime);
            
            // TODO update display
          }
        }
        if (--stateTimer <= 0)
        {
          // Taken too long
          digitalWrite(RECHARGE, OFF);      // Turn relay off
          Serial.println("CHARGING TAKEN TOO LONG"); // Logging
          currentState = STATE_DONE;        // Next state is done
          
          // TODO update display
      }
        break;

      case STATE_CHGWAIT:
        if (--delayTimer <= 0)
        {
          ++numberCycles;
          currentState = STATE_START;     // Next state is setup to charge
        }
       
        // TODO update display
        break;

The code has always turned both relays off at the end of the test so I don't know why they would be be on.
Anyway see how this goes.
neilg

User avatar
jonescg
Senior Member
Posts: 2679
Joined: Thu, 21 Jan 2010, 23:05
Real Name: Chris Jones
Location: Perth, WA.

Arduino cell cycle tester project

Post by jonescg » Wed, 22 Jun 2016, 06:23

Thanks Neil, I'll give that a go tomorrow. It wouldn't be the end of the world if it stopped after a discharge cycle, but the fact that the relays stayed on didn't help.

I wonder what that is, cause as you say there's commands everywhere to turn them off. Also the cell cycle counter starts at #161 when you reset the board. It counts up to #1620, so the 16 is coming from somewhere...

Thanks again mate, really appreciate it!
AEVA National Secretary, WA branch vice-chair

neilg
Groupie
Posts: 38
Joined: Sat, 07 Apr 2012, 06:24
Real Name: Neil Gibbs
Location: Perth

Arduino cell cycle tester project

Post by neilg » Thu, 23 Jun 2016, 06:32

Re the 2 relays operating together.
Had a look at the tech spec for the Uno and all I can suggest is to try using Digital I/O 3,5,6 or 9 as 10 to 13 are used for SPI (Serial Peripheral Interface) and MAY be affecting the relays. Also 13 has a LED on it but again this shouldn't affect anything.

Don't know about the stray 16.

neilg

Post Reply