Yet Another Build Log (YABL) - Part 4 - Sonarrific



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_MaxsonarLV


Compile 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!

Views: 1467

Tags: ArduCopter, ArduPirates, EZ0, EZ4, LV, Maxbotix, XL, altitude, hold, rangefinder, More…sonar

Comment by Darren on April 25, 2011 at 2:58pm

I think you need to leave the ring behind... is that so hard?

 

(smile)

Comment by Ante Vukorepa on April 25, 2011 at 3:22pm

LOL :)


3D Robotics
Comment by Chris Anderson on April 25, 2011 at 3:56pm
Love this! You shoot the BEST photos! What camera are you using?
Comment by Ante Vukorepa on April 25, 2011 at 4:29pm

Thanks a lot!

They were taken with an Olympus PEN E-P1 (except for the headers, that was iPhone 4).

I use the PEN as an everyday/snapshot camera. Canon 1DS Mark II is my main, "serious business" camera :)


Developer
Comment by Randy on April 25, 2011 at 5:01pm
Re the comment on the XL vs LV mix-up, someone else also reported that.  I swear they use to be different, one was essentially the reverse of the other.  I.e. as you got closer the voltage went up on one, and down on the other.  In any case, I'll add that to my list to fix.
Comment by Michael Zaffuto on April 25, 2011 at 8:15pm

I couldn't help but notice the very nice AMANI GT CPLD Arduino Shield

(http://majolsurf.net/wordpress/?p=1529) in your parts bin...very nice... ;)

Do you have any interesting plans for it?

Comment by ARHEXA on April 25, 2011 at 10:31pm

great pics.

so the EZ4 has more range than the EZ0 ?

i'd like to order one, but i really want the longest range possible.

and how is the range of the XL ? longer than both LV ? it's just 15$ more and if it has much more range it worth it,

does the arducopter know to 'use' the long range of the better sonars ? or after certain distance it switches to gps altitude anyways ?


JDrones
Comment by Jani Hirvinen on April 26, 2011 at 2:17am

Yeah great looking pictures Ante. As we use precision CNC machines to make those mounts they are all identical and not sure if Maxbotix uses hand placement or not but nicely done with the hexa spacer. Just like it was meant to be, this is DIY community at it's best.

 

As you also noticed, you can mount it in various places under ArduCopter frame. For the connecting cable, we now have nice 24 cm long 3 pin Sonar Cable in store too. 

 

With this cable you don't need to have 90° connector on sonar. Just solder cable directly to it and then have 90° header in IMU board. Another 3 grams saved weight.

 

@AR Range for EZ0 and EZ4 is about the same it's just width of the beam that changes. EZ4 has narrow beam and EZ0 is really wide. Wider beam is better if you fly over soft surfaces like grass etc.

 

LV and XL then have a different range. But they are all really good for their purposes.

 

 

Comment by ARHEXA on April 26, 2011 at 2:40am

Thanks Jani,

could you tell please what is the LV range VS the XL range ?

and does the arducopter knows to use the longer distance of the XL ?

I'm gonna need precision altitude stability as high from ground as possible.

 

if i fly over different surfaces, asphalt, sand, grass, rocks etc... i better go with the EZ0 wide beam ?


JDrones
Comment by Jani Hirvinen on April 26, 2011 at 2:51am

ArduCopter does not know if you are using XL or LV. It just relies on output what those are giving. ArduCopterMega supports both sonars for other ArduCopter software's we do not know but most of them are based on our libraries so they should work ok too.

 

If you want as high as possible altitude, take XL due it's range is almost double compared to LV. As said LV works well too. After 5-6 meters it does not matter so much anyways because we can start rely on pressure sensor.

 

The most important accuracy is on low altitudes anyways... Just like if you plan to take a picture from house, you will take picture from around 60-100m of alt, if baro/gps can hold you within 5 meters it is still really accurate and you don't see the difference on that.

 

 

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Groups

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service