Page 2 of 2

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Sun Mar 18, 2012 10:37 pm
by LuFa
Hey ,

can you tell my how to read 2 of SRF08 ?

i think with this function :

Code: Select all


Sonar1 = srf08_ctx.range[0]; // Sonar 1
Sonar2 = srf08_ctx.range[1]; // Sonar 2



is that right ?

Thanks

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Tue Mar 20, 2012 7:55 am
by alexmos
I am impressed about functionality of SRF08! Now I think it's price resonable. When you finished implementation to code I will buy one to try :)

About my code: I have found a big problem in my sonar-baro fusion: if sonar gives wrong altitude (due to noise in power), my copter have tend to go very quickly to infinite altitude :) This is because baro is tweaked by sonar and there is no diff control. I am planing to constrain sonar-baro error by 2-meter window. If error goes outside this window - no more trust to sonar and we should completely switch to baro. I will add it to r16 of my branch with many other improvements.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Tue Mar 20, 2012 8:09 am
by Waldmensch
You could use a frame which reflects the range of the sensor -
- 26cm to 500cm. Each value outside = wrong
- >50cm while arming = wrong (through that my copter is 15cm over ground in total the sonar delivers wrong, I'm not able to mount it 26cm over ground)

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Fri Apr 06, 2012 1:59 pm
by LuFa
can anyone upload the newest 2.0 with the SRF08 code ?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Tue May 22, 2012 6:21 pm
by boke
Hello i have a SRF08 and a Wiicopter! I did download the new Dev-version but how did this work together? The sonar is blinking but i dont get anything in the GUI. What i have to to? And why do nobody test it? I saw videos from feb. Where it works now its may and nothing?
Please help me!

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Jun 04, 2012 8:13 pm
by Andi
Hello,
can someone help me
I installed and activated the SRF08 in the DEV20120528.
SRF08= the red LED flashes.
Where can I see in the GUI, if the sensor is working properly?
I do not mean that he does
My System = flyduino Megaboard with Drotek 10DOF Mpu

Andi

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Jun 04, 2012 8:19 pm
by Tommie
Look at the debug3 label at the bottom of the screen. It should display the distance between sensor and ground.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Jun 04, 2012 9:00 pm
by Katch
Is there a good source for this SRF08 sensor - I can't seem to find any.

I found this sensor though;

http://www.ebay.co.uk/itm/150723212509

Looks to be in spec - think it would work with the same code?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Jun 04, 2012 9:24 pm
by Andi
Tommie wrote:Look at the debug3 label at the bottom of the screen. It should display the distance between sensor and ground.



Hi , thx Tommie

ok , he works.

One more question:

How does the sensor, the signal is mixed with the Barosignal or how does it work?
PID setting with ALT for the sonar sensor?

@ Katch

I bought my here

http://www.nodna.de/Produkte/Sensoren/D ... 77f7e75558

Andi

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Jun 04, 2012 9:53 pm
by Alexinparis
There is currently no code in the dev version to support the sonar output (except for plotting it)
But there is already some code working from alexmos.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Tue Jun 05, 2012 10:28 pm
by Andi
oh
when it is planned that this works? Sonar switched with AUX without Baro in a first step that would be great
I can not program. I can only test or something for the project donations

Andi

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Thu Jun 14, 2012 12:49 am
by jgrouse
Hi,

I'm having a tough time reading through the posts where all this is at in the current 20120606 dev code (2.0)? I can see limited references to SonarALT in the code and I can get my SRF02 to show the distance in the debug value in the Config app however that's as far as it made it in the current dev code.

Is there a recent chunk of code someone has working with V2 dev code they can post here so I can test it out?

Thanks,

John

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Fri Jun 29, 2012 3:29 pm
by PonyoFS
Hi,
Do you know what I2c speed is supported by the srf08 ?

Thanks.
Antony.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Fri Jun 29, 2012 8:20 pm
by Alexinparis
PonyoFS wrote:Hi,
Do you know what I2c speed is supported by the srf08 ?

Thanks.
Antony.

400kHz is fine with it

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Thu Jul 12, 2012 12:41 am
by PonyoFS
Thanks Alex.

Tonight i tested it on a multiwiicopter board (V4r5) with a freeimu 0.43 and a navigatron V2 GPS. Nothing to do, the sonar freezes my sensors. No flashing led on it, and on the GUI, sensors are crazy !
Anyone has a solution?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Thu Jul 12, 2012 3:58 pm
by PonyoFS
I have the solution, on the multiwiicopter board V4r5, HV i2c bus is powered by the esc when you have separated power... Sorry. :oops:

But i have another problem, address of the srf08 is fixed on 0xF2 (1 long flash and 9 short flashes) and i don't know why. And nothing happened on the GUI.
Do you have a solution ?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Sun Jul 29, 2012 4:58 pm
by PonyoFS
Nobody ?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Sat Jan 05, 2013 10:59 pm
by Raptor
PonyoFS wrote:I have the solution, on the multiwiicopter board V4r5, HV i2c bus is powered by the esc when you have separated power... Sorry. :oops:

But i have another problem, address of the srf08 is fixed on 0xF2 (1 long flash and 9 short flashes) and i don't know why. And nothing happened on the GUI.
Do you have a solution ?


I have an answer for you on this question I know its an old post, but i thought if someone else was looking at this sensor and did a search, they might find this.

Any ways mine was fixed on 0xF2 as well. the I2C bus uses only the high 7 bits for the address info, so 0xf2 becomes 0x79. I modified the orgional code defining the default address to 0x79 and the moved address to 0x78 and uploaded. See below/ Once i did that it works like a charm. When i left the second one at 0xf0 i got some large negitive number.

#if !defined(SRF08_DEFAULT_ADDRESS)
#define SRF08_DEFAULT_ADDRESS 0x79 /This was 0x70.
#endif


#if !defined(SRF08_SENSOR_FIRST)
#define SRF08_SENSOR_FIRST 0x78 // the first sensor i2c address (after it has been moved)
#endif

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Jan 07, 2013 5:38 pm
by PonyoFS
Thanks a lot !!!!!!!!!! :-)
You make me very happy !

