Convert pwm to voltage.

Ian0

Joined Aug 7, 2020
9,846
@Ian0 - not seen that specific device before, but its bigger brother TC4429 does up to 6A in an 8-pin DIP and at £2.15 (1-off, RS Comp.) its no more expensive than an opamp & a TIPxx. Application note AN798 shows a simple motor speed controller that uses the motor back-emf as a speed feedback.
This could be adapted with an opamp instead of the speed pot, something like... (not tested)
Those 5-pin low-side drivers are a particular favourite of mine (you can make a power555 with it, but that’s another story). They don’t always make good power drivers as they have the series-resistance to damp a MOSFET gate built in. However, I’m not sure we’re dealing with a conventional DC motor. I’ve use a lot of Sunon 12V 80mm fans, and they haven’t been conventional DC motors for three decades. There is a smoothing capacitor, and a transistor drive circuit to a brushless motor. They speed-control very well from about 50% of rated supply to 100%, but don’t really like being switched on and off rapidly, hence the LC filter on the PWM.
 

crutschow

Joined Mar 14, 2008
34,470
The result is interesting, but the LTC6992-1 may be an unfamiliar part to many.
what is the circuit to the left? The one that includes LTC6692-1, does this circuit replaces the Arduino because there is no Arduino in simulation?
Yes it' just to simulate the PMW from the Arduino.
I thought that was clear from the "PWM Input Simulation" label, but apparently not.
 

crutschow

Joined Mar 14, 2008
34,470
Powering the buffered output of op-amps with a power transistor, will fix voltage as required or just increase current. Increasing current while have the same impedance, will also increase voltage!
The buffered output increases the available current at the voltage determined by the PWM duty-cycle.
The fans will take only the current they need at that voltage.
What Op-Amp can replace the LMC6484A? Because it is not available.
Any rail-rail type.
What is your source for parts?
 

BobaMosfet

Joined Jul 1, 2009
2,113
I am trying to convert arduino's pwm output (0-255) to constant dc (0-12) based on the value of pwm at this moment (i.e. it can be varied later on). Is there an easy direct way to do this?
Using a LPF, and an Op-Amp could achieve the requirement voltage, but when connecting any device even a resistor of 1k, or 100 the voltage drop to below 5v!
Are you trying to obtain a voltage to use as a value- an indicator signal, or are you trying to drive something else with a voltage? Which you choose, determines the solution, barring other issues (such as Arduino only being 0-5V).
 

Papabravo

Joined Feb 24, 2006
21,228
What is the component labeled "U2"?

What Op-Amp can replace the LMC6484A? Because it is not available.
Also, I just want to make sure that my understanding is correct, does the gain is calculated from your circuit as: 1+ 51.1k/36.5k ? With no consideration for the capacitor connected in parallel to the 51.1k.

The last point, I am still confused if this design will give me the change to connect 5 parallel DC computer fans, each operates on 12v (max)?
U2 is an ideal comparator whose operation is described on the schematic. Output is high or +5V, when the + input is greater than the - input and low or zero otherwise. As you said there is no Arduino component in the simulator. I was trying to come up with a way to show what was going on without using to much handwaving. Even if the schematic symbol was unfamiliar to you, the waveforms should have conveyed some notion of the operation.

The gain calculation is for DC where the capacitor is an open circuit. It has no impact at DC. What happens to the gain for AC signals it that it remains nearly constant up to a "corner" frequency and then it falls off. The simulator can show you the AC gain if that is of interest to you.

You never said how much power 5 paralleled fans will require. On the simulation the top graph shows the power delivered to the 14.4 Ω which is about 3.5 Watts and the power wasted in the TIP31C which is about 2.5 Watts. This approach is MASSIVELY inefficient, which is why nobody does things this way. I guess you have to try these things for yourself to discover what you don't know. The good news is that you can discover many things without having to buy parts, build it up, only to see the magic smoke released.

One more point. finding appropriate parts is something you should practice doing. There won't always be a ready resource you can ask. Only you know your requirements and your budget.
 
Last edited:

BobTPH

