Easiest way to convert variable DC to 50Hz PWM - Page 1
Forum section: electronics / projects

author: Enginenear
author_rank: Newbie
timestamp: March 06, 2025, 04:45:16 pm
content: I'm looking for theeasiest and cheapestway to convert a variable 1-8V DC voltage to a 50Hz PWM signal, such as those used to control servos in RC cars and planes.Easiest: simple electronic components and/or modules readily available on Ama*on, with little or no soldering / custom PCB manufacturing, so I'd rather not use a 555 oscillator. But if someone knows the most basic 555 DC controlled PWM generator (50Hz) I'd still consider it.Cheapest: <15 USD, so no fancy Arduino projects ;-)I have several ideas, but all of them are complex OR expensive OR both.Unless I get a better suggestion, I will try to buy a cheap servo tester [Amazon: servo tester] and replace the potentiometer with an opto-coupler (messy and unreliable).Thanks!

author: reodor
author_rank: Contributor
timestamp: March 06, 2025, 05:15:59 pm
content: The signal used to control an RC servo is, strictly speaking, not a PWM signal. It is the length of the positive pulse that determines the servo position. The 50 Hz frequency is not very critical. I think the correct name is PPM, or Pulse Peak Modulation.I have never seen a servo tester that takes a DC control input.An Arduino Nano is around 3-4 euros. Writing the code should be fairly simple, since there is a huge variety of libraries available for free.

author: Zero999
author_rank: Super Contributor
timestamp: March 06, 2025, 07:07:19 pm
content: If you want a solution which doesn't require any soldering, or electronics/programming, then you need to pay someone 100 times as much as your quote for them to make it for you.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 06, 2025, 07:18:53 pm
content: easiest and cheapestcan mean slightly differently things, and you have not mentionedsize and precision?Cheapest is a dual opamp and some passives, easiest is some low cost MCU module with a servo library.Even the PI PICO is a candidate here.

author: jpanhalt
author_rank: Super Contributor
timestamp: March 06, 2025, 07:26:23 pm
content: 4QD Drives years ago was my Bible for designing PWM. It's now mostly Archive of the same stuff. Some designs go from sawtooth to PWM. That is, without a microcontroller. Here are links to the main archive and a sawtooth to PWM:https://www.4qdtec.com/https://www.4qdtec.com/pwmmod.htmlI am not sure that's applicable, but it might be. John

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 07, 2025, 08:15:28 am
content: Quote from: Enginenear on March 06, 2025, 04:45:16 pmOne detail to watch, is the step size and tolerance of the pulses.A generic MCU with no crystal, will be maybe 1% timing accurate, plus the ADC and supply errors.Timers in generic MCU should have no trouble resolving 1us, if that was programmed.If you can find a unit with a crystal, that would be better for calibration, as it will be more consistent.Ceramic resonators are better than the MCU RC Oscillators, but still only ~0.5%, while any crystal should be < 100ppmIf you are ok with 1% then units like this should be okhttps://www.aliexpress.com/item/1005008107184692.htmlor this lets you trim errors?https://www.aliexpress.com/item/1005008157169402.html

author: youngda9
author_rank: Regular Contributor
timestamp: March 07, 2025, 11:53:06 am
content: Constant current source into a capacitor gives you a linear voltage ramp.555 timer used to reset the capacitor voltage to 0V at a 50Hz rate.Compare ramp voltage to voltage of interest to get a duty-cycle representative of the voltage being measured.It's a simple circuit. As an engineer, you should have the capability to draw a circuit, lay it out on a board, and order the board to then assemble & test. This will be quite cheap and a good exercise.

author: Enginenear
author_rank: Newbie
timestamp: March 07, 2025, 02:45:57 pm
content: Thanks to ALL that contributed with their ideas.To clarify, I know how to solder, make my own PCBs and program micro-controllers. I also have several Arduinos and components lying around, so the initial cost, other than my time, is null.I'm just trying to come up with the easiest "scalable" solution that I can share (for free) with the RC (Remote Controlled) vehicles community, given that some people there are less tech oriented and cannot do that.Best,N.

