How can I switch between two PWM signals? I would like to control a servo motor by two different PWN source. these two PWN signals are coming from two PID controllers.
There might be better ways than the one I just thought of since I'm only a hobbyist, but you could have an AND gate on each PWM output, with your PWM signals on one input and a 'toggle' signal on the other input. Since an AND gate needs both inputs high to turn its output high, there will be no output without the 'enable' signal. To make sure when one is on, the other one is off, we can use a not gate before the second AND. Finally, we need a XOR gate avoid the mistake I made earlier: a state where one AND outputs hi and the other low. This would cause a short circuit as pointed out in the comments bellow.
You can use...
- MUX (multiplexer). The selection inputs control which one of the inputs gets sent to the output. Simple.
- Tri-state buffers. Connect the outputs together, and enable only one buffer at a time.
- Analog switches... Well, they are switches, they will let the signal through when closed, quite self-explanatory
- Junk parts solution with bipolar transistor used as common base switch