Joined Jun 5, 2013
9,003
Are you trying to obtain a voltage to use as a value- an indicator signal, or are you trying to drive something else with a voltage? Which you choose, determines the solution, barring other issues (such as Arduino only being 0-5V).
He also s trying to drive 5 12V computer fans.

Bob
 

Papabravo

Joined Feb 24, 2006
21,228
Yes it' just to simulate the PMW from the Arduino.
I thought that was clear from the "PWM Input Simulation" label, but apparently not.
Trust me, I knew what you were trying to do. I even fetched the datasheet to make sure. I doubt the TS even bothered to do that.
 

Irving

Joined Jan 30, 2016
3,897
Also, TC4429 is not available, and I am wondering what is the usage of variable resistor (potentiometer) of 10k?
Where are you trying to buy parts? Available from all my usual suspects...

Do you understand how a DC motor works? If not the rest of this won't make any sense. The 10k resistor is the speed control in that example circuit. It samples a proportion of the back-emf of the motor which is proportional to speed and integrates that with the capacitor to make a crude self-PWM. At start-up the voltage across the motor is 0 so the output of the chip rises to near supply volts. but because the motor has a very small resistance it draws a high current (start current) generating maximum torque and the voltage across it is very small maintaining the driver output at a high voltage. As the motor accelerates - at a rate determined by the inertial load on it and the current through it - the windings generate a voltage - back-emf - that opposes the current through the motor. Left alone the motor speed increases until the back-emf reduces the current to the minimum to maintain the frictional losses at that speed and torque loading. However, at some point the sampled back-emf voltage across the motor causes the input to the driver to exceed its high trigger point and its output drops to zero. The diode prevents the driver putting an electrical load on the motor and so its speed starts to drop as it can no longer maintain the torque required. Once the voltage has dropped past the driver's low trigger point it again turns on, supplying voltage to the motor. The effect is that the driver switches the current to the motor at a rate that maintains the average voltage - and therefore speed - at the value set by the variable resistor - in effect a crude PWM (actually more a variable frequency drive VFD I think).
 

Irving

Joined Jan 30, 2016
3,897
Yes I will drive something with it: I need to operate 5 DC computer fans in parallel and control the speed of all of them by reducing or increasing the voltage across their terminals (0-12v)
The following applies to fans that are a true DC motor, not those based on a 3-phase bldc motor with a built-in controller.

You won't get good speed control with them in parallel as the speed control works by sampling the back-emf from the motor, a closed-loop arrangement as discussed above - that requires a power-stage per fan.

A simple variable voltage power supply arrangement with no feedback, a so-called open-loop arrangement, will work but has many issues. Unless the fans are extemely closely matched they won't all run at the same speed, and at low duty cycles (low speed) some may not run at all due to current-hogging.
 

Papabravo

Joined Feb 24, 2006
21,228
I have just implemented this circuit but with two modifications: the first is replacing the LMC6484A OpAmp with another one (LM358), and the second is replacing the resistor 14.4 with 1k. The output was about 11.5v, I used power supply of 15v, the output was good for me, and I was very satisfied with it. However, when I have just connected the first fan, without any other ones, this voltage dropped from 11.5v to 4.5v, and the speed of fan was extremely low. I forgot to say that I used duty cycle of 100%, i.e. its maximum capacity. When I have just connected the second fan in parallel to it, the two fans won't work at all. The good point in this design is: I could even operate a single fan at low speed, I could not do that before with all other configurations. So, thanks a lot for your design, but I am still asking if I could adjust the design to be able to run the 5 parallel fans. By the way, I replaced the LM358 with TL082, and another time with TL071, I got exactly the same behavior in each case. For resistor 14.4, I replaced it with 1k, because the 15ohm resistor has burnt 10-20 seconds after connecting the power supply. Also, I tried to replace the 1k with 510ohm, and 330ohm, no difference in the output in all cases (changing opamp and resistor) I got an output between 11.3 to 11.6. The target now is: fix this voltage across the 5 fans, and adjust it a little bit to reach 12v (if we can do so). Again, many thanks for your design, it started to work.
You obviously did not understand anything. The 14.4 Ω was not supposed to be part of the circuit. It was supposed to SIMULATE the load of a fan that draws 500 mA. Replacing it with 1K will seriously INHIBIT or ELIMINATE the ability to drive a fan motor. What in blazes motivated you to do that?
 

