I'm trying to design a circuit that will sweep an RC servo motor (an SG90) continuously from -90deg to 90deg position and to repeat this process indefinitely. I'm aiming to use one IC (a quad op amp 14pin DIP) as the main component. The circuit will be used to sweep a laser across its' ~180deg range of motion, for example, during a live performance.

I've designed a three op-amp circuit using a schmitt-trigger(U1A in fig.2)/integrator(U2A in fig.2) pair to feed a triangle wave into one terminal of an opamp comparator (U3A in fig.2). I know ideally what voltage values I need on my reference input to tell the servo which position to go to [fig. 1]

figure 1. PWM output vs. servo position

My current design is below. The pictured waveforms demonstrate my reference potentiometer set to be such that a 1ms pulse (in red) with a period of 20ms total is fed into the control line of my servo. The pk-pk values are not finalized as I'm simply trying to visualize the output [fig. 2/fig. 3 below]

figure 2. RC servo driver circuit

figure 3. output voltage waveforms from figure 2

My predicament is that I can't think of a way to automatically cycle between the three comparator reference voltages that I need in order to output the three particular pulse-widths of 1ms, 1.5ms, and 2ms. You'll notice that at the moment I have a place-holder potentiometer (R4) just for visual reference so that I can confirm what voltage drop I need at the reference input of the comparator to get these pulse-widths at the output. Ultimately, though, I don't want to have to manually adjust a pot to control the pulse-width as this doesn't achieve my goal of having an RC servo automatically sweeping back and forth.

I have considered other design topologies such as using two single op amp triangle wave generators of different time-periods, fed into opposing inputs of a comparator, but scrapped that idea since I need such a particular fraction of the pulse width for my duty cycle. Has anyone ever encountered a similar problem? How would you automate this pulse-width cycle?

EDIT: Thanks all for your thoughtful responses. I will more thoroughly go through these ideas after my work day and try and get back to you all!

EDIT 2: The final design incorporates the last op amp as a large time period triangle wave generator as suggested by Jens, which is then fed into the inverting input of the comparator U3A. I'll just round up and calibrate a few pots with my DVM for the funky resistor values. See below:

enter image description here

  • \$\begingroup\$ Hi, so your question is mainly asking how do you produce three different voltages (as reference voltage) consecutively over a specific time interval ? \$\endgroup\$ Jul 7, 2022 at 2:34
  • \$\begingroup\$ Yes, that seems like a good way to more concisely frame my question \$\endgroup\$ Jul 7, 2022 at 2:44
  • \$\begingroup\$ Why three static voltages, why not a sweep? Then you can build a sawtooth oscillator to feed the reference. Unless I misunderstand the goal. \$\endgroup\$
    – Bryan
    Jul 7, 2022 at 3:46
  • \$\begingroup\$ It depends how many variations of speed control you want. Sine , triangle, sawtooth, frequency, but the range has to be 5 to 10 % duty cycle at 50 Hz \$\endgroup\$ Jul 7, 2022 at 4:28

2 Answers 2


You already have designed a triangle function generator. You just need a second one with a very low frequency.

This 2nd triangle defines the sweep frequency. Using a proper calculated voltage divider you can feed the IN- input of U3A with this signal.

The last OpAmp of the LM324 can create this, however the linearity is far from perfect with only one OpAmp. P1 is the offset and the relation between R1 and R2 defines the amplitude. R5 provides correct duty cycle.


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ this seems to be the solution I am looking for. I will try to vary component values later tonight for the output offset and tri wave freq and come back eventually to this post with what I come up with. thanks for your contribution! \$\endgroup\$ Jul 7, 2022 at 21:03
  • \$\begingroup\$ Thanks again for your feedback. This is precisely what I used to solve the problem I was having. I referenced pcbisolation.com/blog/triangle-wave-generator/#example in order to better understand the circuit. In order for the amplitude as well as the high point/low point of my single op amp triangle wave to be correct, I coupled a few of the equations given in the above link and row reduced a 3x4 matrix. Now time to assemble and make further adjustments with nominal component values. Cheers! \$\endgroup\$ Jul 10, 2022 at 19:13

enter image description here The simplest way is a rain drop circuity can be foundhere and this will help to activate one of the 3 voltage reference at a time only provided if the frequency of the 3 duty cycle is the same.

Above is quoted from here. The picture refers to the input and output of a series of logic gates and it is extremely precise because they are made of flip-flop circuitry. My idea is that for example we can relate the input and output as (1-1 followed by 0-1 followed by 1-0). This means we can have 3 different output signal and this can actually help to help to activate the current into 1 of the 3 voltage divider(as reference voltage to your comparator) and use inverter to disable others and this applies for all of the 3 voltage dividers.

  • \$\begingroup\$ As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. \$\endgroup\$
    – Community Bot
    Jul 7, 2022 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.