This sensor is in a dusty box since my question.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Jan 14, 2013 10:50 pm
by PonyoFS
Does anyone still working on this sensor?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Sat Feb 16, 2013 11:01 am
by mehranpour
can i running altitude holding just with sonar?
without baro?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Sat Feb 16, 2013 5:33 pm
by copterrichie
mehranpour wrote:can i running altitude holding just with sonar?
without baro?


Only up to 9 feet but more like 6 feet is realistic. However, Sonar is not fully functional in the official release.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Thu Mar 28, 2013 10:21 pm
by farzadsw
mehranpour wrote:can i running altitude holding just with sonar?
without baro?

Yes you can! :D
I'm using multiwii 2.2 source code, and I just changed a few lines in code to make altitude holding based on a sonar (SRF08) sensor possible.
First of all, you need to get valid data from sonar sensor (SRF08 or 02). Although 2.1 and 2.2 versions of the code have essential routines for SRFx sensors, There are some small mistakes in original source code, see this:
http://www.multiwii.com/forum/viewtopic.php?f=8&t=3212&start=60#p33293
Also, if your sonar sensor (SRF08) is not working as expected in long ranges, you can tune "Range" and "Gain" values to get a valid data. I limited the measurement range to about 3 meters and lowered the gain to ignore weak echoes, by adding two lines to "Sonar_init()" routine:

Code: Select all

i2c_writeReg(SRF08_SENSOR_FIRST, SRF08_LIGHT_GAIN, 0x45);  delay(50); // range= 3m 
 i2c_writeReg(SRF08_SENSOR_FIRST, SRF08_LIGHT_GAIN, 0x18);  delay(50); // analogue gain

Now you will get valid data. If data is not completely reliable, you cannot use it for altitude hold. By some tuning, both SRF02 and SRF08 sensors will provide you altitude data but compared to SRF02, SRF08 is more robust! for example, my SRF02 sometimes generates random numbers above floors with a carpet on it.
By replacing baro Altitude with sonarAlt in line 284 of IMU library, you will have sonar altitude hold:

Code: Select all

 EstAlt = (EstAlt * 6 + sonarAlt * 2) >> 3;

good luck
Farzad

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Wed May 22, 2013 10:21 am
by dronius
Hi guys, I was trying to get SRF10 sensor to work with MultiWii 2.2 codebase, but found some issues. Not sure how it was supposed to work at all. Perhaps there were some untested parts that got merged in from original implementation? Or perhaps it's just me being not familiar with MultiWill code.

