Someone please help me with sonar

Post Reply
ajmoore0351
Posts: 3
Joined: Thu Feb 26, 2015 4:09 am

Someone please help me with sonar

Post by ajmoore0351 »

Hello,

I have been trying for two weeks to get sonar to work and have gotten basically nowhere. I am using a HK MultiWii Pro board, and have tried both HC-SR40 and SRF08 sensors. I have tried probably 30 different versions of firmware, and searched high and low for an answer. With the HC-SR40, I could not get it to turn on at all. With the SRF08, I get a single red light on startup and nothing. I have checked voltage across each of the SRF08 pins. The +5V is at roughly 4.9, while the scl and sda are at about 3.3. I am losing my mind, and would appreciate any and all help.

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Someone please help me with sonar

Post by QuadBow »

Have you enabled the sonar in the file config.h?

Code: Select all

/* Sonar */// for visualization purpose currently - no control code behind
//#define SRF02 // use the Devantech SRF i2c sensors
#define SRF08
//#define SRF10
//#define SRF23

ajmoore0351
Posts: 3
Joined: Thu Feb 26, 2015 4:09 am

Re: Someone please help me with sonar

Post by ajmoore0351 »

Yes, I have. When I do that, the SRF08 blinks once on startup and that's it. How do I tell if it's working? How do I encorporate it into altitude hold?

TheBum
Posts: 35
Joined: Wed Dec 03, 2014 9:53 pm

Re: Someone please help me with sonar

Post by TheBum »

ajmoore0351 wrote:How do I encorporate it into altitude hold?

Based on the comment at the top of that code block, you can't. Sonar poses a lot of challenges, not the least of which is scattering when flown over grass. I'm not surprised it hasn't been incorporated in the control loop yet.

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Someone please help me with sonar

Post by QuadBow »

TheBum wrote:Sonar poses a lot of challenges,
This is true for the simple sonar devices. But, we are talking about the SRF08, which is an i2c device. The only challenge is to send one i2c command and retrieve the result back.

TheBum wrote:I'm not surprised it hasn't been incorporated in the control loop yet.
It has been incorporated since at least MW 2.2!

ajmoore0351 wrote:How do I tell if it's working?
I am sure, it is working you can test it by looking after the following lines in the file multiwii.cpp:

Code: Select all

        #if SONAR
          Sonar_update();
        #endif

and change it by adding one additional line:

Code: Select all

        #if SONAR
          Sonar_update();
          debug[0] = sonarAlt;
        #endif

This makes multiwii to write the result of the sonar into the debug field at the lower left hand corner of multiwiiconf.

ajmoore0351 wrote:How do I encorporate it into altitude hold?
Since the sonar device works only for heights less than 2 meters, it is not included into the control loop. It is used only in the file alarm.cpp for the landing lights. So, if you are close enough to the ground landing lights are switched on. That's it!

ajmoore0351
Posts: 3
Joined: Thu Feb 26, 2015 4:09 am

Re: Someone please help me with sonar

Post by ajmoore0351 »

I have put the extra line of code in for debugging, but nothing shows up in multiwii conf. I toggled each of the debug fields on and off, but I get nothing.

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Someone please help me with sonar

Post by QuadBow »

Have you got a clean multiwii distribution?

Have you got a 3,3V-board? They could cause issues when running 5V sensors like the SRF08. Maybe you need a level converter.

What about the default address of the device? SRF08_SENSOR_FIRST is 0xF0 - that should be the address of your device, as well. There are devices with 0xE0. Just try that.

The LED should flash when measuring. So, there is really no operation ongoing.

Post Reply