Espritmodel.com Telemetry Radio
Reply
Thread Tools
Old Nov 14, 2011, 08:28 PM
Registered User
LukeZ's Avatar
Joined May 2001
2,902 Posts
New Product
Open Source Lights - Arduino based RC Light Controller

I've been disappointed with the RC light controllers available on the market and decided to make my own. It works pretty well in my opinion so I decided I'd post it as an open source project. There is a bill of materials, Eagle Cad files, Arduino code, etc... You can also order a printed PCB from BatchPCB, the details are below.

I'll go into a more thorough discussion of the features in follow-up posts, but basically these are the specs as of now:
- Presently tailored for RC cars
- Control up to 8 light circuits
- At a minimum requires a throttle channel but can also accept the steering channel as well as a third channel for more functionality.
- Each light can respond to various "States": forward, reverse, braking, right turn, left turn, and any of up to 3 positions for the channel 3 switch if attached.
- For each light in each State you can set the value you want it to be: On, Off, Blink, Fast Blink, or Dim (dim only available on 6 of the 8 lights).
- All the settings for all the States for each light is called a "Scheme". You can have as many Schemes as you like and you can switch between them from your controller using nothing but the steering channel.
- All the settings/states/schemes are set in the Arduino code, but they are in tabular format and there is an example already there so it is quite simple to do. Ideally someone would write up a nifty Windows app to do it...
- The circuit is all through-hole components so while it is not terribly small it is easy to solder.
- Requires an Atmega328 with the Arduino bootloader pre-installed.
- Code can be updated on the board with any of the common FTDI cables.
- Works with both 5 and 6-volt RC systems.
- Compatible with the inexpensive YeahRacing LED light cables purchased from RCMart or wherever.
- Can be used as a failsafe - all the lights blink like crazy if radio signal is lost.

This post will have the updated source files.


Luke
LukeZ is offline Find More Posts by LukeZ
Last edited by LukeZ; Apr 28, 2014 at 12:27 PM. Reason: Bug fixes
Reply With Quote
Sign up now
to remove ads between posts
Old Nov 14, 2011, 08:29 PM
Registered User
LukeZ's Avatar
Joined May 2001
2,902 Posts
Basic Theory of Operation

Explanation of States
Each light can respond to six different conditions, or states. These are:
- Channel 3 - Position 1
- Channel 3 - Position 2
- Channel 3 - Position 3
- Forward
- Reverse
- Brake
- Right Turn
- Left Turn

State Notes:
- At the very least, you must plug in the Throttle channel. Steering and Channel 3 are optional
- If you do not plug in a steering channel, then obviously you will never encounter the Right Turn & Left Turn States
- If you do not plug in a third channel, the program will only use the values specified in Position 1 as the default. In other words, it acts as if you have a one-position switch that is always in Position 1
- If your third channel is only a two-position switch, the program will switch between Position 1 and Position 2
- If your third channel is a three position switch, you will be able to switch between all three positions
- For the third channel to operate correctly, and in fact, for all channels to operate correctly, you need to run through the Radio Setup once.

Explanation of Settings
For each light, you need to specify what will happen in each state - this is called the setting. The possible settings are:
- On
- Off
- NA
- Blink - Will blink at the rate set in the UserConfig.h
- FastBlink - Will blink at the fast rate set in UserConfig.h
- Dim - Will dim to the level set in UserConfig.h

Settings Notes:
- For the three positions determined by Channel 3, it is best to specify an explicit setting, in other words, you usually don't want them to be NA.
- The opposite is true for the other states - if you don't want anything to happen during the Forward state for example, set it to NA, not Off. Otherwise, your light will turn off when going forward.
- Not every light can be dimmed. Look at the board to see which lights can be dimmed, they are marked with a star (*) on the bottom of the board. In Hardware Revision 1.3 these were lights 1-6.
- If you specify a Dim setting for a light which isn't capable of it, the program will treat it as Off instead.

Explanation of Schemes
A Scheme defines every setting for every light in every state. You may have multiple Schemes, the code defaults to 4 schemes.


Instructions - Software Setup in Arduino

This project assumes you are familiar with the Arduino IDE and know how to open a sketch, and load it onto an Arduino. This board doesn't have onboard USB so you need to load your scketches using an FTDI cable like one of these: (An FTDI cable is basically a USB-Serial converter used for communicating with microcontrollers)
SparkFun FTDI cable: FTDI Cable 5V (~$18)
Adafruit FTDI cable: USB FTDI TTL-232 cable (~$20)

