Go Down

Topic: Check my math. Measuring higher voltage PWM using arduino. (Read 277 times) previous topic - next topic

Miniflyer

Hi guys.

Following objective: I have an unknown PWM signal, it is a signal that regulates an electrical fuel pump. The pump motor is specified at 6V, the control unit intakes a 3s LiPo rated at 11.1V. Anything else is a "black box" i need to figure out.

So what am i planning: I want to measure the PWM over the pump output spread. Sadly i do not own an oscilloscope, and since i will need to gather the data and convert it on an arduino anyways, i figured i can just use an arduino to measure it in the first place.

So, first challenge, getting a readable signal. If it overvolts then i might fry my little helpers.....and i`m not really keen on that.
Second challenge will be reading the PWM from the stepped down signal.

Step 1:



Using the formula:

Quote
U2 = U/Rges * R2
I calculated U2=5V, U=15V (some margin added to the 11.1V spec) and guessing an R2 of 10kOhm, i get an Rges of 30kOhm.
Sooo R1 shoud be Rges-R2=20kOhm


Question 1: Are these values realistic? Should i go ahead and try the setup like this? Or will i probably fry a little helper?

Question 2: Will this setup change characteristics of a PWM signal ?

larryd

10k is 1/3 the total of 30k, therefore 1/3 the voltage will develop across it.

Suggest you use an optocoupler.



If the source signal is adversely effected, you can feed your signal to a transistor circuit.



 

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

CrossRoads

A0 will be (VCC-Vf)*R2/(R1+R2)

Plug in the numbers.

Should not affect the PWM waveform unless R1+R2 are really low values. If R1+R2 = 10K total for instance, and VCC = 15V, then current draw from Vcc will be small, just 1.5mA, which will be a good amount to drive the A0 input.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Miniflyer

A0 will be (VCC-Vf)*R2/(R1+R2)

Plug in the numbers.

Should not affect the PWM waveform unless R1+R2 are really low values. If R1+R2 = 10K total for instance, and VCC = 15V, then current draw from Vcc will be small, just 1.5mA, which will be a good amount to drive the A0 input.
In my calculation i am running 30k.... so 0.5mA at 15V. If i run at just 6V (pump spec), will the values still work?
I will need to order resistors, i have none in the specified range, so id hate to have to wait if my pick was off ....

Wawa

Why the A0 pin. Are you expecting a 'voltage' into the pin from that PWM signal?
I would expect you use a digital pin to measure the PWM on/off times.
Leo..

zoomkat

You might save some time by getting a inexpensive pot (potentiometer) and just dial in what you need for the measurement. The Arduino probably can detect digital input voltages below 5v for some voltage margin.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Miniflyer

Why the A0 pin. Are you expecting a 'voltage' into the pin from that PWM signal?
I would expect you use a digital pin to measure the PWM on/off times.
Leo..
That is the ultimate goal yes.....but if my black box outputs the full 11V as PWM i will fry the arduino. So i want to start conservative......if it outputs the 11 or so volts, it should read fine. If it outputs considerably less, i will be able to change resistors to 10k/10k or so

A poti seems like a good idea for tests, thanks

raschemmel


Miniflyer

Will work fine for just reading, but on the final edition i will need interrupts for the pwm reading. While reading, the Arduino will have to convert it either into stepper speed or servo output....


TomGeorge

Hi,
Where is the PWM coming from and what is it used for?
If it is a servo output then there is a standard format for most servos.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

wvmarle

Don't be too worried - there are always the clamping diodes (and you could add one of your own if you're still worried) to keep the voltage under control.

The main thing you have to do is keeping the current under control. At 3x LiPo the highest voltage possible is 3x4.2 = 12.6V. Those diodes are rated 1 mA, so limit to 0.5 mA and you're safe - that means a resistor of (12.6 - 5.5) / 0.0005 = 14200Ω. A 15-22k resistor between the signal source and your Arduino pin is all you need to stay safe, and you'll reliably and safely detect the signal at any voltage from 3V up to 15V or so.

Then a pulseIn(pin, LOW) followed by a pulseIn(pin, HIGH) to measure the low and high times of the signal gives you the frequency and duty cycle.

To measure the voltage levels of the signal, use a 12:1 voltage divider, connect it to an anlog input, and use the internal 1.1V reference (calibrate this with a known voltage as it has a 10% tolerance!) to measure the actual voltage levels used on your signal.

If you're running a 6V motor from a 3xLiPo source, that should mean a duty cycle of no more than 50%, to average the voltage down to 6V.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up