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.

PWM to DC converter?

Status
Not open for further replies.
OK, here it is.
This works by generating a linear ramp on C1 with the current source made up of U1a, Q1, and associated components. The final amplitude of the ramp will be proportional to the pulse width. The peak amplitude will be held on C1, buffered by U1B, and sampled and held by U2d and C2. The held voltage is amplified by two in U1c, with an offset generated by D3 and U1d to subtract out the minimum voltage of about 2.5V, corresponding to the minimum pulse width of 1ms. After sampling, C1 is discharged by U2c to get ready for the next pulse. The timing for the sample pulse and the discharge pulse is created by generating another ramp (with current source Q2 and cap C3) that is as long as the time between pulses (2ms nominal - if this changes much, the timing generator will have to be modified). The two window comparators U3a/U3b and U3c/U3d create the discharge and sample pulses, respectively.
The 1% resistors and the COG (NPO) capacitor are for stability. If this is not important, you can use sloppier parts.
Calibration can be done several different ways. The simplest may be to lift one end of R12 (you could add a series pushbutton switch), set the input pulse width to 1ms, and adjust Re2 for 2.50V on the output. Then reconnect R12, set the input pulse width to 2ms, and adjust R13 until the output is at 5.00V.
The quad op amp can be changed, but the critical parameters are 9 volt supply capability, very low bias current, input common mode range within 1.2V of VCC, and output range zero to VCC-1V. A rail-to-rail I/O part is the simplest to find, but I don't know if you can find one that is not SMT. You can obviously use op amps in separate packages.
Don't forget to add power supply decoupling capacitors.
 

Attachments

  • rample___hold.png
    rample___hold.png
    35.3 KB · Views: 1,350
they aren't hard to remove... but the servo uses a potentiometer for feedback, it's not open-loop...

but then again, I guess you could take them out, attach a similar potentiometer, and then adjust it to the desired point... when you apply an R/C signal to control the servo, you could tell whether the position indicated by the PWM input was greater or less than the position the pot is at by whether the electronics applied a positive or negative polarity to turn the motor one way or the other :) kind of a roundabout way of doing it, but it's sure simple, and you can get cheap servos for like 8 bucks, and the motor and gearbox without electronics are great for robotics/etc too :)
 
OK all, after a little break over the holidays and stuff, I started in on this project again. I took a look at the schematic Ron H posted and while I sincerely appreciate the effort, I have a feeling the resulting circuit would be pretty large indeed. I'm trying to make this fit in as small a package as humanly possible - something like 1" by 2". As to using a servo's electronics; I suppose I could, but most are surface mount components and I don't have the tools to work with them. So, after a little planning, I came up with the simple schematic shown below:

**broken link removed**

As you can see, the waverforms at various stages have been drawn in. They aren't exactly to scale, but that's what they look like. I drew lines from the input waveform so that the others will fall in line.

Anyway, this works quite well actually. There are a couple things that are bothering me though.

1: The reference voltage on comparator U2 is very critical. Any more or less than 5.3v totally screws up the output. This worries me because of drift and tolerances in components from heat or whatever. Unfortunately, if you look at the waveform on C1, you can see why it has to be so precise.

2: The circuit works well... until Vcc drops/rises to a value below/above the nominal 6.2vDC. I'm using a NiMH battery pack (5 cells of 2/3AA size, 1100mAh capacity) and it's output will drop as servos are used and as the charge level changes. I thought about using a 5v regulator to keep Vcc below whatever the batteries voltage might be under load, but that isn't too elegant in my opinion and the TO220 package is kinda big which would bloat the circuit's size. Plus, I don't have any 5v or LM317T's laying around (unless someone would like to trade a few for about twenty LM7912 regulators I have for some reason).

I'm still not quite done as I have to take the output of U2 (which has exactly what I was looking for) and convert it to variable DC, then feed it to the output comparator/current amplifier circuit, but that's the easy part. I don't want to go further until I can take care of my concerns first.

I like my design as it would be very small, but I'm at a loss right now. And to add insult to injury, I accidentally stumbled across the very thing I was looking for online - the "Opto Isolated E-Switch" (https://www.emsjomar.com/SearchResult.aspx?CategoryID=6 2nd item down). But even that one is kinda big and I want to finish this for the principle of the thing! Besides, you can somewhat see the circuit they used and it doesn't look that complex. However, if I can't get my project to work like I want, I'll just break down and with head hanging low in defeat, go buy theirs.
 
The main flaw in that is the low mark/space ratio of the servo pulses (varying between 1mS and 2mS in 20mS), so you will only get a small variation in the output voltage - with a 5V supply only from 0.25V to 0.5V.

A single 8 pin PIC would do the job properly, and there are various examples of R/C designs on the net!.
 
Nigel: I just looked into the PIC idea and decided to scratch that. The cost and complexity (programming, building the programmer, learning curve, etc) is more than just buying the device already made. It would be ideal if I was planning to make more than one project using PICs, but I only have this one planned right now.

