I've originally meant to write about propeller mounting, tracking, tightening and about my first flight (which ended up with a stripped spinner nut), but since my sonar arrived and, since installation wasn't exactly 100% straightforward, that's today's subject. So, here it is, in the photo above - the Maxbotix LV-EZ4 sonar, freshly taken out of it's zip-lock baggy, along with a 5 pin header. Which is not included. That's from my own header stash. NOBODY TOUCHES MY PRECIOUSES! *cough*Why 5 pins? Because that's the minimum of pins that spans from the GND and +5V/+3.3V on one side of the header and the analogue out on the other. Why pins at all (instead of soldering the cable directly)? Because i want it to be easily replaceable and detachable, in case i want to experiment with it off the ArduCopter. Why EZ4 and not EZ0? Because i thought its beam pattern makes more sense for this particular application:Narrowest and shortest beam for tiny objects. Longest and widest beam for large, uniform objects (i.e. ground). Why LV and not XL? Because it's cheaper and my Arduino/electronics/RC/'copter budget's running thin at the moment. Otherwise, XL probably would've been a much better choice.Anyways. I've bought it from jDrones along with their little sonar mounting kit, just because i was too lazy to figure out / improvise my own way to mount it. And because it looked neat. However, first test fit ended up like this...Mmmyeah. It would appear Maxbotix' tolerances are much looser than the margins jDrones left when designing the mount. The transducer casing isn't quite mounted at the center. Unsoldering it isn't an option, since it's epoxied to the board, so...... a few seconds of nylon spacer dremeling later (sandpaper works too, but i'm lazy):Much neater. Now for the header. Here's a simple little trick for soldering headers (and connectors and other components) i've learned from FreakLabs. First flip the board and add a dab (and i really mean a dab) of solder to one of the holes:Important tip! Never ever do this with the GND hole! They're usually connected to a rather biggish ground plane, which can soak up a lot of heat. Doing that might leave you with a plugged hole you'll have a really hard time sucking the solder from. Trust me, i've been there! Okay. Now. Take the header and press it against the holes:Mind your finger! Don't put it on the pin that's against the soldered-up hole or you might get a burn in the next step. Which is - apply heat to the hole and push the header through simultaneously:Trim the leads as short as you can - you want the board to be as flat as possible:Now just solder the rest of the pins (and reflow the first one). Don't be stingy on the solder, after it fills up the hole (through to the other side), it won't accumulate any further and will just remain on the soldering iron. And there we go, nice and flat:The baggy that comes with the sonar mount kit contains a bit more hardware (can nylon be called hardware?) than is needed for the installation. Here's what is needed to install it on the bottom of the ArduCopter:The sonar PCB is flat... ish... but still not flat, so it's a good idea to use some washers:... and there we go, nice and neat:Now. Where to put it? From the hole distance, i'd say it was meant to be put smack dab in the middle of one of the main plate vertices, like this:... however, if you put it there, there will be no room for the battery and it will have to be mounted off-center, shifting the center of gravity quite a bit. Plus, it looks bad and interferes with access to the battery when you want to take it off / put it back. It turns out there are other two holes that fit the distance perfectly and don't obstruct the battery footprint:You'll have to unscrew one of the nuts that clamp the arm. If you've got an ESC right above the corresponding bolt (like i did), you'll have to remove it, and mount it back when you're finished. One of the long spacers from the sonar mount kit will serve as the new nut. That also means you'll have to put the nut on the other side of the spacer (instead of a bolt). Here's the end result:The only thing left now is to fashion a cable to hook the sonar up to the Oilpan pitot tube input. I've again made the same set of make-shift female header connectors as before. The sequence of the pins on the sonar is exactly the same as the sequence on the Oilpan - GND is the leftmost (when facing the front of the APM or the vertex of the sonar PCB with the pin header), then 5V, then analogue out/in.The only thing left now is to enable the sonar in software. I'm using ArduPirates branch. First, let's check if it works correctly. Navigate to Libraries/AP_RangeFinder/examples/AP_RangeFinder_test and open the AP_RangeFinder_test.pde sketch. There are two lines of interest here:AP_RangeFinder_MaxsonarXL aRF;//AP_RangeFinder_MaxsonarLV aRF;Now, it would seem logical to comment the first line and uncomment the second if you have an LV model. However, it so turns out that the LV model uses the exact same scaling on the analogue output as the XL, at least in my case. Whether it's something that has recently changed, or something mixed something up, i do not know. I do know that my sonar most definitely is an LV model and that it outputs correct values with the XL routines, NOT the LV routines. To be sure, leave it like this, run the sketch and check the output on the serial monitor, then change it to the other option and do the same. That should make it absolutely clear which one is the correct one.The first number is the real distance/altitude, the second is the raw output. For XL (and my LV), both numbers are the same, because the absolute output of the sonar board is scaled so that they're exactly proportionate and equal with a reference voltage of 5V.After you've verified your sonar works and you've determined the correct sonar reading routines to use, pay a visit to Config.h in the main ArduPirates sketch folder and set the two lines at approx. 251-252 (it's around line 65 for ArduCopterNG code branch) to:#define UseBMP // Use pressure sensor for altitude hold (default) ?#define IsSONAR // or are we using a Sonar for altitude hold?Next up, open ArduPiratesNG.pde, find the following lines at approx. 90-91 (around the line 228 for ArduCopterNG) and uncomment the appropriate one, depending on the result of your test sketch output:AP_RangeFinder_MaxsonarXL AP_RangeFinder_down; // Default sonar for altitude hold//AP_RangeFinder_MaxsonarLV AP_RangeFinder_down; // Alternative sonar is AP_RangeFinder_MaxsonarLVCompile and upload the code, switch to CLI mode and check the sonar PID values by pressing 'o'. According to defaults and the wiki, good values for the stock ArduCopter hardware should be P=0.8, I=0.3, D=0.7.That's all, folks (for now)!And a belated happy Easter!
Someone asked about the magneto (or lack of it) in my previous post, so here's the reason it was absent…
I could've just soldered the cable on, but figured i might want to use it for other Arduino projects occasionally. This makes it a much simpler task:
Word of advice: don't push the pins all the way down when soldering, or they'll stick out too much from the bottom of the magneto PCB (it's pretty thin) and you won't be able to mount it flat on the carrier plate. Oh, and G on the plug stands for GND. Anyways, let's move on. Ever noticed how the ArduCopter frame's GPS carrier plate and dome center come with two M3 screws, but *four* M3 nuts? Ever wondered why?
Mmmm. Bendy. Here it is with four nuts:
Much better. As i was about to put the dome and legs on my ArduCopter, i found another thing off. Can anyone spot what's wrong with this picture?
That's right, i can't plug the USB in the IMU. The standoff is in the way. I'm an idiot and have to unscrew everything again. Yay… Here's the wrong way to mount the APM/IMU sandwich (smack dab in the middle of the carrier plate on both axes):
… and here's the right way (moved one hole towards the front):
Oh, by the by, do not tighten the nuts on the upper carrier board. Leave them slightly loose. Why? So you can do this:
… when you want to take the upper board off (to access the APM/IMU). Unscrewing the standoffs is much easier than unscrewing the nuts, plus, it doesn't require any tools.
Speaking of tightening, careful with those plastic screws. They crack like eggshell. The moment it goes "crick" the first time, it's tight enough. Here's how, where and why they crack:
As you'd have probably guessed by now, i'm a heat-shrink tubing junkie. As far as i'm concerned, it's the best and most convenient thing since sliced bread. It makes mess not look like mess, it protects and isolates, it marks and identifies… I can never have too much of it.
Or can i?
Turns out i can. Because it also makes cables rigid. Which leads me to the first no-no of arducopter frame-building. This:
… seemed like a good idea at the time (bright yellow makes the battery cable easy to spot when i'm plugging/unplugging it in a hurry), but makes my life miserable every time i try to plug the battery in, because the heat-shrink tubing keeps trying to straighten the cable out when i want it to curve underneath the ArduCopter main plate. Re-heating it while keeping the cable curved helped somewhat, but in retrospect, it could've done without it.
On the other hand, here:
… the rigidness turned out to be useful, because it keeps the PDB<->RX connectors neatly grouped and packed together so i can unplug/plug them into the receiver all at once. Finally, motor mount LED covers. I didn't get any with my ArduCopter frame kit. Because, apparently, they don't come with version 1.0 (despite there being a hole in the motormounts for the LED, which is kinda daft, but oh well).
So i've decided to make my own, with stuff i had lying around. Sawing isn't my thing, plus, i didn't have any scrap PCBs to saw. Plus, white and red LEDs shining through a green or yellow PCB? Yish.
I did, however, have this:
It's a plastic pad meant for furniture. Obviously, the two plugs are a nuisance and the whole thing is much wider than the motor mount, but otherwise, it looks like precisely the thing i need. So:
… from one came many. Well, two. The color makes for a somewhat jarring contrast on black arms, but hey - it does its job:
It's a dedicated video (PAL or NTSC) Arduino shield with passthrough capabilities. Nothing fancy, just a sync separator and some passive electronics. Obviously, it needs to be mated with an Arduino (additional one, alongside APM, of course), but it's plug and play and comes with a neatly put together library. Question is, can this + Arduino physically fit an average ArduCopter?
If so, it might be the ticket to beginner's quad computer vision experimentation (plus, you get an OSD generator extra ;) on the cheap ($50ish + camera).
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.
Hiya, folks! First of all, if you're sick and tired of looking at Arducopter official frame builds, you might decide to skip the whole post right about now ;)
Yes, it really is going to be just another ArduCopter build (my first quad, actually), but i hope people doing the same can learn from some of my mistakes and, perhaps, avoid them. So let's get on with the show, shall we...
Since i've been having some pretty nasty vibration issues with a traditional heli i've been messing with for the past 3-4 years, i felt somewhat queasy about just straight on mounting the motors to the holders. I've originally intended to pad both contact planes of the arms with foam, but decided i'm being too OCD about it and did just this:
It looks like (and is actually billed as) a two-sided sticky tape, but is really a transparent gel used for mounting things on uneven surfaces (i.e. a mailbox to a wall). Like a permanently non-setting hotglue that's not really hot. Okay, you got me, it's really nothing like hotglue.
The thinner variants usually have higher strength (20kg/m), while the thicker one (1mm) i've used has lower (10kg/m). But since i'm not actually using it to bear any weight, thickness is all i'm interested in. Here's what it looks like from the other side:
How well does it work? From my initial tests - surprisingly well. It filters the high frequency buzzzzz vibe from the engines pretty nicely. Without it, you could clearly feel it at the end of the arms. With it, it's nearly all gone, except at lowest RPMs. I'm now considering padding the screw holes with it as well (punching through it with a screw, like through a washer).
Coming up next: devising a semi-permanent, practical way to hook up motor mount LEDs to the A8-A14 ports of the IMU shield.