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:
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:
Some more heat shrink tubing and... voila! A nice custom 5-pin female connector:
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:
... soldered an 8 pin ribbon cable to that (with the 4 LED cathode wires soldered together to the last pin) and wrapped it all:
... then put some heat-shrink tubing on that and - there we go, a male connector done:
The ribbon cable splits into 4 two-wire cables that go through the arms (alongside the motor wires) and end in this:
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:
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.