Go Back   RCCrawler Forums > RCCrawler General Tech > Electronics
Loading

Notices

Thread: Arduino based scale LED lighting - Wraith

Reply
 
LinkBack Thread Tools Display Modes
Old 01-03-2015, 09:36 PM   #1
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Arduino based scale LED lighting - Wraith

I've had an Arduino project in my back pocket for a couple of months just waiting to install into a new RC project. For Christmas my wife bought me a wraith kit so I decided it would be my first victim.

If anyone is interested the entire Wraith build is on my website:
Axial Wraith Kit | rczoony




I started out running the ESC, Servo wires, and all of the LED wiring I needed to a project box I located into the rear of the Wraith. The project box (sourced from Radio Shack) fits perfectly and will house the controller and receiver.



I added an extra light bucket that came with the kit but isn't installed by default. I mounted them to the front to act as left and right signals.


Here's the mess of wiring I was left to deal with after running it to the rear.


I wired the Arduino using 3 servo extensions. This is so I can tap into the signal, grounds and power. I'm using the ESC to power the circuit and have a Castle BEC to handle the servo power. The ESC only has to drive around 120mA in LEDs.



It's a bit of a mess in the box but access for programming isn't too bad.


So, here is a video of the final version of my code. Using the third channel of my hacked Flysky controller, I'm using the toggle function to increment x% at a time, from -100 to 100. This allows me 4 modes of LED operation:
MODE 1: -100 OFF
MODE 2: -33 Scale Light control
MODE 3: 33 Hazard Lights
MODE 4: 99 Police Style flashing


Last edited by drzoo2; 01-03-2015 at 09:42 PM.
drzoo2 is offline   Reply With Quote
Sponsored Links
Old 01-03-2015, 10:09 PM   #2
Pebble Pounder
 
Join Date: Mar 2012
Location: Port Angeles
Posts: 167
Default Re: Arduino based scale LED lighting - Wraith

That's a really cool setup
yotapower07 is offline   Reply With Quote
Old 01-04-2015, 10:52 AM   #3
RCC Addict
 
Join Date: Mar 2007
Location: Turn the mayflower around.. it will never work
Posts: 1,588
Default Re: Arduino based scale LED lighting - Wraith

I'm not a huge fan of lights but I'm kinda digging your set up! Good job eh
JokersWild is offline   Reply With Quote
Old 01-04-2015, 12:46 PM   #4
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

Admittedly, there are definitely better platforms for lights than a Wraith. I really wanted to do an install based on some Arduino code that I wrote and since I got the Wraith for Christmas, it's what I had. I have a friend with a Wroncho build that will benefit as well.

If anyone is curious... here is the wiring diagram I drew up.



There's about $15 in this controller total. Cool little project. I'd be happy to post my code and a little write up if anyone is interested in trying to build it. I have base code that would be a little easier to wire up, only requiring 2 servo extensions leaving the Arduino in the scale light mode eliminated third channel control.

Last edited by drzoo2; 01-04-2015 at 12:54 PM.
drzoo2 is offline   Reply With Quote
Old 01-04-2015, 01:13 PM   #5
Newbie
 
Join Date: Oct 2012
Location: Cremona, Italy
Posts: 12
Default Re: Arduino based scale LED lighting - Wraith

I hate to play the "know it all" role, but in the diagram the Arduino is powered by the BEC.
Anyway, nice job
Wich Arduino did you use?
Salzig is offline   Reply With Quote
Old 01-04-2015, 01:22 PM   #6
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

Quote:
Originally Posted by Salzig View Post
I hate to play the "know it all" role, but in the diagram the Arduino is powered by the BEC.
Anyway, nice job
Wich Arduino did you use?
Oops! your right, I posted the wrong diagram. That was my original intent. I'll have it updated in a few!

Quote:
Wich Arduino did you use?
Pro Micro, ATmega32U4 5V/16MHz Module


Edit: updated. Diagram above is correct now.

Last edited by drzoo2; 01-04-2015 at 02:01 PM.
drzoo2 is offline   Reply With Quote
Old 01-04-2015, 01:59 PM   #7
Newbie
 
Join Date: Oct 2012
Location: Cremona, Italy
Posts: 12
Default Re: Arduino based scale LED lighting - Wraith



Maybe you missed my question. Wich Arduino is it?
Salzig is offline   Reply With Quote
Old 01-04-2015, 02:01 PM   #8
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

Quote:
Originally Posted by Salzig View Post


Maybe you missed my question. Wich Arduino is it?
Yep, See above. Was trying to get the corect diagram up...
drzoo2 is offline   Reply With Quote
Old 01-04-2015, 02:09 PM   #9
Newbie
 
Join Date: Oct 2012
Location: Cremona, Italy
Posts: 12
Default Re: Arduino based scale LED lighting - Wraith

Thank you.
I want to do something similar.
Salzig is offline   Reply With Quote
Old 01-04-2015, 02:27 PM   #10
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