Dinofx: Actually the input is a series of 1ms to 2ms pulses on a 20ms square wave from an R/C receiver. I want to take these small pulses and convert them to a variable linear DC signal. So, at 1ms, the DC output of whatever circuit would be 0V. Then, with an input at 2ms, the DC output would be Vcc. The DC level should vary depending on where the input signal was between 1ms and 2ms. As you can see, the difference between 1ms and 2ms is quite small, especially in relation to the whole signal, so it is quite difficult to get a reliable and usable output.
 
Maybe what you need is to charge the capacitor faster than it discharges. That way while the signal is mostly off, the charge will not drain as fast as you charged it. Maybe have two resistors in parallel, with a diode on the one with lower resistance used during the "charge pulse".
 
Once you get Vout, can you please tell me what you are going to do with it, as I am trying to do the exact same thing. I assume U2 is some low power op amp, so you'll need something beefier to run your motor.

Edit: Nevermind, I see you goal is to convert a 5-10% duration pulse into a 0-100% duration pulse. Great, now what's the next step?
 
Well, the next step is to take that larger changing duty cycle, filter it, and use one more comparator to give me a + or - DC output. I want to use it as an on/off switch for whatever accessories I want (solenoid, LEDs, etc). The beef up the output, I'll just use a transistor set up as a switch. Aside from maybe a solenoid, this won't be used for high current devices. The actual motor controller I will be using is a PWM unit capable of 90+ amps at 10-16vDC.
 
So, this discussion is actually about "A PWM to PWM converter"? If you know how to take the 100% duty cycle PWM and drive a variable voltage source for a motor, please help me out on my post on this topic. TIA
 
Well, I suppose part of it will be a PWM to PWM converter, but that's the part I'm stuck on so i don't think I'll be of much help there! The buffer stage, filtering for a relatively smooth DC output, and current amplification is pretty easy - which is the part I do know how to do. ;)
 
**broken link removed**

Article discusses conversion of .5 to 2.5 ms pulse at 25ms frequency to linear output voltage.
 
Update: I looked at that article that was posted and agree that is exactly what I'm looking for! However, the parts aren't available around here so I kept it for option 2.

What I ended up doing was removing the controller PCB from a servo (**broken link removed**) whose gears were all messed up. The output of the heart of the servo circuit, a M5166OL IC, takes a 1ms to 2ms input and outputs a PWM signal to feed to a motor through a pair of PNP transistors.

So, I breadboarded a circuit that filters this output and then compares the resulting DC voltage to a reference voltage to achieve the final output I need. I've figured out how to make the output do pretty much whatever I want depending on the input pulsewidth, so it is pretty versatile. The feedback pot had to be permanently set to be dead center for everything to work. The one small issue I have is that there is a delay between when you move the transmitter and the output of my circuit changes. Obviously, the culprit is my cap/resistor system, but if I reduce the charge/discharge time, there is too much ripple and falsely triggers the output comparator. I might utilize a Schmitt trigger to help with that (since the ripple only happens when the input pulse is about 1.5mS - but is clean at 1mS or 2mS) or simply live with it. Other than that, the circuit works marvelously.

Now, I have three more minor questions.

1: I was using a TL082 Op-Amp as my comparator and noticed I had about 1.2v of DC offset when the output should have been low. When the output was high, it was fine, but the low output bothered me. Two different chips have done this. I replaced it with an LM324 Op-Amp and it works MUCH better, except it is a bigger package since it contains 4 op-amps. Would a LM741 be a better choice? I am generally trying to use parts that are locally available (RadioShack).

2: A part of my circuit requires a 2k potentiometer, but the one I have that physically fits nice is a 10k pot. If power dissipation is taken into account, is there anything wrong with simply putting a 2.2k resistor across the pot? This makes the total resistance 1.8k (which is close enough for what I need). As I move the wiper, the resistance changes in a normal curve from 0-1.8k ohms. I just want to make sure there isn't some obscure "rule" against doing this.

3: What would be the best way to amplify the output current of my circuit? The op-amp's output isn't quite Vcc at 10mA, but I want to drive a load that will be fed the full VCC (or close to it) at 1-2 amps. Would a MOSFET be the ideal choice? If so, how is one biased to do what I am trying to do. Once again, I'd like to use RadioShack parts if possible.

Sincere thanks to everyone who has offered help and suggestions!
 
Like the 741 and most opamps, the TL082 has emitter-followers at its output that can't swing to ground. The LM324 is different and can. An LM358 is the dual version of a quad LM324. It has an 8-pins package.

RadioShack has expensive parts and a small selection. www.digikey.com or many other online parts suppliers have nearly everything and at low prices.
 
This is the final schematic that works.

**broken link removed**

It's a bit of a pain to "program" though. In hindsight, I really would've liked a version that would have the following action:
- At 1ms (minimum position) = low output.
- At 1.5ms (center position) = floating (neither high or low)
- At 2ms (maximum position) = high output

I'll order an LM358 from Digikey or similar place (thanks audioguru) and then will try to stuff the entire assembly in an emptied servo case. It will be tight though!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top