Anyway, got it to work, the main problem was 7-bit vs 8-bit addressing on I2C. See patch attached, should also work with SRF08 and friends.
Note that SONAR_MULTICAST_PING is commented out, check if your sensor supports that (mine doesn't it seems)

I'm also thinking to play with altitude stabilization whenever sensor signal looks reliable and altitude is <= 3m. Above threshold, it would rely on barometer. Alternative is to have mixed contribution of sonar + barometer data into altitude calculation within certain "band". E.g. <= 2m 100% is taken from sonar, and >= 4m 100% is barometer. Inbetween, it's linear.

What is the process of contributing to MWC mainline?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Wed May 29, 2013 5:27 am
by felixrising
Hi Dronius,

Did you get your patch included? After some discussion over at the 2.3 wishlist http://www.multiwii.com/forum/viewtopic.php?f=7&t=3167&start=40#p36647 regarding patch submission process, I'll draft something up on the wiki.. there is also some documentation about the same in the google code repo here: https://code.google.com/p/multiwii/source/browse/trunk/README.txt

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Thu Jul 04, 2013 6:13 am
by Mazz1
farzadsw wrote:
mehranpour wrote:can i running altitude holding just with sonar?
without baro?

Yes you can! :D
I'm using multiwii 2.2 source code, and I just changed a few lines in code to make altitude holding based on a sonar (SRF08) sensor possible.
First of all, you need to get valid data from sonar sensor (SRF08 or 02). Although 2.1 and 2.2 versions of the code have essential routines for SRFx sensors, There are some small mistakes in original source code, see this:
http://www.multiwii.com/forum/viewtopic.php?f=8&t=3212&start=60#p33293
Also, if your sonar sensor (SRF08) is not working as expected in long ranges, you can tune "Range" and "Gain" values to get a valid data. I limited the measurement range to about 3 meters and lowered the gain to ignore weak echoes, by adding two lines to "Sonar_init()" routine:

Code: Select all

i2c_writeReg(SRF08_SENSOR_FIRST, SRF08_LIGHT_GAIN, 0x45);  delay(50); // range= 3m 
 i2c_writeReg(SRF08_SENSOR_FIRST, SRF08_LIGHT_GAIN, 0x18);  delay(50); // analogue gain

Now you will get valid data. If data is not completely reliable, you cannot use it for altitude hold. By some tuning, both SRF02 and SRF08 sensors will provide you altitude data but compared to SRF02, SRF08 is more robust! for example, my SRF02 sometimes generates random numbers above floors with a carpet on it.
By replacing baro Altitude with sonarAlt in line 284 of IMU library, you will have sonar altitude hold:

Code: Select all

 EstAlt = (EstAlt * 6 + sonarAlt * 2) >> 3;

good luck
Farzad



Hello! do you know if i can use this metod with "i2c gps nav" sonar? i have HC-SR04 and i want sonar alt hold.
Sorry about my english, thank you!

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Tue Aug 20, 2013 10:46 am
by PolyGONtrauma
Since my SRF08 is working accurately in debug-window, I wanted to implement the baro/sonar fusion code mentioned on the first page. Unfortunately, the file "MultiWii-V1_9_alexmos_guru.zip" does not exist any more on the server. Is there any way to get the code?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Tue Sep 17, 2013 1:06 pm
by Pat1300
Hi PolyGONtrauma,
Last version of alexmos baro/sonar fusion is avaialbel in MultiWii2_0_alexmos_r23.zip : https://code.google.com/p/multiwii-alexmos/downloads/list
Good luck with the merge !
Patrick

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Fri Nov 08, 2013 10:37 pm
by kavehslt
hi everyone

my sfr08 does not work correctly. i change the address to true one like raptor said before ( i have (1 long flash and 6 short flashes) means EC in hex address and i change it to 0x76)) but i don't see any effect in my multiwii config program raptor said by enabling debug 3 we should see the effect but i don't see any thing and i2c error happen after 15-18 second !!!!!! i really confused because when i used HMC5843 with my srf08 from the beginning the i2c error happen.

Please Help me

i used independent sensors

mpu6050 + hmc5843 + MS561101BA + SRF08
and multiwii 2.2. i test all this ways with MultiWii_dev_2013_10_28_r1604 and i give the same result too.

SOS!!!!!! :? :roll:

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Sun Nov 10, 2013 11:15 am
by kavehslt
HELLO WOULD YOU HELP ME PLZ

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Sat Nov 16, 2013 10:52 am
by stardobas
:? in wultiwii 2.3 I haven't success to upgrade SRF08... I've try but I can't compile stretch for my quadcopter....Please have you a stretch to give me for quadcopter just patched with applied sfr08 holding system? I've try to upgrade but.....no success...

