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 http://www.rczoony.com/wp-content/up...4123049566.jpg 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. http://www.rczoony.com/wp-content/up...1501033887.jpg http://www.rczoony.com/wp-content/up...1501039816.jpg 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. http://www.rczoony.com/wp-content/up...1501031848.jpg Here's the mess of wiring I was left to deal with after running it to the rear. http://www.rczoony.com/wp-content/up...5010339603.jpg 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. http://www.rczoony.com/wp-content/up...5010325632.jpg http://www.rczoony.com/wp-content/up...0150103205.jpg It's a bit of a mess in the box but access for programming isn't too bad. http://www.rczoony.com/wp-content/up...5010337210.jpg 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 <iframe width="560" height="315" src="//www.youtube.com/embed/IE5sMlP9HfQ" frameborder="0" allowfullscreen></iframe> |
Re: Arduino based scale LED lighting - Wraith That's a really cool setup |
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 |
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. http://www.rczoony.com/drzoo2/web/Wraith.png 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. |
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 "thumbsup" Wich Arduino did you use? |
Re: Arduino based scale LED lighting - Wraith Quote:
Quote:
http://i00.i.aliimg.com/wsphoto/v3/1...pg_220x220.jpg Edit: updated. Diagram above is correct now. |
Re: Arduino based scale LED lighting - Wraith "thumbsup" Maybe you missed my question. Wich Arduino is it? |
Re: Arduino based scale LED lighting - Wraith Quote:
|
Re: Arduino based scale LED lighting - Wraith Thank you. I want to do something similar. |
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. |
Re: Arduino based scale LED lighting - Wraith Many thanks. I will write my own code, where's the fun otherwise? ;-) |
Re: Arduino based scale LED lighting - Wraith Don't blame ya..... Good luck! |
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. http://www.rczoony.com/wp-content/up...5011520974.jpg http://www.rczoony.com/wp-content/up...5011526100.jpg http://www.rczoony.com/wp-content/up...5011535718.jpg http://www.rczoony.com/wp-content/up...5011542973.jpg http://www.rczoony.com/wp-content/up...5011530748.jpg 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. <iframe width="560" height="315" src="//www.youtube.com/embed/dvyHtzvDrmU" frameborder="0" allowfullscreen></iframe> |
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 |
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. http://www.rczoony.com/drzoo2/web/Wroncho.png 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..... |
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... |
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? |
Re: Arduino based scale LED lighting - Wraith Quote:
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:
Quote:
Quote:
Quote:
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. |
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? |
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 |
All times are GMT -6. The time now is 11:39 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