I am pondering over the problem, where I have one servo, and two input sources controlling it at different times. How to I decouple the signals electronically?
A servo has to be controlled by two controllers, depending on the state of the machine.
One source is manual mode. The other is auto mode.
Both PWM signals are within the 5V range.
I'd like to avoid relays.
The two controllers share the Vcc and ground rails. But the PWM comes from either controller A or controller B. [edit1] The controllers are separate from each other. One is on, the other off, and vice versa.[/edit1]
While I have controlled a lot of things one-on-one, I never worked with this scenario.
Connect only one output pin to the servo and each input to a separate input pin. You can then use the sketch to control which input signal is passed to the output pin
Apologies if I wasn't clear enough. I edited my original post saying:
The controllers are separate from each other. One is on, the other off, and vice versa.
The controllers just happen to actuate the same servo.
There are two controllers, each driving one servo at dedicated times.
----------
| uC A |-----
---------- |
--------| servo |
---------- |
| uC B |-----
----------
uC A: The Arduino controls the machine.
uC B: The second controller is a remote receiver
bool auto_on in uC A determines whether uC A should be "quiet', while uC sends the PWM.
My concern is that if I physically connect the PWM outputs from uC A and uC B that some interference may happen. Hence, the query: how can I electronically separate the signals.
Yes, one pin to the servo from uC A.
I do not want to read a PWM from uC B into uC A and do whatever processing to pass the signal through. Then I rather use relays
The machine has six servos. I am sure there is a better way; e.g., two transistors of sort?! [edit1]Or a multiplexer?
I am comfortable to switch two inputs to one output via software, e.g., AND, OR, etc. I am after physically separating one input from the other.
Please ask further questions, if this is not clear.[/edit1]
Good, I like to work with ICs directly when I can, and not only because I am cheap.
You might have less wiring and trouble with an 8 to 1 unit, I have not used any in so long but they come in all lengths or sizes, whatever you call it.
One controller replaces the wiring harness and mechanical operating components of the mower. [manual mode]
The mechanical linkages are severed.
The inputs will have encoders.
The mechanical actuators will be driven by servos.
I am almost done coding the original functions.
The other system is a flight controller (ArduPilot Rover) running on pixhawk, with yaw GPS. [automation]
The aim of my OP is to have the servos driven by [manual mode] XOR [automation].
Ideally the [manual mode] controller can be completely switched of, and automation takes over.
Lacking the experience in the design of the PWM switching, I am asking how to best achieve this.
I do not know, what happens when I connect two PMW outputs to one servo, when one of the outputs is 'switched off', not present, or whatever voltage it has if any, or what else it could do to interfere.
Why I want to switch between the two PWM sources, without using mechanical switches.
The multiplexer appeared to me as a proper solution.
I am more than happy to be educated of better ways for achieving the desired outcome.
You connect the servo to an output pin as usual. It does not need to be a PWM capable pin
you connect the manual output to an input pin
you connect the automatic output to a second input pin
the sketch reads from both inputs, but outputs only the selected one to the output pin
Selection of which input to be sent to the output could be done in a number of ways, including detecting that there is no input from the manual mode controller causing the automatic input to be selected to be output and vice versa
Say OR instead of XOR and I don’t see why a simple OR gate won’t do what you want.
You may need some simple electronics, but switched off system should present as logical zero or false or low.
Many ideas presented assumed that there would be servo signals present from two locations, running at all times, and one to be used.
You have repeat claim that by design only one line will actually have a signal. Somewheres above there are a few solutions that operate using this very convenient constraint.
A few diodes was one, I think.
We all like the more complicate solutions, natch. But you do not need them it seems.
x y (x or y) (x xor y)
0 0 0 0
1 0 1 1
0 1 1 1
1 1 1 0
I want XOR
One or the other, not both.
But yes, you're right... a PWM signal form one source, not both.
So if a switched off system presents itself as zero, low or false, then diodes may well do the trick, to prevent the live signal to be grounded.
I think I have to go and experiment.
I can see the option of the [manual] controller to be on, routing the signal as @UKHeliBob suggested; whether I use the pins or control a multiplexer or not.
Look, I appreciate every input and if I could have described it better, I apologise for not having done so.
I understand that we have to be not only precise, but very precise, and hence, appreciate you pointing out that my OP may not have been as clear as some would like.
So to be explicit:
there is one dedicated controller operating the machine's functions (in essence replacing physical controls with electronic ones)
there is an [automation] controller, taking full control over the machine.
The controllers, while independent, control the same servos
the option (A) exists to have the manual controller routing the automation PWM signals to the servos
the option (B) exists to have a more passive routing scheme, which can operate with one controller at any given time.
Not sure, whether this is any better. I hope it makes it clear, compared to my original statement: "I am pondering over the problem, where I have one servo, and two input sources controlling it at different times. How to I decouple the signals electronically?"