How to digitally measure avg current drawn by gopher?

Thread Starter

Poor old sod

Joined Jul 25, 2017
110
24V up to 55A drain, not known if instantaneous drain constant. 75mV==50A at shunt. Refresh rate for display is 500mS. PWM frequency unknown, sample duration unknown. Need to smooth samples for steady readout? Currently variant readout every cycle on const. load. Is it as simple as a large capacitor across the shunt to persist the current a bit more? BTW I do not know if 100% duty cycle ever reached-prob not as problem exists on full speed. Hopefully it won't upset my speed control too much. readout along flat varies from 1.2 to 9.8A in a cyclic manner of numbers, the extremes being rare-up to 10-15 sec per cycle of them. The highest readout is prob correct, just have to catch it more often. Capacitor across shunt will have to take at least reverse 2V to allow for electronic braking effect. No rev current occurs. Cannot use diode protection as fwd threshold too low. Advice please.
 

Alec_t

Joined Sep 17, 2013
11,665
You're saying the shunt drops 75mA at 50A, but -2V during braking? That implies a braking current of 1466A. Seems very high.
 

Thread Starter

Poor old sod

Joined Jul 25, 2017
110
Just a wild guestimation to make sure sufficient back emf was allowed for, 75mV @ 50A! normally, on 30% overspeed downhill there is zero current thru the shunt, but the back emf is still applied. Hey, no current ==no volt drop across meter shunt so pls disregard unless PD affects something important. I conceed an RC network may be needed across shunt [rev current cct broken by power transistors in pwm supply] , but a suitable T escapes me.
 
Last edited:

Thread Starter

Poor old sod

Joined Jul 25, 2017
110
current is trying to go in reverse through a transistor==not possible unless triac or similar, and it ain't. the back emf is in reverse polarity to the normal motor current, and regenerative charging does not occur. Thus when going downhill the battery current reduces to zero, but is never -ve. This particular detail is irrelevant to my primary question, how do I get a better quality readout with consistent figures?
 

ebeowulf17

Joined Aug 12, 2014
3,274
current is trying to go in reverse through a transistor==not possible unless triac or similar, and it ain't. the back emf is in reverse polarity to the normal motor current, and regenerative charging does not occur. Thus when going downhill the battery current reduces to zero, but is never -ve. This particular detail is irrelevant to my primary question, how do I get a better quality readout with consistent figures?
Can you share a schematic of what you've got so far? Where are you sampling and with what equipment? Are you feeling voltage from top of shunt straight into an ADC? Are you using an op amp to amplify low signal before feeding ADC? What is your sampling rate? Could you simply take lots of samples and average them?

Also, what are you signal requirements? How quickly does your measured value need to respond? Are you wanting accurate response within small fractions of a second, or looking more at long term average values?

Way too many variables here to have a simple answer straight off. I'm guessing my thought will end up being one extra resistor and one cap, but that depends on the answers to many of the questions above.
 

Alec_t

Joined Sep 17, 2013
11,665
Over what period do you want to know the average? If it's longer than, say, around 30 sec then a digital solution may be preferable over an analogue one.
 

LesJones

Joined Jan 8, 2017
2,698
One possible solution that might work is first convert the current value into a voltage value. Then feed this into an op amp integrater. Integrate over a period of say one second. The integrator would be cleared every second by a microcontroller but just before it was cleared the integrator output value would be read by the ADC in the microcontroller and that reading would be added to to the sum. I have never tried anything like this. What do other members think ?

Les.
 

Thread Starter

Poor old sod

Joined Jul 25, 2017
110
I'm sorry to be so disorganised. I have an ebay sourced 0-49.9A DC digital meter, model C27D. with it's shunt. the shunt is attached to the 24V -ve terminal. with Positive for the meter adjacent the terminal and -ve further away. the shunt drops 75mV @ 50A. This is used to drive the digital meter. 24VDC is used from across the battery only to power the meter. The meter reads discharge current only. The refresh rate of the display is 500mS. The sample time is unknown, but I suggest it's short, and that the capacitor has a series resistance , preventing very fast charging. The readout is constantly changing with extremes every 30sec or so. The extremes are what I want to see more of, as they are the true value I want displayed.. If I hold the signal too long the reading will increase beyond the true value. I don't know how to synch the pwm pluses to the meter. I was thinking of an RC add in with the C across the meter and R in series wtith C and across the shunt, thus prolonging the sampled signal somewhat. It's not essential that exact figures be obtained, ballpark will do, as I just want an easier time getting an estimate of current being drawn. Of course an analog meter would be much easier, apart from the op amp to drive it. I have only room for a small movement for an old VU type meter with a vertical edge readout . The very few of them left are quite expensive, and I'm unwilling to pay that much. I'm aware they are undamped.
 

LesJones

Joined Jan 8, 2017
2,698
What you want is still confusing. Do you want an average value averaged over a number of seconds ? Or do you want a peak reading ? What is the basic purpose for these readings ? My original thought was that you wanted to work out the average current so you could calculate how long the batteries would last based on their ampere hour rating. Now I don't think this assumption is correct. Your idea of a capacitor in parallel with the shunt is a non starter as the shunt resistor is only 0.0015 ohms so it would it would need an extremly large value capacitor to give the sort of time constant you want.

Les.
 

Alec_t

