_4071776.jpg

Since the current ArduPirates code (as you all probably know) supports LEDs not only as a navigation aid, but as a status indicator as well, and since i had nothing better to do while i was waiting for a replacement ESC (one of the four i got turned out to be faulty) i've decided to install them in the jDrones' motor mounts.

Now, i could've just pulled two wires from each motor mount, crimp some female connectors to them and plug them in the OUT4-OUT7 ports, but i thought that's a rather inelegant solution, because:
a) i didn't want to use up the (precious) PWM outputs,
b) according to what i've read, A8, A10, A12 and A14 were to be dedicated as LED ports in the future anyways, and
c) i wanted something neater and easier to plug/unplug every time i remove the APM from the frame.

So here's what i came up with...
Since i couldn't solder pins to the topside of the Oilpan, i've soldered a ribbon cable to A8, A10, A12, A14 and the nearby GND:

_4041742.jpg

I've tacked the ribbon to the side of the Oilpan's headers with the same gel tape i've used to dampen the motor vibrations, as stress relief. I've cut a female header to size (it was an 8-pin one, i think), soldered the ribbon to its pins, heat-shrink wrapped the individual pins:

_4041737.jpg

Some more heat shrink tubing and... voila! A nice custom 5-pin female connector:

_4041739.jpg
_4041744.jpg

Next came the male side. Using pin headers, of course.

I've initially intended to connect the LEDs directly to GPIO ports. Atmega 1280 limits the current per pin to 40mA and the LEDs i've been using can withstand that just fine (they are rated for 20mA, but don't heat up much at 40mA and the LED emitter die seems stable enough), plus, i've been driving things at max current from Arduino pins numerous times without any repercussions, however...

1) I'm not prepared to risk having electronics that drive a 1+ kg object containing fast-spinning parts burn out for a few brighter blinkenlichts,
2) The LEDs will probably last longer at 20mA and
3) 4x40 mA = 160 mA, while the maximum an Atmega 1280 can source at any given time is 200 mA - not much headroom left, right?

After a bit of rummaging through my drawers, i found a bunch of tiny 22 Ohm metal film resistors, which, as it turns out, results in almost exactly 20mA going through the LED in series. Much better. I've soldered them directly to the pin header:

_4041747.jpg
... soldered an 8 pin ribbon cable to that (with the 4 LED cathode wires soldered together to the last pin) and wrapped it all:

_4041749.jpg

... then put some heat-shrink tubing on that and - there we go, a male connector done:

_4041754.jpg

The ribbon cable splits into 4 two-wire cables that go through the arms (alongside the motor wires) and end in this:

_4041751.jpg
It's a good idea to key the connectors somehow. Not because you can fry anything (you can't in this particular case) but because it saves you the joy of assembling the whole quad and then realising you plugged the LEDs in wrong. So, sharpie:

_4041755.jpg

Good idea to key the other side too. Because, if you're like me, you'll inevitably end up having the cable hooked up the exact opposite way around from the one you've marked, once you build the frame.
With hardware side fixed, time to configure the software. The relevant entries are located in Config.h and Arducopter.h.First, in Config.h, the line:#define IsAM // Do we have motormount LEDs. AM = Atraction Mode... needs to be uncommented.In Arducopter.h, the relevant parts begin around line 100, and should look like this:/*#define FR_LED 3 // Mega PE4 pin, OUT7#define RE_LED 2 // Mega PE5 pin, OUT6#define RI_LED 7 // Mega PH4 pin, OUT5#define LE_LED 8 // Mega PH5 pin, OUT4*/#define FR_LED AN10 // Mega PE4 pin, OUT7#define RE_LED AN8 // Mega PE5 pin, OUT6#define RI_LED AN12 // Mega PH4 pin, OUT5#define LE_LED AN14 // Mega PH5 pin, OUT4You might notice i've got the AN8-AN14 ports out of order here. It's because i've (stupidly) wired them in reverse, compared to how they are by default in the current ArduPirates code.Coming up next: What *not* to do when assembling the frame.
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Sorry for the late replies, been over my head in work lately and completely out of the DIYdrones loop.

    Honestly, don't have a clue, haven't even seen the new code (2.x) nor the Mission Planner.
    But i intend to, as soon as i manage to find some free time and catch a breath :) 

  • where is this code supposed to go if using mission planner. found code in defines.h but im not sure thats the same thing.

  • Nice Job!  Love the functionality, but I'm just starting out, and am using the Mission Planner 100% to config and download.  Any way to make this work in that environment?

  • Thought so, was just checking.
    Thanks!
  • Developer

    Ante, PWM needs always Timers and most of timers are already in use also CPU usage is rather high already so having extra tricks to run PWM leds would most probably kill it.

     

    Blink is more efficient on dark sky.

  • Thanks for the kind comments, everyone :)

    @Chris Paul - Oh, you should see what the end product looks like. It's a rat's nest of (heat shrink wrapped) cabling. I didn't want to cut the cables down (in case i decide to move them to a different frame some time in the future), so there's too much of it running around and making a mess.

    @I.S. - Magneto, GPS and the dome weren't present for the shooting ;)
    Didn't want to solder the cable to the magnetometer, in case i want to take it off, hook it up to an Arduino and play with it occasionally. So i've made it a heat shrink connector thingy as well.

    @Jani - How feasible would soft PWM be on AN ports? That is, how much CPU would it eat and how fast does the main loop run?
  • Developer

    That's the way how I planned it, nice to see someone else is also starting to use them.

     

    Yes original ArducopterNG code was using OUT4-7 for driving LEDs due it was easy to use those and on that time we had them all free. Now that we have hexa setups and camera systems coming. We had to move them out from normal OUTpins to those AN ports.

     

    ACM will support LED's on AN ports and LED's will have many different meanings in future releases.

     

    Nice catch Ante :)

  • Nice good and clean Tom 
  • @Chris

    +1

    @Ante

    Really nice! Congratz

    No magneto?

  • Wow ante.  Thanks for posting this.  I look forward to the next.  I'm just in the process of building my ArduCopter now, and you have inspired me.  Nice work with the heat shrink too.  Very clean.  Looks like I'm gonna have to clean my red-neck lookin' electrical tape contraption up a bit :)
This reply was deleted.