Once you open the sketch you will see several tabs along the top. At the very left is the main loop code and that tab is called "OpenSourceLights". Most people don't need to mess with that. However you will want to look at the next two tabs:

AA_LIGHT_SETUP - tab in the Arduino IDE
This is where you specify what happens to each light for each state as well as where you can create multiple schemes. Examples are provided in the code comments, and it's pretty self-explanatory. Basically each scheme consists of a table. Each table has 8 rows, one for each of the 8 lights. For each row there are also 8 columns representing the 8 states (Channel 3 Modes 1, 2, & 3, Forward, Reverse, Brake, Right Turn, and Left Turn). The values in the table are whatever setting that light will be in for that state. The possible settings are: On, Off, Blink, FastBlink, Dim, NA.

See below for an example:

Code:
    prog_int16_t Schemes[NumSchemes][NumLights][NumStates] PROGMEM =
    {
        {
        //     SCHEME ONE - EXAMPLE PROVIDED
        //     Mode 1     Mode 2     Mode 3     Forward     Reverse     Brake     Right Turn     Left Turn
        // ------------------------------------------------------------------------------------------------------------------------
            {  Off,       Off,       On,        NA,         NA,         NA,       NA,            NA            },         // Light 1    -- Headlight One - On when Channel 3 is in Position 3
            {  Off,       On,        On,        NA,         NA,         NA,       NA,            NA            },         // Light 2    -- Headlight Two - On when Channel 3 is in Position 2 or 3
            {  Off,       Dim,       Dim,       NA,         NA,         On,       NA,            NA            },         // Light 3    -- Brake Light - On when Braking, otherwise Dim if Channel 3 is in Position 3
            {  Off,       Dim,       Dim,       NA,         NA,         NA,       On,            NA            },         // Light 4    -- Right Turn Lights - Blink when turning Right, otherwise Dim if Channel 3 is in Position 2 or 3
            {  Off,       Dim,       Dim,       NA,         NA,         NA,       NA,            On            },         // Light 5    -- Left Turn Lights - Blink when turning Left, otherwise Dim if Channel 3 is in Position 2 or 3
            {  Off,       Off,       Off,       NA,         On,         NA,       NA,            NA            },         // Light 6    -- Reverse Lights - only turns on when moving in Reverse
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 7
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            }          // Light 8
        },
        {
        //     SCHEME TWO - BLANK
        //     Mode 1     Mode 2     Mode 3     Forward     Reverse     Brake     Right Turn     Left Turn
        // ------------------------------------------------------------------------------------------------------------------------
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 1    -- Headlight One
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 2    -- Headlight Two
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 3    -- Left Brake
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 4    -- Right Brake
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 5    -- Front Running Lights
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 6    -- Reverse Light
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            },         // Light 7
            {  Off,       Off,       Off,       NA,         NA,         NA,       NA,            NA            }          // Light 8
        },

    };
Don't worry about the prog_int16 stuff or anything that looks confusing. Just change the values (Off, On, etc...) remembering to spell things correctly and keeping a comma between each one.


AA_User_Config.h - tab in the Arduino IDE
This is where various configurations are made, such as how many schemes do you want to use, does your speed control use a double-tap for reverse, debugging options, etc... Look it over, but for most people the defaults will be fine.



Instructions - Radio Setup
When you have a new model you need to run through the Radio setup routine once so the Light Controller can recognize the channels on your radio, which direction is forward and backwards, etc... You only need to do this once, and it doesn't have anything to do with the light settings. You can upload new light settings to your controller as many times as you want and it should still remember your radio settings.

You may wish to disconnect your motor from the ESC while running the Radio Setup to keep your car from running off your bench...

To enter radio setup mode, turn the power off on your Light Controller, hookup your radio channels (however many you intend to use), hold down the button on the Light Controller and while keeping the button pressed, apply power. Keep holding the button for a couple seconds until the Red LED on the board lights solid.

When the Red LED goes solid you are in setup mode. The Red LED will stay lit for the duration of setup mode, and the Green LED will blink to indicate which stage you are in. There are three stages to the Radio setup. At the beginning of each stage the Green LED will blink slowly once, twice or three times (depending on if you are on the first, second or third stage). This means get ready for the upcoming stage. Each stage lasts about ten or fifteen seconds. While it is in the given stage, the Green LED will continue to blink quickly once, twice or three times, again depending on the stage. This is the sequence, and what you need to do:

