Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

5-50hz PWM to constant DC voltage 0-5v

Status
Not open for further replies.

sirmuzz

New Member
I am trying to convert a 5hz (can go up to 50hz with external trigger) PWM signal to a proportional DC voltage for input into a flight controller. The flight controller (Unmanned aerial vehicle) take a 0-5v voltage to determine distance, but the sensor outputs 0-5v PWM. I know about the integrator circuit but on the O-scope it appears this does not work well for low frequencies. I get a alternating voltage in the form of a sinusoidal wave that is flat in most places. I need more like a 0.77in/volt type configuration. Because it is on a RC aircraft, size and weight are crucial.

I am using the Senscomp Mini-A (although the last two pins do not match the senscomp datasheet). It auto triggers at 5hz which is fine for me, and produces a PMW of 5hz (although on o-scope it appears to have a 200ms period with doesnt compute, think i am reading scope wrong). I using this with the APM 2.6 (arducopter) which uses a arduino mega. I do not want to modify the code so that i do not introduce bugs in the FC or throw off the timing of the software (could end up crashing a large quad into something and loosing lots of money, if not hurt someone).

I know just enough about electronics to get myself in trouble most of the time although I have been playing with them for 20+ years. I do have a o-scope, a fluke 95 50mhz scopemeter and function generator

It appears i need an integrator with a sample/hold circuit but not sure how that would work out given size and weight constraints.

Many thank for you ideas and consideration. Its always what seems to be the simple things that throw me for a loop.

Thanks!!!
sirmuzz
 
I have filterLab, an opamp based active filter designer. I could cobble up a low-pass filter. How much ripple can you stand? How steep the roll-off?

Example:


Fil.gif


Fil1.gif
 
You need a low-pass filter as Mike suggested. The question is how much ripple can you tolerate, since the amount of ripple affects the filter-order required, and the response time of the circuit. Is response time critical?

The fastest response time would be using a digital approach with a microprocessor. You detect the ON time of the PWM signal and divide that by the period to get the average signal value. This can be determined within one or two cycles.
 
I am not sure how to quatitize ripple, but i do need a clean signal or the FC would end up crashing into the ground. Faster the better. The FC uses the ultrasonic sensor to range the ground during automated takeoffs and landings, once above the min_sonar value, the pressure sensor and GPS are used for altitude. I have been toying with the idea or using a arduino mini to do an analogRead (pwm read) but then i do not know how to present that on another pin as a pure dc voltage proportional to the PWM duty cycle. From my research, the arduino does not appear to have a DAC that would allow me to output the analog voltage. Any suggestions for a small compact mirocontroller that would have the ability to accept PWM input and then output a proportional voltage on another pin?

On the integrated filter, with my frequency being so low, to get a good steady signal, my calculations show i would need some massive capacitance to keep the signal up after the PWM pulse has ended. I have tried up to 2000uf without any luck. I end up with a nice sin looking hump that then tapers off to nothing before the next pulse. I believe that the low pass filter could work and does work with higher PWM frequencies but my challenge with that approach seems to be the RC time constant and the ability to respond to change. The UAV during landing will need fairly quick reporting on the distance to ground, or into the ground we go, or it will never land.

Thank you for everyones help, and please forgive me if i seem somewhat ignorant to some of the finer points of circuit engineering.

Thanks!
sirmuzz
 
Do you think using a mirocontroller to up the PWM frequency then run it through the integrator to level it out would work?

sirmuzz
 
I believe the Arduino Mini has PWM outputs. If so, you could convert the low frequency PWM into a high frequency PWM that's much easier to filter (likely with just a simple RC LP filter). Measure the low-frequency PWM duty-cycle digitally and then use that value to generate the high-frequency PWM output.
 
5hz (can go up to 50hz with external trigger) PWM
Can you force the sensor to give a 50Hz PWM? That would give a faster measurement of duty cycle.
 
So why not measure the duty cycle in a small microcontroller like a PIC or PICAXE and use the D/A to get your voltage.

Or, try the circuit in figure 1 here: **broken link removed**

The uC circuit might be smaller overall.
 
If you want a non-microcontroller solution, the EDN analog integrate-and-hold circuit referenced by KISS should work for you. You just have to increase the time-constants for your PWM pulse period.
 
Thank you very much for the solutions! I think i am going to try the intergrator/sample/hold circuit first. Researching the arduino it appears it can only handle a small range of PWM frequencies; although you can change it a bit, 5hz-50hz does not seem possible without external components. I will follow up as soon as i can procure the parts to build the i/s/h circuit.

Thanks!
sirmuzz
 
Oh and i can externally trigger the sensor up to an astable frequency of 50hz, but that would require external components to trigger it, thus back in the same situation. I may go this route after trying the i/s/h circuit if i cant make that work. I would be able to trigger the sensor using a tiny, the put an integrator on the output pin fed to the FC. Do yo think 50Hz is high enough to smooth better with a integrator? I know it would be better to some degree because the freq is x 10, but is 50hz high enough still to get a smooth average using an integrator?

Thanks
sirmuzz
 
I just ordered the ICs from Linear and the components from mouser. Will let you know how this looks on the bench once i can get it bread boarded.

Thanks again for all the help, i am very appreciative of any education.

sirmuzz
 
220a.gif

Here is what you could expect with 50Hz PWM and a 4 pole Linear Phase filter with a cutoff of 10Hz. Note that that ripple is minimal, but it takes a while for the output to catch up to a PWM duty cycle change. The sim shows the PWM duty cycle going from 0% to 90% and back to 0%. You could make the response faster at the expense of having more ripple.

220b.gif
 
Thank you mike, that information will be very helpful modifying the integrator on the i/s/h circuit. I also ordered so ATTiny 85's to do the low freq pwm to higher freq pwm using the microcontroller as well. Will try them both and see how it works.

Thanks!
sirmuzz
 
Here is the platform this device will be used on. Just for anyone curious.
 

Attachments

  • ent1.JPG
    ent1.JPG
    59.1 KB · Views: 240
If you are using the intrinsic Arduino PWM function, the rate is 500Hz, so the filtering requirements will be greatly relaxed. The simulation above was for 50Hz PWM.
 
I am trying to convert a 5hz (can go up to 50hz with external trigger) PWM signal to a proportional DC voltage for input into a flight controller.
According to the datasheet for the Mini-A sensor series, besides the PWM signal the sensor already provides an analogue 0-5V (or 0-10V, according to model) signal, so why is the conversion necessary?
 
According to the datasheet for the Mini-A sensor series, besides the PWM signal the sensor already provides an analogue 0-5V (or 0-10V, according to model) signal, so why is the conversion necessary?
The PWM-output is a pulse that is high between the send and receive times of the ultrasonic ping: the distance is the speed of sound divided by half the pulse-time. When it is constantly and repeatably re-triggered, it is a PWM signal, but converting that to analog is not the best way to use it.
Either measure it digitally (using an Input-capture interrupt) or, as already suggested, use the analog output.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top