Inexpensive DIY EV Monitoring System (Arduino based)
Not too long ago I decided to attempt to learn digital electronics. It is something that has always intrigued me, but something that has always been over my head. Circuits and wiring? Easy. Computer code? Not so much.
Long story short, I ended up getting a couple of Arduino boards and started playing around. Armed with a helpful tutorial in C here: HowStuffWorks "The Basics of C Programming" I started to get the hang of it. The reality is, there really is no end to what an Arduino board is capable of. My $14 Chinese Arduino Nano copy has 8 analog inputs and 13 digital I/0s. All that is required is the brain power to program it to make it do what you want. So I am now testing my code on a better battery monitoring system for the Electric Booger. Since it is 72V, all I need is 6 voltage monitoring inputs, one input from the amp sensor and maybe a temp sensor on the motor. I have successfully make an Ah counter program that works very well. Here it is running with a simulated volt and amp input: http://i1119.photobucket.com/albums/...pstah563ys.jpg It even works for charging, when current is reversed: http://i1119.photobucket.com/albums/...pslcofxteu.jpg Here is the code so far: Quote:
1) charge_correct: counts reverse amps at an 80% rate to account for battery charging inefficiency 2) fuel_tank: size of available Ah to begin with. |
Very cool! I'm glad someone else is trying this out.
I am curious how you plan on monitoring voltage and current. I would imagine you're going to tap into your ammeter's shunt? I used one of the Haas current sensors that Paul's open revolt uses in my BMS, but it wasn't as accurate as I'd like it to be. What is the plan for the voltage monitoring? |
My car doesn't actually have an ammeter. I know, I know. Lame. I have used a remote one on my multimeter in the past, so I have a pretty good idea of current vs voltage sag, so I just never bothered. But with an Ah counter, it will be essential.
I still have the hall effect amp transducer that I used to use when I was running a separate field controller with my former sepex motor. It is a 0-400A amp sensor (600A peak) - 0-5V analog output. 2.5V is 0 amps. Output goes up for one current direction and down in reverse direction. It is quite accurate, as far as I can tell. This one: http://www.farnell.com/datasheets/30908.pdf Volts is easy. Arduino GND to the most negative battery pack post. Then each positive post signal goes through a 10K/500 voltage splitter (so 100V = 5V) to Arduino A0-A5. |
Cool, your current sensor is quite similar to the one I was using. Just make sure to test it with a known load so you know you're getting accurate readings over time. Like I said, I had issues. I'm not an electronics guru. I do know a little programming so dealing with stuff like noise on lines is not easy for me.
I'd be interested to see how you plan on wiring / program the voltage monitoring to the arduino. Because your batteries are in series, each divider will add to the voltage of the previous batteries unless you have some way of getting around that. I assume you'll just have to compensate for the different voltage ranges in your code? |
cool, just fyi 10 bit adc @ 100v will give you about 0.1v resolution at the top of the pack, then you have to subtract out the lower voltage readings to get the individual voltage which create rounding errors on the "higher up" batteries, with 6 batteries it won't be a big deal though.
Also, you can use createChars to make 6 mini bargraphs (speaking of rounding errors :) ) on the display, one for each battery, from zero pixels to 8 pixels high (blank and full are already existing characters probably, maybe even 1 pixel high already exists), or expand them to 4 lines high. Lucky you have 8 ADC and 6 batteries! :) |
Yup, I was about to write that. 10 bits = 0-1023 output = about 0.1V resolution @ 100V, which is fine for me. If I had a lithium pack I would use multiple boards to get the resolution higher. 25+ separate measurements would require that anyway.
So bank2 reading - bank 1reading = bank 2 voltage, and so on. Also, the Vref pin is only ever used if you want to read an analog signal of less than 0-5V using all 10 bits of ADC. For example, if you wanted to measure a 0-2V signal with 1023 steps of measurement, you would feed a 2V signal to Vref and write the code accordingly. Normally, the ADC compares each analog input to +5, but the measured voltage potential needs GND to make the circuit. So I will hook GND up to the lowest pack potential as the zero ref. Schematics to come. |
you do have to watch out for overflow conditions. millis() overflows in 49 days, some of your "accumulators" might run out of room well before then too. Floating point is convenient, but the raw adc data is bits and might be more accurately accumulated in a double, or a int64_t if you have room. Adding 1024 to itself, 5 times per second will overflow a int32 in 4 days. Dunno if it matters though, depends how accurate it needs to be.
|
I got around that by resetting the counters once the charger hit full charge.
|
I will have a reset button for when it is fully charged. The negative current measuring and resulting "battery capacity regeneration" on the fuel gauge is more for if I want to graze charge while doing errands, charging a bit here and there while [hopefully] keeping my fuel gauge somewhat accurate. It will be interesting to see what sort of charge correction factor I will end up needing to give it some accuracy. I guess it will largely depend on how deeply discharged the pack is while charging - charging at the deep end is far more efficient than at the top end.
|
Now on to the charger monitoring side. I paid a solid $14 for this Arduino and plan to get all my money's worth!
Currently (PUN!), I have six 12V chargers. They put out 10A up to 14.7V and then hold 14.7V until the current drops down enough to switch to a 13.8V float. Too see what's going on remotely, I go look at my Kill A Watt, which I have learned to interpret pretty well. But this involves going down to the garage. I know, I know, first world problem, but wouldn't it be nicer to simply look out the window and see an LED status light flashing in the car? Yes, yes it would. I always look at the Kill A Watt at the beginning and end of a charge to make sure all chargers were working because I had a near fatal (from a battery's perspective) incident where a fuse popped in one charger without me noticing. I haven't gotten there yet, but my future code will watch for differences in voltages between banks and flag a warning LED and message (or text me if I buy a GSM Arduino shield?) if something is out of whack. Anyway, here is a circuit simulation: http://www.youtube.com/watch?v=ip3TT-6Zu1A And here is the code for this part. Many things will cross over from the battery fuel gauge code, as they will share the same inputs and logic. EDIT: I played around with it more and found that if the charger was turned off with the switch before it was finished, it would assume that it was on float and would start the float timer, permanently cutting off the charger relay (ch_enable pin) unless the arduino was reset. This, combined with possible reliability issues, has led me to use a SPDT switch - OFF, charge and charge with float timer, requiring two pins. I have changed the code below to reflect this. Quote:
|
All times are GMT -4. The time now is 09:42 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com