I have a few other wiring diagrams and some code written I'd be happy to let you start with. Just let me know and I'll post it up.
drzoo2 is offline   Reply With Quote
Old 01-05-2015, 11:15 AM   #11
Newbie
 
Join Date: Oct 2012
Location: Cremona, Italy
Posts: 12
Default Re: Arduino based scale LED lighting - Wraith

Many thanks.
I will write my own code, where's the fun otherwise?
Salzig is offline   Reply With Quote
Old 01-05-2015, 11:16 AM   #12
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

Don't blame ya.....

Good luck!
drzoo2 is offline   Reply With Quote
Old 01-17-2015, 06:43 PM   #13
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

A friend asked me to install this into his Wroncho. He runs his rig from a DX3C which allows for running the the aux channel (channel 3) as a 3 position switch. I eliminated the off function and left the ability to switch between "scale", "hazard" and "police" lighting.

I rewired the LED harness he had in the truck to allow for individual control.
Since this is a hard body and he obviously wants to remove it, I had to add a connector since the controller is stuffed into the old receiver box.










Video of the first test right after upoading code. The Controller, LEDs and receiver all are powered from the USB port. Makes it simple when testing code and tweaking.

Last edited by drzoo2; 01-20-2015 at 08:51 PM.
drzoo2 is offline   Reply With Quote
Old 01-20-2015, 08:44 PM   #14
Newbie
 
Join Date: Jan 2015
Location: Canada
Posts: 40
Default Re: Arduino based scale LED lighting - Wraith

Hehe

Nice work guys.

I use my Arduino's for doing crazy Stuff with my "kids" Nerf Guns.

Now I have more projects to keep me busy, and this one seems rather simple.

Thank for the write ups.

Star
Starlite033 is offline   Reply With Quote
Old 01-20-2015, 09:13 PM   #15
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

The Wroncho was slightly different than my Wraith in that it had a side marker LEDs that I also wanted to blink with the front and rear signals. I wired them together since these could technically be the same circuit. Also since I ran out of amber LEDs so I used white (painted orange) which meant I had to add the resistor at the LED vs at the PCB. The same color/manufacturer can generally be wired in parallel and will function as long as the forward voltage drop is the same.

I also has to be careful on my current draw from a single port. Each port is rated for 40mA with the entire Arduino rated for 200mA. Could have added a FET but it makes it that much more complicated to wire. I have some ideas how incorporate other components easily in later builds.



If anyone want to look at my code I have it here:
http://www.rczoony.com/drzoo2/Arduin...ler_Wraith.ino

http://www.rczoony.com/drzoo2/Arduin...er_Wroncho.ino

The Wroncho code is based on my Wraith code with some small port and function changes. This can be copied into the Arduino IDE and uploaded. Both posted diagrams should coincide with the posted code as far as port mappings and pinouts.

Also the code allows for a calibration routine that has to be ran at least once. This handles reverse channels and also allows for setting where the blinkers activate in the steering. For instance if you want the blinkers to come on at full lock or immediate after touching the steering.

Be kind, I'm a hardware guy with only a little programming experience.....

Last edited by drzoo2; 01-21-2015 at 08:59 PM.
drzoo2 is offline   Reply With Quote
Old 11-07-2015, 05:53 AM   #16
Quarry Creeper
 
Join Date: Jul 2015
Location: Hanover
Posts: 209
Default Re: Arduino based scale LED lighting - Wraith

Very nice.
I too was inspired.
I am prototyping one right now for myself, and those in our "club."

I studied your code for a while, and instead of making changes, I decided to start over. Nothing wrong with your code, just not what I wanted.

I made mine "self-calibrate."
The arduino reads the pulseIn inputs at power-on (void setup) and stores those as channel center, rather than writing to the EPROM, and doing an actual calibration.

Even though this is simpler, if one adjusts the Tx trims, or powers the 'duino before the Tx/Rx, the system will not work properly. I have no intentions of correcting this behavior at the moment.

I have no "turn signals" at all. Everyone in the "club" deems them silly, not "gonna use them on a trail..."
I added hazards that come on automatically after 5 seconds of inactivity, and cancel when the user performs a Th/St change.

I also added a "strobe-like" blink to indicate that there is no signal/signal out of bounds when read by the pulseIn code. That's more for troubleshooting/debugging. Not sure if I'll leave it...

