PWM > Analogue Conversion project

Thread Starter

Brumby

Joined Nov 23, 2013
4
Hi Guys,

I would like to start with a simple project which i am hoping i could get some advice on where to start. I been searching for a couple of days on the forum and didn't identify a project that was the same.

I have been dabbling with kits over the years for fun and am wanting to learn more to mainly to stimulate the mind

I have a data logging unit that only has a configurable 0-5v input.

I would like to make a Simple device that can convert 0-100% duty cycle of a Solenoid or Injector to a linear 0-5v output (0v= 0% to 5v=100%).

The supply voltage varies from say 10v-16v when engine is running.

It is for logging of data only but would like it to be as accurate as it can be.

If someone could give me some guidance it would be appreciated

Thanks in advance
 

Alec_t

Joined Sep 17, 2013
14,280
You could integrate the signal with a simple RC circuit then scale it using an opamp. A voltage regulator would be advisable to stabilise the supply voltage to the opamp. Since this is for a vehicle environment there could be massive amounts of interference, so the circuit would also need to include voltage spike suppression components and would require electrical screening.
 

WBahn

Joined Mar 31, 2012
29,978
Phrases like, "would like it to be as accurate as it can be" will get you in trouble. Want it to be twice as accurate? Can do. Here's how much more money you will have to spend. Want it to be twice as accurate compared to that? Can do. Here's how much more money you will have to spend.

You need to determine, at least roughly, how accurate is accurate enough for your purposes. No need spending a bunch of time and money obtaining a level of accuracy that you don't need.

There are two basic approaches that come to mind. One is to measure the time between edges and compute the fractional duty cycle from there. The other is to produce two analog inputs, one of which tracks the max voltage (since it can vary quite a bit) using a peak detector and one that tracks the average voltage using a low pass filter. Convert both and then compute the ratio. There are other games you could play in order to use the max voltage to adjust the case on the average voltage so that you end up with a single signal that is scaled properly.
 

#12

Joined Nov 30, 2010
18,224
What he wants is duty cycle so I'm thinking, clip the "on" pulses to a dependable peak voltage and go with Alec in post#3.
 

Thread Starter

Brumby

Joined Nov 23, 2013
4
Hi,
Thanks for your replies,

I am wanting to backprobe the solenoid when logging

The Solenoid and injectors operate on a car battery voltage, which fluctuates with the output of alternator which would generally be 14v.

But thinking it will be best the minimum maximum input voltage range would be 10-16v.

I would like to convert:

Input= 10-16v(14v alternator charge) with varying duty of device 0-100%

Output= 0v-5vdc linear (convert to range say 0v=0% to 5v=100%)

Would it be best as was mentioned to first regulate the input voltage to say before attempting to convert to have a stable voltage to begin with

Thanks again
 

WBahn

Joined Mar 31, 2012
29,978
What he wants is duty cycle so I'm thinking, clip the "on" pulses to a dependable peak voltage and go with Alec in post#3.
I'll agree with that. That approach is used in a number of things, yet it didn't even occur to me. Might have yesterday or tomorrow, but apparently not today.
 

#12

Joined Nov 30, 2010
18,224
Here's a start at the circuit. Obviously, if the duty cycle is 100%, the output will be 5 volts. I have taken a stab at the values of the parts based on 1% accuracy and 1/10th of a second averaging time.
 

Attachments

Last edited:

Thread Starter

Brumby

Joined Nov 23, 2013
4
Thanks#12,

Would you recommend a regulating the input voltage to say a stable 10 or 12v? will that affect the signal in/out

Thanks Again
 

#12

Joined Nov 30, 2010
18,224
Yes and no.
Yes, I would regulate the input signal at 5 volts.
No, the circuit I drew is already regulating the input signal at 5 volts.
 

crutschow

Joined Mar 14, 2008
34,283
Here's a start at the circuit. Obviously, if the duty cycle is 100%, the output will be 5 volts. I have taken a stab at the values of the parts based on 1% accuracy and 1/10th of a second averaging time.
That circuit is basically a half wave rectifier with zener regulation and won't give a linear output with duty cycle. Moving the 100k resistor in series after the zener with no series diode in front of the zener should work, as shown below.

Edit: Note I used a 4.7V zener since I don't have a 5V zener in my parts library.

PWM Averager.gif
 
Last edited:

#12

Joined Nov 30, 2010
18,224
Thank you. I knew I wasn't quite right, but couldn't visualize the correct configuration. Now that you've done it, I can see that the input rectifier is completely unnecessary.
I assume the discharge path is back through R1 and R2 to the source.
The time constant is still a tenth of a second (+/- 1%).
It seems this will need a buffer amplifier on its output.
A simple voltage follower op-amp will do nicely.
The power supplies for the amplifier will need to be more than +5V on the positive side and - 2V to -3V on the negative supply, depending on exactly which chip is used.
ps, 5 volt zeners are available in the physical world.

http://www.mouser.com/Semiconductor...s-Rectifiers/Zener-Diodes/_/N-ax1mh?P=1z0w4d5
 

Attachments

crutschow

Joined Mar 14, 2008
34,283
Thank you. I knew I wasn't quite right, but couldn't visualize the correct configuration. Now that you've done it, I can see that the input rectifier is completely unnecessary.
I assume the discharge path is back through R1 and R2 to the source.
The time constant is still a tenth of a second (+/- 1%).
It seems this will need a buffer amplifier on its output.
A simple voltage follower op-amp will do nicely.
The power supplies for the amplifier will need to be more than +5V on the positive side and - 2V to -3V on the negative supply, depending on exactly which chip is used.
ps, 5 volt zeners are available in the physical world.
Proof of concept is where a Spice simulator is really handy. It usually identifies any fallacies in your basic design.

Not only is the input rectifier not needed but it will prevent the circuit from working properly since the zener voltage will not be pulled to 0V when the input goes to zero.

R1 is basically to limit the current to the zener while still providing a low impedance to the R2C1 averaging circuit. The square-wave voltage across the zener thus charges and discharges the capacitor slightly each cycle to give the average voltage output.

A rail-rail type op amp buffer should work down to 0V input and output with a 0V negative supply if the output doesn't have to sink any appreciable current (such as driving a resistive load going to ground).

5.1V is the closest standard zener value to 5V. Don't think I've ever seen a 5.0V one.
 

Thread Starter

Brumby

Joined Nov 23, 2013
4
Thanks for the good information,
It is good to see the way that you guys think how to make it functions.

The 4.7v Zener regulating would be fine as i can range the input the formula as 0v 0% to 4.7v 100%

Am i correct is thinking the zener with value of say 4.7v regulate the input voltage be it 10v or 16v?
 

crutschow

Joined Mar 14, 2008
34,283
............................

Am i correct is thinking the zener with value of say 4.7v regulate the input voltage be it 10v or 16v?
Yes. The zener exhibits a low impedance at its zener voltage so its voltage changes only slightly with a change in current (as determined by the difference between the source voltage and the zener voltage across the series resistor [in this case 1kΩ]). So the zener voltage will remain near 4.7V but change slightly as the input goes from 10V to 16V (increases about 42mV according to my simulation).

If this slight change is zener voltage with input voltage is a problem then there are more elaborate circuits using precision voltage references that could be used.
 
Top