  # BDCoDE

Members

22

• #### Last visited

• Rank
Member
1. That was really great explanation, I'm new to electronics, not only Energia. And posts like yours helps a lot. I'm a little bit busy this days, but I will try to use your advices in practice as soon as possible. Thank you!
2. I run the test again with new code and got 1.55Ah. Here is the new output. Voltage= 0.00V Current= 0.00A Capacity= 0.00Ah Discharging time= 1.00s // battery isn't connected yet Voltage= 0.00V Current= 0.00A Capacity= 0.00Ah Discharging time= 2.00s // battery isn't connected yet Voltage= 3.60V Current= 0.28A Capacity= 0.00Ah Discharging time= 3.00s Voltage= 3.64V Current= 0.28A Capacity= 0.00Ah Discharging time= 4.00s Voltage= 3.64V Current= 0.28A Capacity= 0.00Ah Discharging time= 5.00s ...................................................................... ...................................................................... ...................................................................... Voltage= 2.22V Current= 0.17A Capacity= 1.55Ah Discharging time= 21694.00s Voltage= 2.22V Current= 0.17A Capacity= 1.55Ah Discharging time= 21695.00s Voltage= 2.21V Current= 0.17A Capacity= 1.55Ah Discharging time= 21696.00s Voltage= 0.00V Current= 0.00A Capacity= 1.55Ah Discharging time= 21697.00s Voltage= 0.00V Current= 0.00A Capacity= 1.55Ah Discharging time= 21698.00s
3. The output of fully charged Li-ion battery can be up to 4.1/ 4.2 V. Therefor if I use 1k as R2 and 1.5k as R3 I'll get 4.15V * 1.5k /( 1.5k+1k) = 2.49V Almost the same as yours. Can't get the voltage to fit under 2.5V using this rule.
4. Like this? The schematic with voltage divider will then look like this. Are everything ??????? correctly now? // Very simple Arduino Lithium-ion battery capacity tester // from electronicsblog.net #define LED GREEN_LED #define resistor 13 float capacity=0, value,voltage,current, time=0; void measure (void) { analogReference(INTERNAL2V5); delay(1) value= analogRead(A5); voltage=value/1023*5; current = voltage/resistor; capacity=capacity+current/3600; time++; Serial.print("Voltage= "); Serial.print(voltage); Serial.print("V Current= "); Serial.print(current); Serial.print("A Capacity= "); Serial.print(capacity); Serial.print("Ah "); Serial.print("Discharging time= "); Serial.print(time); Serial.print("s "); Serial.print("\n"); } boolean x=false; unsigned long ms; void setup() { pinMode(LED, OUTPUT); Serial.begin(9600); ms = millis()+1000; }; void loop () { digitalWrite(LED, x); x=!x; measure(); while (millis() < ms); ms=millis()+1000; };
5. Thanks for advice, I will try it tomorrow. The test is finished. Here is the last lines of output file. As you can see the voltage is about 3.5V at the lowest, I don't know why but the voltage was constant 5.00V til 16653.00s :!!!: The test showed that battery is 1.87Ah. I think it's true, because the battery sticker says it's 2000mAh, but it's produced in China :grin:. Will run some more tests tomorrow, with voltage divider ;-) Voltage= 3.60V Current= 0.28A Capacity= 1.87Ah Discharging time= 17590.00s Voltage= 3.59V Current= 0.28A Capacity= 1.87Ah Discharging time= 17591.00s Voltage= 3.58V Current= 0.28A Capacity= 1.87Ah Discharging time= 17592.00s Voltage= 3.57V Current= 0.27A Capacity= 1.87Ah Discharging time= 17593.00s Voltage= 3.56V Current= 0.27A Capacity= 1.87Ah Discharging time= 17594.00s Voltage= 3.56V Current= 0.27A Capacity= 1.87Ah Discharging time= 17595.00s Voltage= 3.54V Current= 0.27A Capacity= 1.87Ah Discharging time= 17596.00s Voltage= 3.54V Current= 0.27A Capacity= 1.87Ah Discharging time= 17597.00s Voltage= 3.54V Current= 0.27A Capacity= 1.87Ah Discharging time= 17598.00s Voltage= 3.52V Current= 0.27A Capacity= 1.87Ah Discharging time= 17599.00s Voltage= 3.51V Current= 0.27A Capacity= 1.87Ah Discharging time= 17600.00s Voltage= 0.00V Current= 0.00A Capacity= 1.87Ah Discharging time= 17601.00s Voltage= 0.00V Current= 0.00A Capacity= 1.87Ah Discharging time= 17602.00s Voltage= 0.00V Current= 0.00A Capacity= 1.87Ah Discharging time= 17603.00s
6. How do you think this voltage divider will work?
7. No voltage divider, here is the actual schematic. Besides, I was getting 1.4V when I was using "voltage=value/1024*3.7;" , instead of "voltage=value/1024*5.0" as in your example. Now with "voltage=value/1024*5.0" I get constant 5.00V and 0.38A, but I'm not sure if it's correct. P.S Here is the new output. I used "voltage=value/1024*5.0" Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3220.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3221.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3222.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3223.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3224.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3225.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3226.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3227.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3228.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3229.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3230.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3231.00s Voltage= 5.00V Current= 0.38A Capacity= 0.34Ah Discharging time= 3232.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3233.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3234.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3235.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3236.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3237.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3238.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3239.00s Voltage= 5.00V Current= 0.38A Capacity= 0.35Ah Discharging time= 3240.00s
8. Your code is working well so far. The only thing I edited was resistance , from 6.9 to 13 Here is the output example:Voltage= 1.42V Current= 0.11A Capacity= 0.01Ah Discharging time= 430.00s Voltage= 1.35V Current= 0.10A Capacity= 0.01Ah Discharging time= 431.00s Voltage= 1.42V Current= 0.11A Capacity= 0.01Ah Discharging time= 432.00s Voltage= 1.37V Current= 0.11A Capacity= 0.01Ah Discharging time= 433.00s Voltage= 1.43V Current= 0.11A Capacity= 0.01Ah Discharging time= 434.00s Voltage= 1.37V Current= 0.11A Capacity= 0.01Ah Discharging time= 435.00s Voltage= 1.41V Current= 0.11A Capacity= 0.01Ah Discharging time= 436.00s Voltage= 1.37V Current= 0.11A Capacity= 0.01Ah Discharging time= 437.00s Voltage= 1.42V Current= 0.11A Capacity= 0.01Ah Discharging time= 438.00s Voltage= 1.35V Current= 0.10A Capacity= 0.01Ah Discharging time= 439.00s Voltage= 1.59V Current= 0.12A Capacity= 0.01Ah Discharging time= 440.00s Voltage= 1.42V Current= 0.11A Capacity= 0.01Ah Discharging time= 441.00s Voltage= 1.36V Current= 0.10A Capacity= 0.01Ah Discharging time= 442.00s Voltage= 1.45V Current= 0.11A Capacity= 0.01Ah Discharging time= 443.00s Voltage= 1.36V Current= 0.10A Capacity= 0.01Ah Discharging time= 444.00s Voltage= 1.45V Current= 0.11A Capacity= 0.01Ah Discharging time= 445.00s Voltage= 1.39V Current= 0.11A Capacity= 0.01Ah Discharging time= 446.00s Voltage= 1.76V Current= 0.14A Capacity= 0.01Ah Discharging time= 447.00s Voltage= 1.44V Current= 0.11A Capacity= 0.01Ah Discharging time= 448.00s Voltage= 1.41V Current= 0.11A Capacity= 0.01Ah Discharging time= 449.00s Voltage= 1.33V Current= 0.10A Capacity= 0.01Ah Discharging time= 450.00s I can smell the resistors burning . I think it's strange that Voltage is so unstable. but we will see what will happen the next hour. P.S The real voltage is 3.7 Li-ion battery :grin:
9. Edited: I was lucky and received my usb2uart converter now. It's based on CP2102 chip, if it makes any difference. I installed drivers and Windows shows it on COM11 post. I checked the code below, it's working just fine. But not the "Battery Test" code. I have no idea what to do... static uint8_t sensorPin = A5; int sensorValue = 0; void setup() { Serial.begin(9600); } void loop() { sensorValue = analogRead(sensorPin); Serial.println(sensorValue); delay(100); } Checked as well on my another code. This one works fine too. #define cmdL 'L' //UART command #define cmdR 'R' //UART command char incomingByte; // income data char command; void setup() { Serial.begin(9600); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); if(incomingByte == cmdL) { Serial.println("You typed L"); } else if(incomingByte == cmdR) { Serial.println("You typed R"); } else if(incomingByte > '0'){ Serial.println("Wrong command. Please try again"); }// ????? ?????? } delay(100); }
10. Let me just ask you a stupid question because I'm REALLY new to all this stuff. How should I receive Serial.print()? Via usual USB cable I use to program the chip using terminal program or via USB2UART converter usin RxD & TxD pins? P.S I'm using M430G2553 chip
11. I don't know why, but there is still nothing :shock: P.S Updated source...
12. I tried with now, still no effect. P.S Updated source code in my previous message.
13. Ok, didn't noticed that part of you message. The code looks like this now: // Very simple Arduino Lithium-ion battery capacity tester // from electronicsblog.net static uint8_t sensorPin = A5; #define LED GREEN_LED #define resistor 13 float capacity=0, value,voltage,current, time=0; void measure (void) { value= analogRead(sensorPin); voltage=value/1024*5.0; current = voltage/resistor; capacity=capacity+current/3600; time++; Serial.print("Voltage= "); Serial.print(voltage); Serial.print("V Current= "); Serial.print(current); Serial.print("A Capacity= "); Serial.print(capacity); Serial.print("Ah "); Serial.print("Discharging time= "); Serial.print(time); Serial.print("s "); Serial.print("\n"); } boolean x=false; #pragma vector=TIMER0_A0_VECTOR __interrupt void TIMER1_OVF_vect(void) { x=!x; digitalWrite(LED, x); if(x) { measure(); } } void setup() { pinMode(LED, OUTPUT); TACTL = ID_3 + MC_1 + TASSEL_2 + TACLR; // Set timer to up mode on SMCLK/8 (125kiHz) TACCTL0 = CCIE; // Enable timer interrupt TACCR0 = 62500 - 1; // set overflow value to remove time error (16bit counter register) _BIS_SR(GIE); // enabled global interrupt; Serial.begin(9600); }; void loop () { LPM3; }; The GREEN_LED is now always ON, but still nothing in Terminal output. Here is the new picture of schematic. There you can see how all jumpers are connected.
14. Sorry, my fault. I was actually trying with both of them. The problem was in Serial.print(). I used Serial.println() instead. Here is the working source. static uint8_t sensorPin = A5; int sensorValue = 0; void setup() { Serial.begin(9600); } void loop() { sensorValue = analogRead(sensorPin); Serial.println(sensorValue); delay(1000); } But I still can't get this battery test working. Here is the code you gave me, is there anything wrong with it? // Very simple Arduino Lithium-ion battery capacity tester // from electronicsblog.net static uint8_t sensorPin = A5; #define LED GREEN_LED #define resistor 13 float capacity=0, value,voltage,current, time=0; void measure (void) { value= analogRead(sensorPin); voltage=value/1024*5.0; current = voltage/resistor; capacity=capacity+current/3600; time++; Serial.print("Voltage= "); Serial.print(voltage); Serial.print("V Current= "); Serial.print(current); Serial.print("A Capacity= "); Serial.print(capacity); Serial.print("Ah "); Serial.print("Discharging time= "); Serial.print(time); Serial.print("s "); Serial.print("\n"); } boolean x=false; #pragma vector=TIMER0_A0_VECTOR __interrupt void TIMER1_OVF_vect(void) { x=!x; digitalWrite(LED, x); if(x) { measure(); } } void setup() { pinMode(LED, OUTPUT); // I don't know the ATmega timers, but I will be assuming your timer clock is running at 1MHz and interrupts every 0x10000-0x0BDC = 62500 microseconds (every 62.5 milliseconds) _BIS_SR(GIE); // enabled global interrupt; TACTL = TAIE; // enabled timer overflow interrupt; TACTL |= MC_1; // normal operation page 366 (mode up); TACCR0 = 62500 - 1; // set overflow value to remove time error (16bit counter register) TACTL |= TASSEL_2 + TACLR; // start timer/ reset clock Serial.begin(96000); }; void loop () { LPM3; };
15. I do use Serial.begin(9600) P.S I read this thread and decided to check if it's working on mine board. I connected P1.5 pin to GND and used this code. Still can't receive anything in Serial Monitor. I tried both M430G2553 & M430G2452. What's the problem :x static uint8_t sensorPin = A5; int sensorValue = 0; void setup() { Serial.begin(9600); } void loop() { sensorValue = analogRead(sensorPin); Serial.print(sensorValue); delay(10); }
×
• Blog

• #### Activity

×
• Create New...