Stage 1
Green LED blinks slowly once. This tells you get ready for stage 1. Then while it is in stage 1 it will continue to blink quickly 1 time. During stage 1, the controller is memorizing the minimum and maximum travel values of your radio. So while it is blinking 1 time over and over again, move your throttle stick, steering wheel, and channel 3 switch (if used) back and forth to their extreme limits. The controller will recognize these and save the values.

Stage 2
Green LED blinks slowly twice. This tells you get ready for stage 2. While it remains in stage 2 the Green LED will continue to blink quickly 2 times over and over. During stage 2, the controller is memorizing your center points. Release your throttle, release your steering, and if you are using a 3 position switch on Channel 3, set it to the middle position. If you have a 2 position switch on Channel 3, set it to ON. Leave the controls untouched during this phase and the controller will memorize what the center values are.

Stage 3
Green LED blinks slowly three times. This tells you get ready for stage 3. While it remains in stage 3 the Green LED will continue to blink quickly 3 times over and over. During stage 3, the controller will detect any channel reversing you may have. While in stage three, hold your throttle stick to full forward, hold your steering wheel to full right, and if you are using Channel 3, set the switch to the ON position (if 2 position switch) or to the position 3 (if 3 position switch). Hold these things in place while the LED continues to blink 3 times.

Radio Setup - Complete
After the three stages are complete the Green LED will turn on and stay lit for 3 long seconds, and then both it and the Red LED will turn off. Radio setup is now complete, and you shouldn't need to run it again, unless your trims change drastically or you move the controller to a new model.



Instructions - Changing Schemes on the Fly
We have seen above that you can program multiple lighting schemes into the Arduino code. You can change from scheme to scheme from your transmitter while running your car. Here is a written description: To enter Change-Scheme-Mode while running your car, turn your steering wheel back and forth all the way to the ends quickly at least six times (three to the left and right). To acknowledge, every light hooked up to the controller as well as the onboard indicator LEDs will "twinke" (or blink very rapidly) for a few seconds. This lets you know that you're in change-scheme-mode. After that, all the lights will blink out the number representing the currently selected scheme (if you are in scheme 2 for example, the lights will blink twice, then pause, then blink twice again, over and over). To change schemes, turn the steering wheel over for a second. If you turn it to the right it will increment to the next scheme, and if you turn it to the left, it will go back to the previous scheme. Each time you arrive at a new scheme the sequence of blinks will change to indicate which one you are on.

