Beginners Guide to Processing 18650 Cells | Cell Database

Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
All new design with intelligent control
Keep the work up m8 Smile
The Ultimate DIY Solar and build place
YouTube / Forum system setup / My webpage  Diy Tech & Repairs

Current: 10kW Mpp Hybrid | 4kW PIP4048 | 2x PCM60x | 83kWh LiFePo4 | 10kWh 14s 18650 |  66*260W Poly
Upcoming: 14S 18650~30kWh | Automatic trip breakers, and alot more

I have two more difficult versions of the code running and it works fine ( I got help from the good people over at EEV Blog) but I am having a hard time with the "simple code." Daromer, I thought you were good at this stuff, why is it you refuse to help with this project?
I have not refused to help. When did I say that?

I would love to help in most of the projects but honestly I hardly got time to do my own Smile If i get more time to spare further onward I will lend a hand as well.
The Ultimate DIY Solar and build place
YouTube / Forum system setup / My webpage  Diy Tech & Repairs

Current: 10kW Mpp Hybrid | 4kW PIP4048 | 2x PCM60x | 83kWh LiFePo4 | 10kWh 14s 18650 |  66*260W Poly
Upcoming: 14S 18650~30kWh | Automatic trip breakers, and alot more
(08-03-2017, 06:33 AM)Inverted 18650 Wrote: Hey All,

I received a new order so I have been testing cells for hours on end and replying in other posts but haven't made an videos yet. The good news is I did film a bunch of footage just have to edit and upload it. I did have a couple issues with the Arduino program because I kinda suck at it so expect more analog additions..until I learn more C/C++. If there are some coding wizs here that would like to help me out, id be stoked...having a bit of trouble with the 'while boolean' to turn off fets & counter but still save the mAh reading..trying to keep it simple only makes it

Post the code. Point out the 'simple while boolean' parts that are a problem. Would like to help.
Runs with low voltage
Will do.. it's all crazy right now..I have been trying to learn a little about "state machines" in the last few hours and that may be the solution... once I get back to the laptop I'll screenshot the "simple" one that I am having a hell of a time short, I can't get the mosfet to turn off and stay off with the goes back into the loop and the batt voltage bounce s back up and the cycle restarts...the pin thats analogWrite (PWM), won't stay off after the digitalWrite, LOW whenever batt voltage goes below 3.0V.
this is not the orignal "simple" sketch, its lost int he mix of the 20 other tries on the laptop dashboard. but this is what i am trying to do. keep the coding very simple, if possible, and dont add anything else to the board, so we can measure 6 cells at once. I have a few differnt sketches that work fine but this "simple" one is kicking my ass.
Thanks for all the help..if youmeasure the voltage over the load resistr here it should be exactly a 1V drop, hence 1Amp over the 1 ohm resistor. Again this is not my original but ill find it and get it up too. I can add external compenonets, but that takes up PIN space, and I can add analog sensing but some people arent good with that stuff.

Thank to everyone that plays with this and helps, once it all working you be stoked to have a badass little SIX cell tester that works well and is easy to make.

# define off_voltage 3.00//stops test when cell gets down to 3.0V
# define VRef 4.72//measured voltage at "REF" pin, adjust this to match your board
const int Mosfet_Enable = 3;//turns mosfet on and off
const int Batt_1_Voltage = A7;//voltage sensor
bool Discharge_1;// is test running
float measuredVoltage_1;//stores raw volts
unsigned long mAh;//stores final mAh

