1
\$\begingroup\$

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.

I want to switch between these two signals by an Arduino. here is a schema of what I want to do, but the problem is that I can't find the right switch. what do you suggest? enter image description here

\$\endgroup\$
2
\$\begingroup\$

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.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • 2
    \$\begingroup\$ Are you sure you want to connect the outputs of the two AND gates together? \$\endgroup\$ – CL. Aug 18 '17 at 14:45
  • 1
    \$\begingroup\$ What if AND1 outputs a 0, and AND2 a 1? \$\endgroup\$ – Vladimir Cravero Aug 18 '17 at 14:54
  • 1
    \$\begingroup\$ I think I got you. Current from AND2 to AND1? \$\endgroup\$ – Schizomorph Aug 18 '17 at 14:55
  • 1
    \$\begingroup\$ Yeah. You need something with a tristate output that includes HiZ. \$\endgroup\$ – Vladimir Cravero Aug 18 '17 at 14:56
  • 1
    \$\begingroup\$ Thanks for pointing this out guys. I think I fixed it now. \$\endgroup\$ – Schizomorph Aug 18 '17 at 15:11
2
\$\begingroup\$

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

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ thanks dear peufeu, I'm working by analog switch 4066. it works good when enable leg is directly connected to 5 volt by wire, but when I use the Arduino digital pins for ON and OFF, it doesn't work well, and always is ON \$\endgroup\$ – saeed-nik Aug 23 '17 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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