Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino as Volt Meter
#11
(02-11-2019, 10:11 AM)Redpacket Wrote:
(02-11-2019, 07:22 AM)Geek Wrote: This is crazy 'accurate' thanks guys. Is there an easy way to get a proper reference voltage? I have seen setups on Ali for sale. But this is so consistent I'd like to go the next level.


Could you advise the setup you had for that?
ie, what supply voltage, which reference used, what voltage divider resistors, etc?

I'd suggest using the 1.1V internal ref, calibrate it once, save that cal value, then log some values.

Also beware of supply noise, so have eg a 10uF capacitor across it.

I am using the USB on my PC. The voltage drop is caused by the schottky diode on the USB input. Interesting idea with the cap. I am going to try this with a battery.

Here is some code that will work for all Atmega Arduino. The remark on the top of readVcc gives a slightly better description of what is going on.

Code:
long readVcc() {
 // Read 1.1V reference against AVcc
 // set the reference to Vcc and the measurement to the internal 1.1V reference
 #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
   ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
 #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
    ADMUX = _BV(MUX5) | _BV(MUX0) ;
 #else
   ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
 #endif  

 delay(2); // Wait for Vref to settle
 ADCSRA |= _BV(ADSC); // Start conversion
 while (bit_is_set(ADCSRA,ADSC)); // measuring

 uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
 uint8_t high = ADCH; // unlocks both

 long result = (high<<8) | low;

 result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
 return result; // Vcc in millivolts
}
Korishan likes this post
Reply
#12
With that readVCC example, you should really do that quite often throughout testing. Perhaps when detecting there's a load on the probes. Power can fluctuate, even on batteries.
Also, after running readVCC, on most of the atmegas, there needs to be a pause before resetting it back and reading the pins. Well, that is, if you use the A0 pin (i think that's the one) for your probes. Otherwise, the ADC might not be ready yet switching the mode on that pin.

I did have that issue on my nano. waiting about 20ms or so is usually long enough, tho.

Also, that code only works with the atmel's. I haven't seen any that work with the esp or the stm mcu's yet. Not that it's not out there, just that I haven't found it yet
Proceed with caution. Knowledge is Power! Literally! Cool 
Knowledge is Power; Absolute Knowledge is Absolutely Shocking!
Certified 18650 Cell Reclamation Technician

Please come join in general chit-chat and randomness at Discord Chat (channels: general, 3d-printing, linux&coding, 18650, humor, ...)
(this chat is not directly affiliated with SecondLifeStorage; VALID email req'd)

Kickstarter: Honest STM32F103 based dev Boards
Patreon: Korishan
Reply
#13
(02-12-2019, 12:59 AM)Korishan Wrote: With that readVCC example, you should really do that quite often throughout testing. Perhaps when detecting there's a load on the probes. Power can fluctuate, even on batteries.
Also, after running readVCC, on most of the atmegas, there needs to be a pause before resetting it back and reading the pins. Well, that is, if you use the A0 pin (i think that's the one) for your probes. Otherwise, the ADC might not be ready yet switching the mode on that pin.

I did have that issue on my nano. waiting about 20ms or so is usually long enough, tho.

Also, that code only works with the atmel's. I haven't seen any that work with the esp or the stm mcu's yet. Not that it's not out there, just that I haven't found it yet

Agreed. In the chart I posted before there was a 500ms delay, and a 1500ms delay after printing the result. Apparently you can also get inaccurate results if the device is not properly grounded. This is one reason why I want to try the same thing from a battery. Will be interesting to see what happens.
Korishan likes this post
Reply
#14
I should probably be posting this on another forum. However, it is my mission to create the most simple BMS possible, with the most functions feasible. I should be asking the same questions on AVRFreaks, or Arduno forums. There are so many knowledgeable people on this forum. My theory is, if you guys can help me create this, then anyone can build it.

I have reasonable electronics skills. Limited soldering skills. The goal is to make something as simple as possible as an Arduino based BMS. Just a few simple signals, mostly composed of software, and as few components as possible.

I need some advice in laymans terms (how to decouple VCC). I personally desperately need a decent oscilloscope . At the moment I am trying to investigate the shortcomings of an unearthed Atmega chip.

As this project continues, as much advice as I can get is received with gratitude.
Reply
#15
(02-12-2019, 06:49 AM)Geek Wrote: I should probably be posting this on another forum. However, it is my mission to create the most simple BMS possible, with the most functions feasible. I should be asking the same questions on AVRFreaks, or Arduno forums. There are so many knowledgeable people on this forum. My theory is, if you guys can help me create this, then anyone can build it.

I have reasonable electronics skills. Limited soldering skills. The goal is to make something as simple as possible as an Arduino based BMS. Just a few simple signals, mostly composed of software, and as few components as possible.

I need some advice in laymans terms (how to decouple VCC). I personally desperately need a decent oscilloscope . At the moment I am trying to investigate the shortcomings of an unearthed Atmega chip.

As this project continues, as much advice as I can get is received with gratitude.
Chuckle, you can see my babbling about something like that in the general section, i mean an active balancer, not a BMS. Basically, it could be combined...

I have a concept (for a Balancer, but had just not enough time to make even the most simple tests. 

If you want to have a cheap "oszilloscope" with basic functions google DSO 138. Take it with case, not without.
It is simple but effective, compared to having no one.
0,8kWp in Test
4 kWh battery target
Ultra low cost
Reply
#16
(02-13-2019, 10:39 PM)Cherry67 Wrote:
(02-12-2019, 06:49 AM)Geek Wrote: I should probably be posting this on another forum. However, it is my mission to create the most simple BMS possible, with the most functions feasible. I should be asking the same questions on AVRFreaks, or Arduno forums. There are so many knowledgeable people on this forum. My theory is, if you guys can help me create this, then anyone can build it.

I have reasonable electronics skills. Limited soldering skills. The goal is to make something as simple as possible as an Arduino based BMS. Just a few simple signals, mostly composed of software, and as few components as possible.

I need some advice in laymans terms (how to decouple VCC). I personally desperately need a decent oscilloscope . At the moment I am trying to investigate the shortcomings of an unearthed Atmega chip.

As this project continues, as much advice as I can get is received with gratitude.
Chuckle, you can see my babbling about something like that in the general section, i mean an active balancer, not a BMS. Basically, it could be combined...  

I have a concept (for a Balancer, but had just not enough time to make even the most simple tests. 

If you want to have a cheap "oszilloscope" with basic functions google DSO 138. Take it with case, not without.
It is simple but effective, compared to having no one.

Got a link?

The concept I have in mind is a self powered active balancing device. So each Arduino is powered from a string of cells. Each has a FET and a load. Start burning power at 4.15v. For emergency shutdown such as under or over voltage  use optocoupled relays to drive shunt trips or SSRs to shut the system down.

The parts would mostly be available as pre fabricated units and pretty much plug and play.

The system would be so simple and require so very few components. I understand that it would consume too much power for a small pack. But if you want a BMS for a small pack - get one of those el-cheapo units from AliExpress.

I plan to fit each one with a 'black box' capability. So it can be connected to a PC and a sketch uploaded to dump the eeprom - and retrieve a log if necessary.

The only problem I am having - I need to be certain that the voltage readings will be consistent. Even leaving a little margin for error - you still don't want your system just shutting down unexpectedly, or not shutting down in an emergency.

Also, if I was to share such a design, I would want it to be 'foolproof'. If its intended users would have little knowledge of such a system - I need to be sure that however it gets set up - it absorbs a lot of room for error.
Reply
#17
Do you mean a link for the DSO 138 ?

https://www.google.com/search?q=DSO138

I think only about 1 arduino, if any at all.... a basic unit works without, but is missing some conveniences.
I do not think about loading higher cells, i talk about feeding lower ones. ACTIVE Balancing.
0,8kWp in Test
4 kWh battery target
Ultra low cost
Reply
#18
(02-14-2019, 02:44 PM)Cherry67 Wrote: Do you mean a link for the DSO 138 ?

https://www.google.com/search?q=DSO138

I think only about 1 arduino, if any at all.... a basic unit works without, but is missing some conveniences.
I do not think about loading higher cells, i talk about feeding lower ones. ACTIVE Balancing.

No for your balancing threads -

https://secondlifestorage.com/t-Balancin...lar-system

https://secondlifestorage.com/t-Alternat...ular-Banks

That DSO does look interesting though.
Reply
#19
(02-15-2019, 03:19 AM)Geek Wrote:
(02-14-2019, 02:44 PM)Cherry67 Wrote: Do you mean a link for the DSO 138 ?

https://www.google.com/search?q=DSO138

I think only about 1 arduino, if any at all.... a basic unit works without, but is missing some conveniences.
I do not think about loading higher cells, i talk about feeding lower ones. ACTIVE Balancing.

No for your balancing threads -

https://secondlifestorage.com/t-Balancin...lar-system

https://secondlifestorage.com/t-Alternat...ular-Banks

That DSO does look interesting though.
At that time ( of the links you found) i didnt thik about the balancing i have in my nose now. 

Yet, daromer hast destroyed (by PM) my rosy clouds, looks like it is already well known what i thought i had figured out.

The DSO is imited to 1 Mhz sampling rate and only one channel, but for all what is within this limitations its quite nice. At least better than nothing, especially when you think about switched supplies and so on....
0,8kWp in Test
4 kWh battery target
Ultra low cost
Reply


Who read this thread?
64 User(s) read this thread:
daromer, Sean, Joaquinsfy, owitte, Korishan, PAF, jdeadman, wim, watts-on, Stefaan De Ridder, BlueSwordM, Geek, Bloater, ChrisD5710, Nikhil Mahajan, spyroslo, karmi27, Ste Collister, Charly144, brwainer, drchips, Roland Domke, Redpacket, Ibiza, davidtrn24, Bubba, Cherry67, Riplash, mishok, Rasmus Godske, michaell, tig77, chuckp, emuland-metroman, hazSolar, Beholder, Christiaan Plug, Leipi35, Jaster, Wolf, Cesar_Tee, camthecam, Dallski, rettore, PaulDane, richie241, kevinjaye, holdman_2004, mart1nn, LEDSchlucker, zoookii, ibp, 1Lukas1, Gremlin, Richard, Overmind, Church1182, Edster, Lucan, Leafnut, wreckless, ganushak, MonkeyThink, tmodx

Forum Jump:


Users browsing this thread: 1 Guest(s)