void setup(){
  Serial.begin(9600);//start monitor
  pinMode(Mosfet_Enable, OUTPUT);// PIN D3 is now an OUTPUT
  digitalWrite(Mosfet_Enable, LOW);//starts in the off position
  pinMode(Batt_1_Voltage, INPUT);//can read V
void loop(){
measuredVoltage_1=(analogRead(Batt_1_Voltage) * (VRef/1023));//convert raw to analog V
 if (analogRead(Batt_1_Voltage > off_voltage)){  //if the battery voltage is above 3.0V, start test
    analogWrite(Mosfet_Enable, 180); //send PWM signal and applies ~3.5V to mosfet gate to allow 1V to flow from Drain to Source
    Discharge_1 = true;  //yep, were testing a cell now
    mAh = (millis()/3600000);/* need more HELP with this for sure!! i see others use previousMillis- currentMillis. Its a constant 1Amp load so 1000ma shoud flow every h, hence mAh.
     need the counter to stop counting once the test is done AND store the final counted mAh. remember we cant measure the current an waste an input pin( we can but dont want to).
    instead, if you measure 1V flowing over the resistor, you know you have 1A being pulled from the cell, or you can break the cicruit and measure amps in series on fet pin 2.*/
 else if (measuredVoltage_1 < off_voltage){
   digitalWrite(Mosfet_Enable, LOW);
   Discharge_1 = false;
   pinMode(Mosfet_Enable, INPUT); /* this worked and turned everything off for a while, now I get an upload error- it Must be turned totally off becasue when discharging
  stops, the measured cell voltage will rise back up once the cell is no longer under load, and then the loop starts FET again..battery pulses up and down and never stops.*/
Serial.print("V1 = ");   // label for 'cell 1'
Serial.print(measuredVoltage_1); // prints 'cell 1' voltage to monitor
Serial.print("\t");//prints blank space
Serial.print("mAh1 = ");// capcity cell 1
Serial.print(mAh); //total capacity
Serial.print("\t");//prints space
Serial.println();// makes the data on monitor form a nice neat line
I haven't studied your code too closely to figure exactly what it's trying to do, but I did see a couple of possible issues:

I think the line
 if (analogRead(Batt_1_Voltage > off_voltage)){  //if the battery voltage is above 3.0V, start test
Should be
 if (measuredVoltage_1 > off_voltage)){  //if the battery voltage is above 3.0V, start test

Also, maybe it is intentional, but you have not catered for the condition where measuredVoltage_1 is exactly equal to off_voltage.
i.e. use >= in one condition or <= in the other.
Ohhhh, I see your problem! You left out a semicolon Tongue
Inverted 18650 likes this post
Proceed with caution. Knowledge is Power! Literally! Cool 
Knowledge is Power; Absolute Knowledge is Absolutely Shocking!
Dollar Shave Club. Best Razor I've ever used
Certified 18650 Cell Reclamation Technician

You're right, good catch, but still need to solve the bigger problems. If you read the notes beside each line, I tell you where the main problems are...I think I have a fix, but it involves ending the simplicity..

You can use the sketch as is and just time the cells and watch the serial monitor, when the voltage hits 3.0V, just write down the mah ( because the counter will keep going up even after you take the cell out) & remove the cell..once all cells are done, and your ready for the next batch, push reset.

But using it like that sucks...I got some tips from the EEV Blog page too and I'm trying to sort it out, hopefully resolve it today.
If you're trying to get the code to stop once it drops below 3V I would suggest something like the following:

Initialise Discharge_1 to true at startup:
 bool Discharge_1;// is test running
 bool Discharge_1 = true;// is test running

then change the line I mentioned in the previous post to:
   if ( ( measuredVoltage_1 > off_voltage && Discharge_1 == true )  //if the battery voltage is above 3.0V, start or continue the test

Also, move the Serial.print stuff into the above condition block so it stops printing when complete.

Also you asked about more help with the millis() thing.  Note that this example will only work (or to be more precise, will only correctly calculate mAh) immediately after a power up or reset, because you are calling millis() which is the number of milliseconds since the processor started running.  So if you wanted to, say, wait until the user pressed a button before starting, you will need to note the millis() at the start of the event and then deduct it from the current millis() during execution.

And finally, the line:

    pinMode(Mosfet_Enable, INPUT); /* this worked and turned everything off for a while, now I get an upload error- it Must be turned totally off becasue when discharging
looks a bit suspicious to me.  Unless you have a pull-up or pull-down resistor on that mosfet signal, then setting that pin back to an input will leave the signal to the mosfet floating and therefore in a unknown state.
I would have expected:
digitalWrite(Mosfet_Enable, LOW);
to have worked just fine.
Inverted 18650 likes this post

Who read this thread?
94 User(s) read this thread:
hbpowerwall (08-30-2017, 11:21 PM), AZ_Tekkie (07-30-2017, 02:33 AM), daromer (08-23-2017, 07:17 PM), FiremanDIYPowerwall (08-06-2017, 06:39 AM), mike (08-12-2017, 01:44 AM), goodnowm (10-24-2017, 06:32 AM), PaulKennett (08-04-2017, 10:53 AM), Joaquinsfy (08-23-2017, 05:55 AM), owitte (11-24-2017, 09:51 PM), opus40 (08-05-2017, 02:18 AM), Grazor (12-06-2017, 04:51 PM), Majorphill (07-14-2017, 04:43 AM), anishkgt (09-08-2017, 10:57 AM), ruby2 (08-27-2017, 01:42 AM), Korishan (08-26-2017, 11:12 AM), A + A (08-26-2017, 03:36 PM), FERCSA (08-23-2017, 10:26 PM), Batrium (07-31-2017, 03:42 AM), Wattsup (07-14-2017, 11:52 AM), Scepterr (08-16-2017, 10:06 AM), BobinTN (09-07-2017, 05:34 PM), egam (08-04-2017, 04:39 PM), Alec_J (08-20-2017, 10:42 PM), jdeadman (08-27-2017, 02:28 AM), monsted (10-05-2017, 02:09 PM), crud (07-23-2017, 08:11 PM), 2146 (07-20-2017, 09:53 PM), wim (08-26-2017, 11:58 AM), frnandu (08-26-2017, 11:23 AM), typ49 (08-21-2017, 08:06 AM), Jeremy Choy (08-23-2017, 08:04 PM), 1958 greyhound (09-24-2017, 11:43 AM), kktuo (07-22-2017, 11:36 AM), rebelrider.mike (08-21-2017, 05:02 AM), watts-on (08-26-2017, 11:27 AM), Dan Lim (08-09-2017, 10:10 AM), jesusangel (08-26-2017, 08:42 AM), BamBamsBatteries (08-13-2017, 03:11 AM), Daggerzz (08-23-2017, 10:55 PM), Hanssing (08-26-2017, 07:54 PM), MetalFang (08-03-2017, 08:43 PM), kot (07-17-2017, 06:08 PM), Joost2 (08-22-2017, 05:14 PM), ismaildoganw (08-19-2017, 09:52 AM), kazbach (08-15-2017, 06:40 PM), Stefaan De Ridder (08-20-2017, 11:39 AM), GBPhoto (09-30-2017, 05:25 PM), TomTinkerDIY (07-26-2017, 10:48 PM), Chiptosser (08-13-2017, 02:00 AM), Power Up (07-18-2017, 02:54 PM), systemtm (08-05-2017, 04:49 AM), Inverted 18650 (09-08-2017, 02:28 PM), BlueSwordM (08-07-2017, 02:57 PM), Happy Camper Homesteader (07-13-2017, 02:51 PM), brafi (08-08-2017, 03:52 PM), Stew Mohr (08-07-2017, 10:47 AM), John.Siler (07-20-2017, 07:44 PM), Xander52 (07-18-2017, 01:57 PM), fr333n3rgy (07-18-2017, 02:52 PM), Terry (08-04-2017, 03:08 PM), Eric Koshinsky (08-19-2017, 10:37 AM), colishere (08-24-2017, 05:36 AM), benjaminjohnsonquinones (07-30-2017, 07:22 AM), Robert Crawley (08-11-2017, 07:53 AM), KtB (08-26-2017, 02:21 PM), Pyro (08-08-2017, 10:35 PM), mayson14 (08-10-2017, 04:42 AM), Travis Watson (08-07-2017, 03:13 PM), Seedser (08-09-2017, 10:10 PM), iceisfun (08-28-2017, 05:03 AM), Geek (08-29-2017, 05:55 AM), Morgan Jones (08-19-2017, 03:14 AM), Jon (08-24-2017, 07:08 AM), Bloater (10-08-2017, 01:50 PM), floydR (10-30-2017, 01:24 AM), jrobida (09-06-2017, 04:12 AM), Gerard Achternaam (09-18-2017, 11:51 AM), David Parkes (09-14-2017, 05:12 PM), nautal (09-19-2017, 12:05 AM), SemaJG (09-15-2017, 10:57 AM), Sa_2307 (10-15-2017, 06:35 PM), ap103 (10-16-2017, 05:14 PM), howiegrapek (10-05-2017, 05:18 PM), Lazyman342 (09-27-2017, 03:07 AM), Chris Crum (10-04-2017, 03:23 AM), Jason.T.Keenan (10-18-2017, 05:20 AM), revolting (10-30-2017, 05:02 PM), Dave Adams (12-25-2017, 08:47 PM), vlmendezjr (11-19-2017, 07:26 PM), modido (11-05-2017, 01:13 PM), Brent Brown (11-20-2017, 06:34 PM), cosmic (01-21-2018, 05:36 AM), drchips (01-13-2018, 06:36 PM), Broncosis (01-06-2018, 07:56 AM)

Forum Jump:

Users browsing this thread: 1 Guest(s)