author: Enginenear
author_rank: Newbie
timestamp: March 07, 2025, 02:52:40 pm
content: For my specific purpose (a "toy"!) a 1% tolerance is more than enough.Thanks.

author: Zero999
author_rank: Super Contributor
timestamp: March 07, 2025, 11:04:24 pm
content: Quote from: Enginenear on March 07, 2025, 02:52:40 pm1% in terms of frequency? Duty cycle? That's not easy with cheap components, especially frequency, as capacitors typically have a nominal tolerance of 10%.Here's a way to do it with just analogue components.V1 is the power supply voltage, which is 12V.v2 a 9V reference voltage. This can be a voltage regulator such as the LM7809, a zener diode, TL431 etc.U1 & U2 are a comparator IC such as the LM393.U3 is an op-amp such as the LM358U1 forms a Schmitt trigger. The centre reference is set to half the reference voltage and the hysteresis set so it turns off at 8V and on at 1V. This sets the amplitude of the triangle wave.U3 is an integrator, which is inverting. It provides a delay and the linear ramp for the triangle wave. Its input is connected to the comparator's output and its output to the comparator's input.I'll post a more detailed explaination later.Here's the schematic, along with a simulation showing the triangle wave and the output when the input is swept between 1.5V and 1.7V in 1V increments.

author: thm_w
author_rank: Super Contributor
timestamp: March 08, 2025, 12:06:53 am
content: https://www.aliexpress.com/item/1005003457667684.html

author: Enginenear
author_rank: Newbie
timestamp: March 08, 2025, 12:20:07 am
content: @Zero999, I mentioned "1%" only as a reply to a previous post. AFAIK, servo control in RC is mostly frequency-independent (if it's in the 50-100Hz range should be fine). i did some tests using a waveform generator and a cheap servo and it worked.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: March 08, 2025, 12:37:40 am
content: Quote from: Enginenear on March 07, 2025, 02:45:57 pmNot sure what you mean by "scalable", but the basic Aliexpress modules should be 1%-3% ballparks, so are probably good enough.If you mean 'able to be improved' that's a little trickier. The most flexible and available is likely to be a Pi PICO 2. Crystal+better ADC.As #9 indicated, getting 1% from analog needs care, you can pay a bit more and get 1% caps, and 0.1% resistors and if you want voltage-in, (rather than ratio) you also need good precision references.To compound things, the triangle generator in #9 is simple, but to get 1-2ms you need to work on only a small portion of that ~ a 350mV span.Now a jellybean opamp offset of 3.5mV is a 1% error.You can add a gain stage to create a trapezoid waveform, to ease the task of the slicer, but such gain is sensitive to variations, so needs precision resistors.An alternative approach is to generate the trapezoid with digital help, using opamp + precise PWM, and then slice that.The precise PWM is fixed and can come from CMOS logic or a MCU, ideally with a crystal.This avoids needing any ADC and all timing is now digital, so can be crystal derived.16Mhz crystal is easy, but for more challenge I looked at 32.768kHz clocked digital side.Just 2 analog parts gets everything ready for the slicer, and the small 1nF cap is still low cost in 1% NPO. Note only half of the timing is slope determined, keeps tolerances tight.This example has ~ 15% over-range, and the slice is analog linear, so has no ADC quantized errors, servo pulse width granularity is limited by circuit noise jitter.

author: reodor
author_rank: Contributor
timestamp: March 08, 2025, 11:05:57 am
content: Quote from: Enginenear on March 08, 2025, 12:20:07 amIt is correct that the frequency is quite uncritical. There are, however, reasons to keep it close to 50 Hz. Some servos are designed to expect 50 Hz, and will not perform correctly if fed by a frequency that is significantly different. Some servos will overheat and get damaged if fed a too fast pulse. Unless you know for sure that your particular servo is designed to handle fast pulses, it is best to keep it around 50 Hz.