To exit the change-scheme-mode and save the selected scheme as the active one, hold the steering wheel all the way over (doesn't matter which direction) and hold it there for two seconds. All the lights will twinkle again and it will save that scheme as the active one. It will remember this setting even when power is lost, and next time you power up it will be on the same scheme as you left it. Of course if you want to change it again it is quite easy, using only the steering wheel.



Luke
LukeZ is offline Find More Posts by LukeZ
Last edited by LukeZ; Mar 18, 2014 at 09:11 PM.
Reply With Quote
Old Nov 14, 2011, 08:30 PM
Registered User
LukeZ's Avatar
Joined May 2001
2,902 Posts
Instructions - Hardware Notes

Hardware Versions
The original board posted was v1.3, which was later found to have the 2N2222 transistors wired backwards from what they should be (collector and emitter pins were swapped). Strangely they still worked fine and I built nearly a dozen versions this way that had no problem. Nevertheless, the error was corrected in v1.4 and the files have been updated.

If you have a v1.3 board, and have not yet assembled it, you should rotate the transistors 180 degrees from what the silkscreen shows. Place them on the board with the flat of the transistor facing the Arduino chip, rather than the LED connectors. This will ensure the pins are in the correct locations.


Buying Bare Boards
I do not sell boards myself, but you can purchase them from OSH Park: LukeZ's Open Source RC Lights v1.4

OSH Park requires a minimum order of 3 boards. At the time of this update, the cost for 3 was roughly $19 shipped. I don't make any money on this, the price is set by OSH Park and the money goes to them.

Alternatively, since this is open source, you are free to take the Eagle files posted above to your favorite fab house.


Atmega328 Chip
Assembling the board is simple and straightforward. Programming the chip using the Arduino IDE is as easy as programming any other Arduino - that is, once you get the Arduino bootloader onto your chip! This is not so simple. There are tutorials online for how to do this, if you are interested. If not, never fear: you can buy Atmega328 chips with the bootloader already installed, here are two sources:
SparkFun ATmega328 with Arduino Optiboot (Uno)
Adafruit Arduino bootloader-programmed chip (Atmega328P)

Price is about the same for both, around $6. Not having to worry about getting the bootloader on the chip will save you a lot of trouble. Just build the circuit, plug in your FTDI cable (see the previous post), and this will look just like an Arduino to the IDE.


LEDs
The least expensive LEDs that already come soldered to cable assemblies with JST plugs are the ones from YeahRacing (series LK-0008 for 3mm LEDs, LK-0009 for 5mm LEDs). Other brands that work are 3Racing and Tamiya, though the Tamiyas are overpriced and usually have different ratings. All three of these brands use the same plugs and the same polarity, which this board is designed to be compatible with.

The YeahRacing lights can be purchased in many places, my favorite is RCMart. Here is there YeahRacing LED list: Click Here.

The YeahRacing LEDs come in 3mm and 5mm versions in all kinds of colors from Red, White, Blue, Green, Yellow, and Orange. They come as a string of two LEDs wired in parallel and they run about $3 bucks a set.

However you can use whatever LED you like and if you look in the Bill of Material spreadsheet you will also see part numbers of the JST plugs at DigiKey for making your own cables.


LED Resistors
Series resistors for the lights can be tailored to fit the LEDs in use. Typically the LEDs available in the RC Car market today come in a string of two LEDs per cable, wired in parallel.

Unfortunately specs are rarely listed for any of these products. Testing has found that a series resistor of 100 ohms is almost always adequate for these arrangements, even if operating at 6 volts. I have tested most of the YeahRacing LEDs with 100 ohms and they are fine.

If you wish to maximize the light output you may go to a lower resistor, say 75 or even 50 ohms. However be sure to measure current draw with a meter - you shouldn't usually exceed 20mAh per LED, which would be 40mAh total for a string of two LEDs in parallel.

If you want to be extra safe, a 150 ohm resistor could be used.

If you make your own LED strings or know the specs of the LED you are using, you can calculate the resistor value precisely using free online calculators, such as this one: LED Resistor Calculator.

EDIT: I recently found these very cool current limiters sold for cheap by Hansen Hobbies. They have a 10mA and a 20mA version, and they are presently less than a dollar apiece. Most LEDs are rated at 20mA. If you want to use one of these, just wire it inline with your LED wire leads, and jumper across the limiting resistor spot on the board.




Luke
LukeZ is offline Find More Posts by LukeZ
Last edited by LukeZ; Apr 28, 2014 at 12:40 PM.
Reply With Quote
Old Nov 14, 2011, 08:30 PM
Registered User
LukeZ's Avatar
Joined May 2001
2,902 Posts
Here are a couple videos that show the device in operation.

Open Source RC Lights - Intro (5 min 58 sec)



Open Source RC Lights - Radio Setup (4 min 8 sec)
LukeZ is offline Find More Posts by LukeZ
Last edited by LukeZ; Apr 10, 2014 at 07:31 PM.
Reply With Quote
Old Dec 09, 2011, 02:34 AM
Registered User
USA, CA, San Diego
Joined Apr 2007
484 Posts
thanks!
I have not started with Arduino yet, but this looks like a good reference when I'm ready.
Reegor is offline Find More Posts by Reegor
Reply With Quote
Old Dec 11, 2011, 05:55 AM
Registered User
Romania
Joined Dec 2006
36 Posts
Hi Luke

it's possible to upload this program in Arduino Pro Mini 328 ?
http://www.sparkfun.com/products/9218
OldMann is offline Find More Posts by OldMann
Reply With Quote
Old Dec 11, 2011, 12:24 PM
Registered User
LukeZ's Avatar
Joined May 2001
2,902 Posts
Yes, the code should work fine on the Pro Mini 328. It is the same processor used here just in a different package.
LukeZ is offline Find More Posts by LukeZ
Reply With Quote
Old Dec 19, 2011, 08:50 PM
ELECTRIC R/C
Jsutherland8's Avatar
INNERKIP,ONTARIO,CANADA
Joined Feb 2006
352 Posts
Open Source Lights - Arduino based RC Light Controller

Ya this is great.......
Thanks..........

Like those ARDUINO projects.
Jsutherland8 is offline Find More Posts by Jsutherland8
Last edited by Jsutherland8; Dec 19, 2011 at 10:56 PM. Reason: + ?
Reply With Quote
Old Dec 19, 2011, 10:54 PM
Yes, "that" Karl...
karl k's Avatar
Canada, BC, Burnaby
Joined Mar 2007
1,680 Posts
Excellent work. I really like the way you have the schemes set up.

Very well thought out. Keep up the good work.
karl k is offline Find More Posts by karl k
Reply With Quote
Old Jan 16, 2012, 04:22 PM
Registered User
Joined Jan 2012
1 Posts
Could this be build on arduino board itself? I'm starting with it myself. Eventually I'd like a setup similar to yours but with few changes. I want hazard lights to come on say after 10sec standstill and a flame from exhaust - say 2-colour led flashing after letting off throttle. Is that doable? Thanks
fallaci is offline Find More Posts by fallaci
Reply With Quote
Old Jan 17, 2012, 03:33 PM
Registered User
LukeZ's Avatar
Joined May 2001
2,902 Posts
Fallaci - yes, you could use a standard Arduino board, you will just need to add the transistors for controlling your lights (or you can use the Arduino pins directly if you keep the current within limits!).

The code can be modified to do anything you like. I don't really have time to make many modifications right now but you are familiar with Arduino programming just take a look at the code, I think you will find it rather easy to add the features you are talking about.

Luke
LukeZ is offline Find More Posts by LukeZ
Reply With Quote
Old Apr 05, 2014, 03:21 PM
Registered User
Joined Dec 2010
63 Posts
Hi Luke,

great idea. Do you sell the bare boards? batchpcd does not worl

Cheers

Mike
HongKongPfui is offline Find More Posts by HongKongPfui
Reply With Quote
Old Apr 05, 2014, 10:06 PM
kad
Quad Crasher
kad's Avatar
United States, NY, Poughkeepsie
Joined May 2012
637 Posts
Quote:
Originally Posted by HongKongPfui View Post
Hi Luke,

great idea. Do you sell the bare boards? batchpcd does not worl

Cheers

Mike
You can get boards from OSH Park. You'll have to order 3, but it's only $18.50 for the set.

http://oshpark.com/shared_projects/uynap7Y6

-K
kad is offline Find More Posts by kad
Reply With Quote
Old Apr 10, 2014, 08:21 PM
Registered User
LukeZ's Avatar
Joined May 2001
2,902 Posts
Thanks Kad for responding. Mike, you're right, BatchPCB closed down and was bought out by OSH Park. You can order the boards from the link Kad provided. EDIT: To get the latest version, you should actually order from the link posted above in the Hardware Notes section. This fixes an issue with the transistor pins and has a cleaner silkscreen.

Also the instructional videos had gotten removed, but I reposted them, you will see them above.

To answer your question about whether I am providing boards: no, you should buy them from OSH Park.

HOWEVER - I do have four, assembled and tested boards which I will give away for free. I will mail them to the first four people who contact me via PM, BUT you must also indicate to me you have an actual project to use it in and you must commit to post your results here in this thread! If you just have a general idea of vague testing you would like to do, please do not request one. I want to see these end up in actual RC models.

Please send your requests to me via PM so we don't clutter this thread with it.
LukeZ is offline Find More Posts by LukeZ
Last edited by LukeZ; Apr 28, 2014 at 12:37 PM.
Reply With Quote
Old Apr 10, 2014, 10:03 PM
Registered User
Joined Jun 2013
416 Posts
nice project

but I think it lacks a honking.

add channel for speaker " Beepppppp"

and when turn left or turn right or reverse , speaker also will work as Led blink: Beep....beep........beep
John michel is online now Find More Posts by John michel
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Arduino Nav Light Controller chuck99z28 DIY Electronics 37 Nov 02, 2013 03:39 PM
Discussion Linux Based Open Source Control System (OSRC) Gizmoman31 UAV - Unmanned Aerial Vehicles 10 Mar 18, 2012 11:26 AM
Idea Linux Based Open Source Control System (OSRC) Gizmoman31 Aerial Photography 9 Mar 18, 2012 11:25 AM
Question Any open source ARM based multi roter heli? ctrl Multirotor Talk 7 Jul 20, 2011 05:44 AM