Papabravo

Joined Feb 24, 2006
21,228
What you have just written is obvious, because if enough current is passing through each fan, they should work properly. So, the point is how can we fix this issue? I am exactly doing the same circuit with no single change other than replacing the OpAmp by TL082, also tried LM358, and I got same result for both. The pwm source is pin 5 of the arduino, I don't know if this is an important information or not. What else should I do to compensate this insufficient current? I think that some modification can be made on your design, so it meets the requirements, but I am still do not know what exactly this modification is. Thus, I am asking if you could help figure it out, or even suggest a source for guidelines.
We're not there, we can't see your setup, and I don't know if it is possible to help you. AFAIK you have not provided us with any useful schematic diagram showing what components you have and how you have wired things up. Going back through the text to figure out what you have is quite simply impossible.
 
Last edited:

MisterBill2

Joined Jan 23, 2018
18,600
I am wondering why the effort to drive a cooling fan with other than the supply voltage?If it is a 12 volt fan than feed it what is available. It will run on 5 volts OK, but not as fast.
AND a note about PWM driving: it will never be able to supply more voltage than the PWM waveform voltage.
 

ag-123

Joined Apr 28, 2017
276
Low resistance, like DC computer fan, it has a very low resistance, I guess in ohms, not even in kohms
There is another way, try a LM2596 buck converter. there is an adjustable one. But in the same way, you would need some sort of dc voltages to control the LM2596. But it likely won't need much currents so the Atmega chip may be able to do that adjustment directly with an rc filter.

If you are looking for ready made ones there are many here
https://www.aliexpress.com/wholesale?catId=0&SearchText=buck+converter

This would be able to power most of the common devices motors etc.
literally, you can even make one yourself out of an arduino, takes a P channel mosfet, and arduino can be used to switch that mosfet. the buck converter network is the same.

btw op amp won't be adequate for this purpose, it would at least need to drive a transistor at the output. typical op amp outputs is in the milliamps.
but a power mosfet can easily be driven that way, even directly from microcontrollers. n channel ones works, but is hard to use, needs a driver stage with bootstrap for the mosfet itself.
 
Last edited:

Irving

Joined Jan 30, 2016
3,897
Do you have a specification or model # for the fan, or measure the current a single fan takes at 12v. Until we know what is needed it's hard to say what wrong.

Also, the wire that 'burned up' - what gauge/size was it and where was it connected from and too?
 

MisterBill2

Joined Jan 23, 2018
18,600
OK, I see a few problems, the major problem is trying to provide something close to smooth DC to drive a DC fan that may be a brush type motor, or it may be an electronicly commutated motor. You do not need to use smooth DC!
And you do not need to use a common collector emitter follower circuit.
What is needed is an NPN switching transistor driven by that PWM signal, so it will switch from cutoff to saturated and that will work. But at the startup a brush type DC motor is close to a short circuit and that means that it draws more current. So for each fan the running load is six watts, 30 watts total from that 12 volt supply.
I would suggest a power FET device except that for saturation a higher gate voltage is required.
More comments later, I need to go to work now.
 

MisterBill2

Joined Jan 23, 2018
18,600
Use a ten amp, 200 volt Vceo NPN switching transistor so that there will be no need for any transient protection diodes in the motor drive portion of the circuit. Then there will need to be an opto-isolator IC to keep the switching current isolated from the micro PWM output. The common sides of the supplies c=should also be separated. Probably the opto device will not be able to provide enough base drive for the switching transistor and so a buffer/driver transistor will be needed. The driver transistor could be a npn high gain device driven by the output of the opto, with a collector series resistor to limit the base drive to the power transistor so that it is only into saturation far enough for the load current.
This arrangement will allow fairly good speed control but it will need separate feedback if there is a need to control fav RPM, which is very seldom done, since what is controlled is the air delivery.
So the feedback will be to the control program in the micro, while the drive is a quite efficient switching PWM system. Much more efficient and much more direct, with fewer components and much less heat. And much a simpler circuit.
 
Top