# Control timing of Monostable Multivibrator

Im having a hard time really understanding a Monostable Multivibrator. What I'm trying to achieve is being able to control the timing of the vibrator with a microcontroller of some kind. (arduino, pic, raspberry pi pico or the like)

I know that Rx and Cx sets the timing, and a potentiometer for Rx can be used for controlling the timing but how would this best be achieved with voltages from the MCU?

My thought was just controlling the voltage directly with the MCU to pin 2/14 (in the image example). But as my understanding of how the IC actually works is limited I'm not sure if it will work. Or do I need a digital potentiometer, optocoupler or a vactrol of some kind?

The IC i'm planning to use is a 4538 Dual Precision Monostable Multivibrator.

• This might be an X/Y problem - what are these variable timings for? What output (frequency, voltage) range is needed? There could be better/easier solutions than the 4538 for this task. Commented Jul 6, 2023 at 21:30
• The circuit I'm building is shifting a video sync signal. I'm using a 74HC132 and a CD4538 to shift a csync signal so a video image is shifter to either left or right. Using a video sync separator ic to get a clean sync signal. Commented Jul 6, 2023 at 21:39
• Here is a schematic of the circuit imgur.io/YyOirlo?r This circuit works, I can shift the pocture left and right but I need to do this with a mcu. And thats why I need to control the timing of the multivibrator. Ill draw up the schematic and add it into my question as soon as I got time if the link would somehow dissapear. Commented Jul 6, 2023 at 21:47

## 3 Answers

My first thought was to use a digital potentiometer, such as the AD5141, to replace the Rx1 and Rx2 resistors. They are usually programmed from an MCU via I2C or SPI. The AD1541 does either, offers 256 different potentiometer "wiper positions", and can also retain its "set position" when powered off and on again.

The other idea is to use a voltage controlled current source, as suggested by @Whit3rd, but I'll offer a more commonly implemented solution than the LM13700 OTA. The principle is to use a DC potential from a DAC to set the current in the path to ground via Rx and Cx, which will determine the charge rate of the capacitor:

simulate this circuit – Schematic created using CircuitLab

Note: the op-amp should be a rail-to-rail output type in this application.

Replace Rx with the blue boxed section, between A and B. I've also shown Cx, and the connection to the monostable IC.

Usually charging of Cx is exponential, towards +5V, and the timing is related to the time constant $$\R_X \times C_X\$$. With a constant current source such as this one, charge rate is proportional to current $$\I\$$, which is controlled by the potential $$\V_{IN}\$$ at IN. With the component values shown, $$\I\$$ and $$\V_{IN}\$$ are related as follows:

$$I = \frac{5 - V_{IN}}{10\times R_1}$$

The values I chose here will produce a range of currents around what would be present given your existing resistance $$\R_X=5k\Omega\$$. Unfortunately, the 4538 datasheet doesn't tell us the switching threshold $$\V_{REF}\$$ at pins 2 and 14, so it's very difficult to say what exact currents are needed. I'm afraid you'll have to experiment with R1 and Cx to obtain an appropriate range of pulse durations, over an input range of, say, $$\0V < V_{IN} < +4.5V\$$.

If you plan to use a PWM signal from the microcontroller, you will need to make sure it's very well filtered, to remove all ripple from the DC potential you apply to IN. That's not easy, and I recommend using a clean stable signal from a DAC instead. Any ripple at IN will cause timing jitter that will show up in the image.

• Great answer and it explains alot! I think in this project the easiest and cleanest solution is to use a digital potentiomer as I plan on using a microcontroller anyways. It's leaning on AD5141 or maybe MCP4551. I will save and experiment with the other solutions as well just to get a hang on how it all works. Thanks for the help. Commented Jul 7, 2023 at 21:18

To control the time of a monostable, the resistor (R_x1) should be replaced with a current source that your microcontroller can adjust. The easiest way to do this, is with an analog output from the microcontroller (a DAC function, for example). If that analog output has a zero to 5V range, you can use an operational transconductance amplifier as the voltage-input/current-output processor.

simulate this circuit – Schematic created using CircuitLab

The 16-pin chip has lots of other connections, all of which can be left open or grounded. The input-connected resistors are to allow at least an order of magnitude current adjust range, maximum current 0.1 mA when the DAC is at 0, time of the monostable increases as DAC is set higher...

Input resistors are just to convert a 0-5V DAC range to a (2.5VDC ,0 to -0.1 V) bias and range for the differential input pins #3 and #4.

• Great! Thanks for the answer. Now for a follow up question, how do I read the datasheet to calculate what current that needs to replace Rx1? For example in my 4538 circuit I use 1nF for Cx1 and 40k-55kOhm for Rx1 for my desired result Commented Jul 7, 2023 at 5:36
• @user1728582 The R1 resistor should be replaced with (roughly) twice the Rx1 value, so about 100k ohms. R1 and circa 5V is intended to equal Rx1 and half-of-5V. Not critical, the whole point is that it's adjustable. Commented Jul 7, 2023 at 8:24
• @user1728582 The resistor network is complicated, because it has to attenuate the DAC output and level-shift it; difference voltage at the LM13700 input terminals is intended to be 0 to +0.080 V, with some margin. The schematic has been corrected. Commented Jul 7, 2023 at 18:53

If a voltage Vdd (I'll assume +5V) drives Rx1 to set the monostable time, any programmed current source can replace it. A DAC accessory to a microprocessor will produce a programmed voltage, but not usually a suitable current.

A way to take a DAC voltage output to produce a programmed current source, is with a current mirror. If the DAC can drive the resistor value you need (10k ohms or more will usually be no problem), a two-transistor current mirror can produce the current source that would otherwise be from Rx1.

Assuming 5V power is available, and powers the CMOS monostable, and that the DAC has 0 to 5V output...

simulate this circuit – Schematic created using CircuitLab

The only caveat, is that the transistors should be identical (same manufacture batch, if possible). There is a dead zone (about 4.5V to 5V output from the DAC) where current is nearly zero unless you use R2, because the current mirror delivers zero current (infinite time on the monostable) under those conditions; an R2 value that satisfies $${R1\over {R1 + R2} } >= {0.6V\over Vdd }$$ will keep the full DAC output range in the operational range of the mirror (but you might want a smaller R2 value if very long times are not useful).