Joined Sep 17, 2013
11,665
Like it or not I think the solution is going to involve an opamp, so that either (a) high resistance values can be used somewhere to get a long RC time constant, or (b) the signal can be boosted enough for input to an MCU to do the averaging.
 

ebeowulf17

Joined Aug 12, 2014
3,274
I'm sorry to be so disorganised. I have an ebay sourced 0-49.9A DC digital meter, model C27D. with it's shunt. the shunt is attached to the 24V -ve terminal. with Positive for the meter adjacent the terminal and -ve further away. the shunt drops 75mV @ 50A. This is used to drive the digital meter. 24VDC is used from across the battery only to power the meter. The meter reads discharge current only. The refresh rate of the display is 500mS. The sample time is unknown, but I suggest it's short, and that the capacitor has a series resistance , preventing very fast charging. The readout is constantly changing with extremes every 30sec or so. The extremes are what I want to see more of, as they are the true value I want displayed.. If I hold the signal too long the reading will increase beyond the true value. I don't know how to synch the pwm pluses to the meter. I was thinking of an RC add in with the C across the meter and R in series wtith C and across the shunt, thus prolonging the sampled signal somewhat. It's not essential that exact figures be obtained, ballpark will do, as I just want an easier time getting an estimate of current being drawn. Of course an analog meter would be much easier, apart from the op amp to drive it. I have only room for a small movement for an old VU type meter with a vertical edge readout . The very few of them left are quite expensive, and I'm unwilling to pay that much. I'm aware they are undamped.
I'm with Les. Step 1 is knowing for sure what you want this circuit to accomplish. If you want to capture peak current readings, that will be possible, but I don't see the benefit. The peak current reading from a PWM driven circuit will always be the same. The whole point of PWM is that your switching components are never partially on, instead they're always full on or full off. This allows for more efficient switching, smaller parts, less heat dissipation, etc. It also means that within any given PWM period, unless duty cycle is 0 or 100%, there will always be the same peak reading and the same zero reading, but they'll just exist for different portions of that time period, depending on duty cycle.

If you want some indication of how speed impacts current consumption, how quickly the battery is being depleted, etc, then you'll want an average current draw, not a peak current draw.

To accomplish that, I think all you need is a simple RC circuit as drawn below (R and C values are guesstimates - they may need some tweaking.) Note that the capacitor is NOT in parallel with the shunt resistor - it's after the new resistor that's part of our RC filter.

I do have doubts now. I thought this was pretty straightforward, but @Alec_t knows this stuff 1000 times better than me, and he indicated that an op amp may be required, so maybe don't take my post too seriously until he weighs in!

IMG_4427.PNG
 

Alec_t

Joined Sep 17, 2013
11,665
If the meter is sampling the shunt voltage at 0.5s intervals and the motor is being PWM'ed at some non-synchronised frequency then the meter readings will naturally be erratic, as experienced. The meter at present sees a 1.5mΩ source impedance, but that would rise if the RC filter above is used. The meter may or may not be happy with that, but it's certainly woth a try. The filter would short-term average the PWM voltage and should eliminate the erratic readings. If no long-term average is required then no opamp etc would be needed.
 

ebeowulf17

Joined Aug 12, 2014
3,274
If no long-term average is required then no opamp etc would be needed.
Ahhh, that explains it. I see where you're coming from now. I agree that if you wanted a really long time constant to get long term averaging, a simple RC circuit would fall short.

And of course you're also right about the filter's effect on source impedance. I was working from the assumption that the meter behaves like your typical DMM, measuring the incoming voltage with a very high input impedance. If that assumption is correct, I think the simple RC filter would work, but there's no guarantee that my assumption was correct (I should be more careful about making assumptions about unknown components!)
 

ebeowulf17

Joined Aug 12, 2014
3,274
Just to appease my own curiosity and make sure I hadn't whiffed on this, I created fake PWM signals to confirm that the various duty cycles scale appropriately in the filtered output. Of course, you can't see the PWM signals, but you'll just have to trust me that it starts at full on, then drops to 50% duty, then 25% duty. Looks like it should work, as long as output impedance isn't a problem for the meter.

I also changed my dummy-resistor (fake motor) resistance to pull 55A. Out of curiosity, where did the 55A figure come from? Is that from the PWM motor controller, from the Gopher specs, from the battery? The number is higher than I expected, but then again, I have no hands on experience with Gophers, so I may just have no idea what's normal for them.

Finally, I added a formula to the output so that it divides the filtered, low-mV signal by 0.0015 (roughly equivalent to multiplying by 667) in order to scale the output into readable numbers, just like the meter would be doing. Anyway, here's the updated sim:
PWM-RC-filter_03.png
 

Thread Starter

Poor old sod

Joined Jul 25, 2017
110
Thank you. I was neededing only a short term average readout. I can prob find the pwm frequency, and think that as long as T<1/it then All should be well. I don'tmind a low reading, just want a more consistent one. The 55A is a peak reading I got under max load at full power setting. I'm grateful for the experimental values obtained. They are a good guide.
 

ebeowulf17

Joined Aug 12, 2014
3,274
Thank you. I was neededing only a short term average readout. I can prob find the pwm frequency, and think that as long as T<1/it then All should be well. I don'tmind a low reading, just want a more consistent one. The 55A is a peak reading I got under max load at full power setting. I'm grateful for the experimental values obtained. They are a good guide.
Happy to help! Let us know how this project works out for you, whether with this approach or some other. Cheers!
 
Top