I'm working on a autonomous rc vehicle - I'm looking for a way that i can switch between running the autonomous code and manual control. The only thing being controlled is a servo and motor which are both just PWM signals. Any suggestions on how to best achieve this?
I assume you have a regular rc-car which you still want to use with your remote control and want an option to go for a coffee and have drive it around on its own.
The control-lines of the servos are just TTL level signals so you can switch them with a few transistors or something like a 74HC157 (Quad 2-Line to 1-Line Data Selector). The 74HC157 would have the benefit, that you can switch up to 4 servo signals with just one cheap chip (< 1€). If you implement some switch, you should make sure the switching takes only place while the signal is low, to prevent wrong signal lengths.
Reading the servo signals and having the Arduino reproduce them on another pin takes some very close attention to properly measure the duration and getting rid of errors due to intervening interrupts. This takes some effort. If you want to know, what's coming in from the rc-receiver, just connect some Arduino-input in parallel to the data selector circuit. You will still have to be a bit careful about what you measure on those, but the errors won't mess up the general performance of the vehicle and probably can be ignored.
For the output of the automatic mode, just use the Servo library. It gives good results.
Korman
Thanks for the excellent information. ![]()