baseflight + SONAR

Post Reply
User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

baseflight + SONAR

Post by treym »

hello,

Here it is a nazePro , but the code work the same for the naze with the hcsr04 sonar [1]

the sonar is for low altitude , you still need a baro for anything 3 meters above the ground.







https://github.com/multiwii/baseflight/ ... ors.c#L449

for now the configuration is hardcoded to use the rc pin 7 and 8 , only 3.3v ( add a 1K Ohms resistor ) :
trigger_pin =rc pin 7
echo_pin = rc pin 8


You can also connect the hcsr04 sonar using the motor pin 4 and 5 ( 5v tolerant )
trigger_pin = motor 5
echo_pin = motor 6

please see : https://github.com/multiwii/baseflight/ ... v_hcsr04.c
Last edited by treym on Mon Jun 30, 2014 11:44 am, edited 3 times in total.

User avatar
Dilbert66
Posts: 45
Joined: Fri Apr 04, 2014 6:09 pm

Re: baseflight + SONAR

Post by Dilbert66 »

Nice work treym. A quad yoyo :)

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: baseflight + SONAR

Post by treym »

he he , i have updated the previous video with oudoor footage that reflect the current sonar status :geek:

alistairr
Posts: 51
Joined: Thu Sep 26, 2013 10:30 am

Re: baseflight + SONAR

Post by alistairr »

Nice work
Which sonar module is this using?

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: baseflight + SONAR

Post by treym »

test were conducted with the hcsr04 .

dzwiss
Posts: 3
Joined: Sat Jun 21, 2014 6:21 pm

Re: baseflight + SONAR

Post by dzwiss »

I would like to put this in my miniH...can you tell me how you have this connected and mounted to Naze32...and if this is set up using baseflight configurator? Any precautions I need to know? A step by step setup would be greatly appreciated. Info is greatly limited and perhaps old regarding this.

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: baseflight + SONAR

Post by treym »

hi,

the code is not yet in the main firmware , so you need to build the code by yourself : https://github.com/multiwii/baseflight/pull/128

for connecting an hcsr04 sonar to the naze , please refers to the https://github.com/multiwii/baseflight/ ... sr04.c#L66

you also need to activate the feature sonar in the command line interface .

io53
Posts: 10
Joined: Sun Jun 08, 2014 4:57 pm

Post by io53 »

Is it possible to change the pin for those of us who are using dev boards with plenty of pins available?

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: baseflight + SONAR

Post by treym »

yes, there is no obvious reason that could prevent using different pins for connecting this sonar

alistairr
Posts: 51
Joined: Thu Sep 26, 2013 10:30 am

Re: baseflight + SONAR

Post by alistairr »

Just looking at the branch on git hub. Has this been merged into main base flight?

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: baseflight + SONAR

Post by timecop »

It has been about 2 hours ago,

alistairr
Posts: 51
Joined: Thu Sep 26, 2013 10:30 am

Re: baseflight + SONAR

Post by alistairr »

Very Cool :mrgreen: :mrgreen: :mrgreen:

scrat
Posts: 925
Joined: Mon Oct 15, 2012 9:47 am
Location: Slovenia

Re: baseflight + SONAR

Post by scrat »

So. Where to connect sonar on rev5 board? :)

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: baseflight + SONAR

Post by treym »

rc pin 7 and 8

or

motor pin 5 and 6


I have added some information in the first post

dzwiss
Posts: 3
Joined: Sat Jun 21, 2014 6:21 pm

Re: baseflight + SONAR

Post by dzwiss »

Thank you very much for this! Good work!

User avatar
Crashpilot1000
Posts: 631
Joined: Tue Apr 03, 2012 7:38 pm

Re: baseflight + SONAR

Post by Crashpilot1000 »

Thanks for actually putting Sonar to work in BF! But I don't know why it is necessary to have a baro hight limit like arducopter for the sonar to work (magic 3m?). Sonar does distance measuring not absolute hight so it is very useful for roof inspections to keep a constant distance from it (aka not crashing into it).

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: baseflight + SONAR

Post by treym »

3m is the max range of the hc-sr04 sonar , nothing magic :)

this has to autodetected to accommodate other sensors , further improvement ....



as for roof inspection , thats might be a nice feat .. but would require a max alt limitation , just in case there is a opening in the roof :D

ruffster
Posts: 16
Joined: Wed Sep 05, 2012 5:57 am

Re: baseflight + SONAR

Post by ruffster »

I've been trying sonar on a HEX6X I'm building. I set it up first with 1k ohm resistors, & then with some voltage dividers.

But with it connected on pins 7&8 (rev 5 full) the board won't start up when the battery is plugged in; it just sits on the blue led and won't respond.

Try again with the sonar disconnected then it starts right up as normal. If I power up the board by usb before then connecting the battery it all works.

I've got a BEC going to a D4FR2 connected via PPM to the Naze, 6 Afroslim 20's on M1-M6.
Features set are PPM TELEMETRY SONAR
Mixer HEX6X

Am I doing something daft?
Thanks

User avatar
treym
Posts: 258
Joined: Sat Jul 21, 2012 12:28 am

Re: baseflight + SONAR

Post by treym »

maybe ? i dont know :) are you sure you sonar is wworking (without sone simple arduino code ?)

i have tested only with the sonar on motor pin 5&6 , ... code is supposed to work on rc pin


the configuration code for the sonar is currenlty a pending task , it was not merged so it need some update ..

User avatar
goodnnuts
Posts: 1
Joined: Fri Jan 02, 2015 2:39 am
Location: Port Alberni, British Columbia, Canada

Re: baseflight + SONAR

Post by goodnnuts »

So, lets see... I am assuming Sonar still won't work with Baseflight yet? :?: At least I can't get it to work in Baseflight but I can get it to work in Cleanflight.
Oh yeah, I'm using just the basic Naze32, not the pro version with the baro and other extras.

Post Reply