0-5v signal to 12v PWM output

Thread Starter

Poody

Joined Jun 19, 2019
6
Hello all,
I'm new here, and this is my first thread. I'm a mech. engineering student but
I'm only a year into my studies, so I have limited experience with reading and designing circuits, but here's what I'm trying to do:

-Use a varying 0-5v signal wire from a sensor
-Convert this signal to a 12v PWM driving a solenoid at 25Hz

I have found a couple of circuits that should allow me to achieve this, but I'm encountering an issue that I'm unsure how to resolve

I don't want the solenoid to cycle at all times. I would like to use pots to set some sort of scaling factor for the PWM conversion.
Example: Let's call sensor voltage Vs. I want to be able to scale the 0% and 100% duty cycle points up/down to achieve the following
-0% duty below a user set voltage
-100% duty above another user set voltage
-Linear scaling of Vs to duty between the two set points

Here are a couple of circuits that may be useful for me to begin with:
http://pcbheaven.com/circuitpages/Voltage_Controlled_PWM_Generator/ Seems to provide the inverse PWM signal that I am after. I need increased duty cycle with increased signal voltage. Possibly use a Unity Gain Differential Amplifier to subtract signal voltage from regulated 5v source and use this output as the input to the PWM generator?

https://forum.allaboutcircuits.com/...-cycle-pwm-of-12v-relay-to-ground-help.19763/
This is very similar to what I am trying to do. The circuit posted doesn't make a ton of sense to me but I am currently digesting it and trying to make sense of some of the symbols and labeling (Ge on the diode for example)


Anyways, if anybody could steer me in the right direction with this it would be greatly appreciated. Thanks!
 
Last edited:

crutschow

Joined Mar 14, 2008
38,326
Do you know what you want for a minimum and maximum set point range for the input versus the PWM duty-cycle?

What's the solenoid current?
 

Thread Starter

Poody

Joined Jun 19, 2019
6
Just a small update:


In reference to the pcbheaven link above, which details a circuit to produce voltage controlled PWM, the circuit compares input voltage Vs to a generated triangle waveform, and produces a square wave with peaks at the intersection of the triangle wave and Vs. Altering the range of the triangle wave should leave me with a square wave producing 100% duty whenever Vs is less than the minimum voltage of the triangle wave, 0% duty if Vs is above the maximum voltage of the wave, and a linear duty scaling between those two voltages. If I instead use a Unity Gain Differential Amplifier to subtract Vs from a regulated 5v source, the solenoid behavior will be reversed as desired.

From my reading on the triangle wave generator portion of the PWM signal generator, it seems the circuit implements a 10k pot to lower the voltage range of the triangle wave to a minimum of 0v. The wave is later amplified to range 0-5v. The voltage divider in the above circuit already takes care of my "no solenoid operation below a certain input voltage" requirement, but how would I go about limiting the maximum voltage of my triangle waveform using a second pot? Hopefully this question is simpler to answer than the original?
 

Thread Starter

Poody

Joined Jun 19, 2019
6
Do you know what you want for a minimum and maximum set point range for the input versus the PWM duty-cycle?

What's the solenoid current?
I want the minimum and maximum values to be in the 0-5v range. Maximum value should not exceed 5v, minimum value will realistically be set around 2-2.5v but I won't know the exact value until I have the opportunity to test sensor response, which is why I want user adjustibility on both ends.
Solenoid draws .7A

Thanks for the response =)
 

crutschow

Joined Mar 14, 2008
38,326
Here's a circuit that should do want you want.
I added a couple of extra comparators (U2, U3) and a latch (U4, U4) to the standard triangle generator circuit, to allow separate and independent adjustment of the high and low peak value of the generated triangle wave.
So you adjust pots U6 and U7 to set the 0% duty-cycle and 100% duty-cycle values respectively, for an input between 0 and 5V.

This adjustment does affect the frequency some, so after setting the limits you may need to adjust pot U8 to get the desired frequency.

The LTspice simulation below shows a 0% duty-cycle below about a 1.3V input (V2), and a 100% duty-cycle above about a 4.4V input, with a frequency of 25Hz for the shown pot settings.

upload_2019-6-21_12-0-17.png
 
Last edited:

danadak

Joined Mar 10, 2018
4,057
One possibility -

upload_2019-6-21_7-19-29.png


The SAR ADC reads the pots as input to the code to convert Vsensor to duty cycle, and then
writes to PWM control register to effect the settings and transfer function of V to DC (Duty Cycle).

Its a PSOC, design is one chip (pots and diode and power MOSFET external). Board cost ~ $ 10,
tool and compiler free.

Code would be fairly simple, maybe 20 - 25 lines of code. But you would have to
have some experience in C to do this. For future reference.

Resources used/unused in right hand window, most of chip capabilities still
available for other tasks. Like display, communications, counters, timers.......


Regards, Dana.

PS : Just caught the fact diode is in backwards, flip its connections to solenoid.
 
Last edited:

crutschow

Joined Mar 14, 2008
38,326
Hi Poody, for a very simple option you could use a LTC6992 IC with the output driving a mosfet.
That needs additional circuitry to provide the adjustable limits the TS wants.
And it's not easy to make the upper and lower limits independently adjustable as the circuit in post #6, which is desirable.
 

Thread Starter

Poody

Joined Jun 19, 2019
6
The solenoid is a pneumatic valve designed to operate at 25Hz. From my understanding, the PWM frequency should match this frequency, yes? I'm sure the frequency has some degree of acceptable error, although it is not specified. I would assume somewhere in the 20-30Hz range would be fine, but many of the voltage to PWM controllers I have seen operate in the 1k-5k Hz range which is far out of spec for my needs.
 

Thread Starter

Poody

Joined Jun 19, 2019
6
To all who replied, thank you for your suggestions! I will be ordering components today and likely building a few circuits sometime next week. I will report back with results.
 

crutschow

Joined Mar 14, 2008
38,326
The solenoid is a pneumatic valve designed to operate at 25Hz. From my understanding, the PWM frequency should match this frequency, yes?
Only if you want the value to turn on and off rapidly at a 25Hz frequency with a varying duty-cycle.
Is it designed to continuously operate in such a manner?
 

Thread Starter

Poody

Joined Jun 19, 2019
6
Only if you want the value to turn on and off rapidly at a 25Hz frequency with a varying duty-cycle.
Is it designed to continuously operate in such a manner?
Perfect, this is exactly what I am after! It is a fast acting solenoid that is designed for PWM operation. Valve is cycled at 25Hz, with flow through the valve controlled by duty cycle. It is not meant to be held open for extended periods of time.
 

crutschow

Joined Mar 14, 2008
38,326
Here's the circuit simplified some, by eliminated the op amp, thus reducing the part's count by one IC.
The tradeoff, is that the resulting sawtooth is not quite as linear as the triangle from the op amp. but that should have only a very small effect on the voltage-in versus PWM duty-cycle for this application.
But stay with the other circuit if such linearity is critical to the system operation.

upload_2019-6-21_12-37-31.png
 
Top