specification

Posted: Sat Nov 16, 2013 1:51 pm
by stardobas
I've changed address in sensor stretch and now I see led blinking for ping sending....

NEWSSS:
using this: alt.EstAlt = (alt.EstAlt * 6 + sonarAlt * 2) >> 3;
I get only sonar value on altidute in the gui....and fine...work well....but I want use barometer altitude when go up 2 or 3 metres...
I wrote this:


alt.EstAlt = (alt.EstAlt * 6 + sonarAlt * 2) >> 3; // additional LPF to reduce baro noise (faster by 30 µs)
if (sonarAlt > 1) {
alt.EstAlt = (alt.EstAlt * 6 + BaroAlt * 2) >> 3;
}

but I continue to read only sonar value....never use barometer value....

Please HELPPPPPP!!

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Nov 18, 2013 12:24 am
by Mis
My idea of SONAR+BARO fusion:

Code: Select all

  #if(SONAR)              // BARO+SONAR Fusion
    if(sonarAlt > 0 && f.SMALL_ANGLES_25) {      // use sonar only if valid sonar data, and with inclinations below 25 degres
      float ratio = (SONAR_BARO_FUSION_HC-sonarAlt)/(SONAR_BARO_FUSION_HC-SONAR_BARO_FUSION_LC);  // baro/sonar ratio
      ratio = constrain(ratio, 0.0f, 0.90f);                // min sonar ratio = 0, max sonar ratio = 0.9
      BaroAlt = BaroAlt * (1.0f-ratio) + sonarAlt * ratio;
    }
  #endif
  alt.EstAlt = (alt.EstAlt * 6 + BaroAlt * 2) >> 3; // additional LPF to reduce baro noise (faster by 30 µs)

Need declaration for one "float scale;" variable at begin of "etEstimatedAttitude" function.
Then on config.h we need two more decalrations:
#define SONAR_BARO_FUSION_LC 100 // bellow 100cm use only sonar
#define SONAR_BARO_FUSION_HC 500 // above 500cm use only baro
That's all. Bettwen 1 and 5m althold use baro+sonar fusion proportional to sonar height (lower -> more sonar usage), below 1m only sonar is used, and above 5m only baro is used.
Additionally sonar is used only if inclination of copter is lower than 25deg, because in higher inclinations reading of sonar can have too high error.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Nov 18, 2013 12:45 am
by stardobas
Wow...I've solve it but I don't considerate the inclination...perfect!!! I will try it!

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Fri Nov 22, 2013 11:58 pm
by Crashpilot1000
Oh, well what was f** up shit from the beginning to the end. Remember what a sonar can physically do and look at that code - it makes you cry.
That "fusion" is gross sh't. Remember: Sonar gives you RELATIVE distance - never absolute hight. So wait another 2 years until mwii understands that.

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Mon Mar 24, 2014 5:33 pm
by weebly
I'm using multiwii 2.0. I tried to edit the code as described. But it doesn't work. Can someone please upload the full edited code. Plz plzz...... I need the full code. :( :( :( :(

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Thu May 08, 2014 10:13 am
by bc power
Guys I need to connect 4 srf02 modules for obstacle avoiding...please help me...

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Wed Aug 27, 2014 8:18 am
by bc power
I need an algorithm for srf02 4 modules....help me guys................................:)

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Wed Dec 16, 2015 4:01 pm
by iDaniel
Hi
i´ve connected an SRF08 Module to my arduino uno. Also i´ve got an GY-521 i2c ACC connected. In the Gui is can see the sonar value aon debug3 and it works quite well,
until i dont turn on my transmitter, wich connected normal (no PPM SUM). Then it shows an i2c error and the sonar doesn´t work...but the ACC ist still working. I turn the transmitter of and the Sonar ist working again...

any ideas?

Re: Integration of SRF08 I2C sonar sensor (done)

Posted: Fri Dec 18, 2015 3:44 pm
by iDaniel
Ok i have tested now the same code, same frsky receiver, same sensor but another arduino(pro mini) and GY-88 Sensorboard. I works without i2c errors ... so i don´t know why, because of the other arduino or the sensorboard... but i did not want to use the uno anyway on my copter. So i won´t figure out why anymore :D