I do plan on having "mode selection." Spetrum only allows an Aux Channel to have 3 positions. (not counting the Lin setting-that's silly for this application)
so, 3 modes it is.
I'm having trouble deciding what the three modes should be...

If anyone would like to see the code...
HANgOVER Airbrush RC is offline   Reply With Quote
Old 11-07-2015, 05:59 AM   #17
Quarry Creeper
 
Join Date: Jul 2015
Location: Hanover
Posts: 209
Default Re: Arduino based scale LED lighting - Wraith

---rather than edit my post---
4th paragraph- Even though this is simpler....
If the 'duino isn't powered on in the correct sequence, it just needs to be powered down and brought back up. But then, wouldn't a momentary push button wired to "reset" do the same thing?
I guess the question I am asking, upon pressing the "reset" button, does the 'duino read "void setup" again?
HANgOVER Airbrush RC is offline   Reply With Quote
Old 11-07-2015, 07:14 AM   #18
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

Quote:
Originally Posted by HANgOVER Airbrush RC View Post
I made mine "self-calibrate."
The arduino reads the pulseIn inputs at power-on (void setup) and stores those as channel center, rather than writing to the EPROM, and doing an actual calibration.
The calibrate function serves two purposes.
1) Like you intend to write, it averages center on every power on. These values are not stored permanently but are stuck into a variable when the Arduino is powered each time.
2) The stored location contains how the radio/servo is configured (forward/reverse). There is no way to know without user input as to servo/ESC direction.
ex: The radio setup for my SCX is such that both channel1 and channel2 are in the reverse direction. My Wraith only requires channel1 to be reverse but channel2 is set to forward.

The channel direction calibration is called when the steering is held fully in any direction within 5 seconds of power up. Its required once after initial electronics setup of the RC.

Quote:
I have no "turn signals" at all. Everyone in the "club" deems them silly, not "gonna use them on a trail..."
I added hazards that come on automatically after 5 seconds of inactivity, and cancel when the user performs a Th/St change.
Should make the code much simple to write. This is the hardest logic to get right.

Quote:
I also added a "strobe-like" blink to indicate that there is no signal/signal out of bounds when read by the pulseIn code. That's more for troubleshooting/debugging. Not sure if I'll leave it...
My latest code for my SCX build adds this too.

Quote:
I do plan on having "mode selection." Spetrum only allows an Aux Channel to have 3 positions. (not counting the Lin setting-that's silly for this application)
so, 3 modes it is.
I'm having trouble deciding what the three modes should be...
Coolest part about writing code. Functionality can be about anything you want.


Quote:
I guess the question I am asking, upon pressing the "reset" button, does the 'duino read "void setup" again?
Yes. It resets similar to a cold boot.

I started working on a new code base that uses interrupt timing to read and set pins vs. the built in Arduino functions, pulseIn() and delay(). These work great when starting out and get you into coding. The issue with them is they are blocking. Meaning the main loop stops when these are called. If not careful they can add a lot of timing errors that cause issues with reading and writing pins. Interrupt based means the loop runs continuously and only makes changes when something happens. It uses timers to determine pulse widths and delays. I have yet to finish it. It's on my todo list for this winter.
drzoo2 is offline   Reply With Quote
Old 11-08-2015, 11:40 AM   #19
Quarry Creeper
 
Join Date: Jul 2015
Location: Hanover
Posts: 209
Default Re: Arduino based scale LED lighting - Wraith

I thought my intentions were written clearly enough. lol.

By "self-calibrate" I mean that there is "no calibrate."

In the arduino's set up, it reads the PWM from the receiver.
I then stores that reading as a constant, assuming that is "center channel"

I then have two other constants (dbLO and dbHI) which are the calculated deadband for that channel. I simply multiply the the channel's center reading by 1.05 (dbHI) and .95 (dbLO.)

Since I am not using turn signals there is no reason for me to incorporate any channel reversing or direction. (making that part of the code much easier to write ;) )

The trickiest part was setting up the "inactivity" timer...

Thanks for the reply on the "reset" pin.

I may end up using that because the way my program works, if the user adjusts Tx trims or powers up in the wrong sequence, my code isn't smart enough to know any better....

Another "problem" I have is that there is no hysteresis when a channel changes states. For example, if the throttle channel is at the edge of changing states, the output may fluctuate rapidly, making the system seem "glitchy."
Is that the reason you are "averaging" your inputs?
HANgOVER Airbrush RC is offline   Reply With Quote
Old 11-08-2015, 11:50 AM   #20
Quarry Creeper
 
Join Date: Oct 2014
Location: East
Posts: 232
Default Re: Arduino based scale LED lighting - Wraith

The average is not really needed. When calculating the dead band, I took multiple center readings. I don't think it's required as the signal is pretty steady.

Honestly, I haven't seen the need to add hysteresis. I may in future code but it hasn't been a problem in my application.

Also my latest code, when the receiver is switched off and back on, I call the calibration routine. That way, I don't have to use a reset switch or cold boot the board to recenter

Sent from my XT1575 using Tapatalk

Last edited by drzoo2; 11-08-2015 at 11:56 AM.
drzoo2 is offline   Reply With Quote
Reply



Arduino based scale LED lighting - Wraith - Similar Threads
Thread Thread Starter Forum Replies Last Post
Led lighting craddock35 Electronics 2 07-13-2013 02:29 PM
LED Lighting Help juswin24 Electronics 7 09-03-2012 07:55 PM
LED Lighting? Drey Electronics 5 01-19-2010 03:17 PM
Scale seats and LED roof lighting washracer_11 Newbie General 12 12-08-2008 05:43 PM
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -6. The time now is 03:02 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO ©2011, Crawlability, Inc.
Copyright 2004-2014 RCCrawler.com