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!
Comments
Hi everyone, we saw a comment in this thread where a few of you had asked about the maximum range of the LV and XL ultrasonic sensors we offer. I figured I would quickly post some of the relevant information to answer these questions.
The maximum range reported by the LV-EZ sensors is 254 inches or (645 cm)
The maximum range reported by the XL-EZ sensors is (300 inches) or 765 cm
The maximum range reported by the XL-EZL sensors is (420 inches) or 1068 cm
It is important to note that each of these units has different scaling on the analog voltage output pins. (This is done to support the increased range information)
Range to a given size target can be found by referencing the sensor beam patterns, a composite image of the LV beam patterns is available here: http://www.maxbotix.com/articles/003.htm and for the XL's go here: http://www.maxbotix.com/articles/008.htm
If you have any questions, please let me know.
Best regards,
Scott Wielenberg
Technical Support & Sales
of MaxBotix Inc.
Phone: (218) 454-0766
Fax: (218) 454-0768
Email: scott@maxbotix.com
Web: www.maxbotix.com
Follow us on Facebook at: http://www.facebook.com/pages/MaxBotix-Inc/125159384204938
cjm
I have done some readings with a multimeter.
I pointed to the proximity and read near 0V, then pointed to the ceiling and measured about 816mv so doing the conversion 9.18mV/inch is about 83inch = 211cm which looks reasonable.
So it seems like the sensor works ok.
Any suggestions from the code gurus?
Nice catch :)
It's not a bad soldered, it's just that the solder hasn't flown all the way through to the top-side of the board (the pins are soldered from the other side and there's plenty of solder there). And the reason it hasn't is that it's a ground hole.
Ground holes generally have a tendency to wick less solder in them, because they don't heat up uniformly throughout the whole through-hole, which is due to one side typically being a part of a larger ground plane which draws the heat away. If you look carefully, the telemetry port's ground pin is the same way.
@Ante, Nice photos, your build logs are excellent. In the last photo here it looks like one of your RA Header pins to the pitot connections isn't soldered properly, but it may just be the photo.
Rob
just to be clear, where I am:
ArduCopterMega 2.0.23
LV EZ4 sonar
about constant 340cm reading on test/sonar on CLI
I've been reading the datasheet and have to do some tests with a multimeter to figure out if the sensor is working properly, when I have time (whenever is that) I will post my results.
Any other one with sonar problems?
Didn't even have time to check ACM2 out.
@Ante
Very nice post.
I have just installedLV EZ4 sonar, enabled it on ACM2 .23 and do the Sonar test on CLI.
It gives me about 340cm reading all the time no matter how far from the floor the sensor is.
Have you tested your sonar on ACM2?
@Michael Zaffuto - I love that shield :)
So far, haven't used it for much besides basics (shift register, PWM), but keep planning to try out the sonar rangefinder project from Eric's page and then expand it a bit (i've got a dozen of ultrasonic transducers and some op-amps i've bought for that sole purpose). Work and ArduCopter keep interfering and i have a thesis i really should be working on ;)
@ Jani - Oh, i've got a bunch of three-wire cables very similar to that one, but didn't want to chop them up. Plus, this way, i can take the sonar off the ArduCopter and plug it into a breadboard if i ever want to experiment with it (90 degree header means it's conveniently directed forwards in that case :)
Re: EZ0 vs. EZ4 - thing i found important in the datasheets is, EZ4's detection pattern is narrower and shorter the smaller the object you're bouncing the echo off from. I.e. small protruding objects that might be near the arducopter (a branch, a loose wire, battery's velcro) will likely be ignored in favour of the big, fat and flat target that's the ground below. That's why i chose it. I might be completely off in my reasoning, though. And i haven't tested how it works with grass yet (but it does give off a nice and solid bounce off carpets).
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.