Go Down

### Topic: PWM shunt current measurement (Read 4787 times)previous topic - next topic

#### tuxstef

##### Jul 18, 2012, 05:52 am
Hello,

How do you get the right time if pwm is used for measuring a shunt voltage? I won't use some electronic circuits except the voltage gain amplifier to scale from e.g. 0-20 mV to 0-4V.
Is there a function to call to get the pwm pin is just now high?

Yours, Stefan

#### winner10920

#1
##### Jul 18, 2012, 07:14 pm
You could add a capacitor to smooth out the voltage on the shunt, although it may also affect the voltage reading,
Or take many reading fast and find the ones that count, mind you may also want adjust in software that the duty cycle varies so the avg current is different than at the instant its on
or add a capacitor and or inductor to the output to smooth the voltage and keep the current constant

#### tuxstef

#2
##### Jul 18, 2012, 08:13 pm
Thanks to winner10920 !

Quote
Is there a function to call to get the pwm pin is just now high?

#3
##### Jul 22, 2012, 06:24 am

Hello there,

1. Remember V=IR
2. If you have a signal 4-20mA coming, add a 250Ohms in parallel to have an equivalent of 1-5VDC (perrrrfect for arduino analog input)
3. If you 0-20mA, you have to use (1) to find the shunt to have a proportional Voltage acceptable for Arduino analog inputs
4. Forget any capacitor or any amplifier...

Hope this helps

#### tuxstef

#4
##### Jul 22, 2012, 07:01 amLast Edit: Jul 22, 2012, 07:20 am by tuxstef Reason: 1
Hello,

I want to ask new, because the main question could be confusing.

The situation:

There's a pwm driven Motor. On the high side current is measured with a shunt and the corresponding voltage is amplified with an opamp circuit to 0,2 - 4V. This voltage goes to the ain input of the arduino.

So, you know that pwm current isn't smooth so the simplest measurement method is to measure at the right time -> if the digital port of the pwm driver is high.

Now my question again:

Is there a function (or any way) to call to find out that the digital port (pwm driven) is just now high?

Also I could take some true rms ics like the AD636. I won't need it because I don't need any absolute measurements here.

The 3rd method would be to measure like the ad636:

Vrms = (Avg * ( Vin^2) )^(1/2)

Any code suggestions?

Thanks!

Go Up