Radio-Controlled (R/C) Relay Driver
by cndg in Circuits > Remote Control
12363 Views, 73 Favorites, 0 Comments
Radio-Controlled (R/C) Relay Driver
It is very cheap and easy to connect relays up to a radio controlled receiver !
This project will connect 4 (or 8 or more) relays up to one channel of your radio-controlled receiver so you can remote-control switches and lights and things.
For this project, you will need:
1. an R/C receiver (you already have this!)
2. an Arduino Nano (these cost about $1.67. search eBay: Arduino Nano)
3. a relay module (you can get 8 relays (30v 10amps) for $4.47, or 4 relays (125v 20-amps) for $8.69) search eBay: 8-Channel Relay Shield
4. a servo lead to connect your R/C receiver to the Arduino-Nano; cut one off an old servo or extension lead, or, buy some off eBay. You can even use standard breadboard hookup wiring: it turns out that these female sockets are the exact right size to plug in to R/C receivers! search eBay: female breadboard jumper
5. some wire to connect the Relay-Shield to the Arduino-Nano. I chopped up an old floppy-disk-drive ribbon cable for this.
The position of the R/C stick determines which one of the relays activates. You can de-solder the stick potentiometer and connect a keypad with resistors if you want to trigger the relays using buttons instead (this step not shown).
Program the Arduino Nano
The Arduino-Nano (or just Nano for short) is a computer with a bunch of pins that can read and write signals.
First - we will program this to run the software which tells it how to read the R/C signals, and write the Relay outputs.
Unpack your Nano, and plug it into your PC using a USB cable. Some lights should flash a few times, and the power LED should come on.
Download and install the programming software needed to write the program to the Nano: it is called the "ARDUINO IDE" and can be any version - the one as at time of writing is 1.6.13 - get it here: https://www.arduino.cc/en/Main/Software
Tell the Arduino-IDE That You Are Using an Arduino-Nano Board
Select the "Tools" menu option, then the "Board" sub-menu, and select the "Arduino Nano" option.
Choose the Port Your Arduino-Nano Is Connected To
Your Nano shows up on your PC as a serial port. On mine, it's COM14:
Set the correct COM port using the Tools menu option, and the Port sub-menu.
If you don't know what port to use - you can open your control panel, then open the "System" utility in that, then open the "Device Manager" panel, and expand the "Ports" option. you will see some COM ports in there. Take a close look at the ones you can see, then plug or unplug your Nano - whichever new one goes away or appears, is the one to use.
Send the Program to the Nano
Save the attached file ServoRelayPro.ino on your computer somewhere (update: use the ServoRelayProV3_1.ino file if you want more features - see step 9 for details, or, use the ServoRelayPro3_8relay_i10.ino file if you plan to program your Turnigy-i10 transmitter to use 8 relays - see step 10), and open it in the Arduino-IDE.
Click the upload button to compile and send it to the Nano (this is the "right-arrow" in the circle.)... alternatively choose "Sketch" from the menu, and the "Upload" sub option.
If it all worked, the Nano LED should flash 3 times at the end, which is our Relay program letting you know it's running OK.
Prepare the Wires
You will be soldering the R/C servo wire and the relay board wires onto the Nano.
Two of these wires need to go through the same hole (labelled VIN) on the Nano, so, use wires that, when twisted together, are still small enough to go through the hole!
Twist the RED servo-wire end together with one of the relay board wire ends (I suggest using another RED one - this is the power lead).
Solder Power - the R/C Servo Red Wire and Relay Red Wire, Onto the Nano
Unplug your Nano from your PC.
One of the Nano holes will be labelled VIN - it is usually the one that is the furthest end away from the USB connector.
Push the pair of red wires that are twisted together through this hole, and solder it in place.
Solder the R/C Servo Wires
The Black (negative) wire going to the servo plug is negative.
Solder this to the GND pin that is usually located next to the VIN pin on the Nano.
The remaining servo wire is the signal wire, and is usually white - solder this to the Nano digital pin hole that is labelled D12 (this is usually the end pin right next to the USB socket - it's diagonally opposite the VIN pin.)
Solder the Relay Wires to the Nano
The VCC is the red wire and should already be soldered to the Nano VIN hole.
Solder the GND pin to the Nano GND hole (usually the 4th hole down from opposite the VIN)
Solder the remaining servo wires in a line, starting at D11 (for 4 relays, this is D11, D10, D9, and D8). For 8 Relays, continue using D7, D6, D5, and D4.
Test and Enjoy
Double-check all your wiring!
It should match what you can see in my picture.
------------------------------------------------
To operate:
1. plug in to your R/C and turn your R/C on.
2. your Nano LED light should blink 3 times.
3. Move your R/C stick slowly - as you pass through each of the relay zones, you should see the relay LEDs illuminate and hear the relays "click" - the Nano LED will also light up each time a relay is energized.
------------------------------------------------
How it works!
R/C receivers send pulses through a signal wire (the white one) to tell servos what position they should be in. A pulse of about 1ms in length means "all the way counterclockwise", and a pulse of about 2ms means "all the way clockwise" with a pulse of about 1.5ms means "in the middle".
We program our Arduino Nano to measure the length of these pulses.
We divide the total stick travel into 9 zones (for 4 relays) or 17 zones (for 8 relays). The first zone is "off" (no relays turned on), the second zone means "relay 1 on", the third zone means "off" again (no relays turned on), the fourth zone mean "relay 2 on", and so on - the final end (last) zone is also off again.
So - we have one zone for every relay, and inbetween every relay zone, is a "blank" (zero) zone.
To prevent interference and accidents, this setup will not activate any relay unless it has been selected for at least 200ms (1/5th of a second). Same for de-activation - so - each relay will always turn on (once activated) for at least 200ms minimum.
The Arduino Nano has a built-in power regulator (VIN), which makes it safe to connect your R/C output (usually 6 volts) to the Nano (which is happiest consuming 5volts, which is what the built-in regulator feeds it).
The Relay modules ("shield" is another name for "module") accept the 6volt power from your R/C, and have inbuilt LEDs and opto-isolators of their own, making it safe to connect everything up to one-another without needing any resistors/diodes/etc at all!
One day in future I'll come back and add more instructions here - showing you how to add a keypad to your transmitter to individually activate relays using buttons.
------------------------------------------------
Warning:
Do not plug your computer into the Nano when it is already being powered by your R/C receiver. I don't know what might happen if 2 different things try to power this at the same time!
hint: if you disconnect the red (middle) power wire from your R/C, then it is safe to power the Nano via USB then (this won't work the relays though - we soldered their power to the VIN which is not used when USB is supplying the power)
------------------------------------------------
Extra: attached here is version 3 of the software (ServoRelayProV3_1.ino) - this is functionally the same, however, the Arduino-Nano's LED is used to communicate to you what is going on inside it's brain. If you load this version onto your Nano, then the blinking LED has the following meanings:
a. right at the start - blinks 4 times (if it's programmed for 4 relays) or 8 times (if it's programmed for 8 relays)
After startup:-
b. not blinking - no signal detected from the R/C receiver.
c. blinking really fast continuously - R/C signal detected (it blinks once for every 2 signals that come in - signals come very fast)
d. one short flash, then off for a long time (about half a second): Relay #1 is energized
e. two short flashes, then off for a long time (about half a second): Relay #2 is energized
f. three short flashes, then off for a long time (about half a second): Relay #3 is energized
g. four short flashes, then off for a moment (about half a second): Relay #4 is energized
h. five short flashes, then off for a long time (almost 1.5 seconds): Relay #5 is energized (if you have 8 relays, the delay is 1.5 seconds. If you have 4 relays, the off-delay is only half a second.
i. and so on...
Downloads
Setup Your Transmitter to Trigger the Relays
There are lots of ways to use your transmitter to trigger relays.
The easy way is imply to hook up a stick, like a throttle level, and as you move this stick, it will trigger whichever relay is activated by the zone the stick stops in.
Another way is to set up the buttons on your transmitter so they trigger the relay you select directly.
This video shows you how to configure a Turnigy-i10 transmitter with two of it's 3-position-switches so that using all combinations of up+down+middle on each of those two switches, you 9 possible outputs (one for every relay, plus one extra for "no relays".
Basically - this is how we do that:
We "mix" the relay output channel (which normally outputs -100% through 0 to +100%) with itself, so that when it wants to output -100, we mix in an additional 25 (so it really only ends up outputting -75),, we mix 0 with 0 so 0 still outputs 0, and we mix -25 with it's other output of +100 so it really outputs +75. In other words: we limit the range of the relay channel from -75 to +75 with 0 in the middle.
Then, we mix a second channel in with the above, programming this second channel to mix +25 or 0 or -25... giving us the desired 9 possible outputs on one channel.
-75 mixed with -25 = -100
-75 mixed with 0 = -75
-75 mixed with +25 = -50
0 mixed with -25 = -25
0 mixed with 0 = 0
0 mixed with +25 = +25
+75 mixed with -25 = +50
+75 mixed with 0 = +75
+75 mixed with +25 = +100
The attached Arduino Nano sketch goes with these video instructions and the above settings to make all this work nicely.