[SOLVED] Selecting an ultrasonic sensor and interface

Firmware/software/electronics/mechanics
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: [Hover] Selecting an ultrasonic sensor and interface

Post by alex »

tobias wrote:I've tested with your code an I think there has been some merge problems. The files i2croutines.c, i2croutines.h and nvic.c where not as they should. I have attached a patch so you can update them. Then the I2C2 bus should work again.

Code: Select all

git apply i2cfix.patch
Ok thanks, Tobias. Now I'm sure I messed things up completely. Your patch can't be applied:
i2cfix.patch:11: trailing whitespace.
void i2cInterruptHandlerI2c2(void);
i2cfix.patch:12: trailing whitespace.
void i2cErrorInterruptHandler(I2C_TypeDef* I2Cx);
i2cfix.patch:26: trailing whitespace.
/* Buffer of data to be received by I2C1, I2C2 */
i2cfix.patch:27: trailing whitespace.
uint8_t* Buffer_Rx1;
i2cfix.patch:28: trailing whitespace.
uint8_t* Buffer_Tx1;
error: Anwendung des Patches fehlgeschlagen: drivers/interface/i2croutines.h:132
error: drivers/interface/i2croutines.h: Patch konnte nicht angewendet werden
error: Anwendung des Patches fehlgeschlagen: drivers/src/i2croutines.c:32
error: drivers/src/i2croutines.c: Patch konnte nicht angewendet werden
error: Anwendung des Patches fehlgeschlagen: drivers/src/nvic.c:224
error: drivers/src/nvic.c: Patch konnte nicht angewendet werden
Have to have a closer look at this.

Did this to revert my local master branch to the original state from bitcraze's repo and pushed it to my fork (origin/master):

Code: Select all

git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force 
But it didn't help. Should I clone bitcraze's repo again and do a clean rewrite of my sonar-mb1242 branch? There's a pure git solution for this for sure, where are the git pros? ;) :oops:
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: [Hover] Selecting an ultrasonic sensor and interface

Post by tobias »

You probably had additional changes that are not in the github repository yet. Maybe clone it again from github and then try to apply the patch?
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: [Hover] Selecting an ultrasonic sensor and interface

Post by alex »

Good news: the sensor is working with my CF 1.0 thanks to Tobias' fix for issue #27.

The problem was that I didn't update my sonar-mb1242 branch correctly due to my lack of experience with git. Accordingly Tobias' I2C2 interrupt fix never reached my CF.

Thanks so much to everyone who contributed to my project over the last months, especially Tobias and Arnaud. I'm so happy right now! :P

Next steps: improving the sonar code, porting it to CF 2.0 and in the end using the sensor readings as additional input for the hover mode.

So long!
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: [SOLVED] Selecting an ultrasonic sensor and interface

Post by alex »

Besides the programming for reading the sonar sensor I prepared it to fit on the CF 2.0 using the Prototype Expansion Board. This is where the sensor's disadvantageous shape comes up again... Sorry for the bad lighting.
IMG_3835.jpg
IMG_3836.jpg
IMG_3837.jpg
IMG_3838.jpg
IMG_3843.jpg
Last edited by alex on Mon Jan 26, 2015 7:03 pm, edited 1 time in total.
dbrgn
Member
Posts: 51
Joined: Tue Dec 16, 2014 9:42 pm

Re: [SOLVED] Selecting an ultrasonic sensor and interface

Post by dbrgn »

Haha, that makes for a difficult landing :)

I got my voltage converter (I actually got a TI REG71050). Unfortunately I underestimated the tinyness of the SOT23 SMD casing... Therefore it doesn't fit on the prototyping board.

I guess I'll have to start etching my own PCBs to work around that :)
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: [SOLVED] Selecting an ultrasonic sensor and interface

Post by tobias »

Good news: the sensor is working with my CF 1.0 thanks to Tobias' fix for issue #27.
Great news! We are very exited to follow your progress!

I which it wasn't so hard to get hold of a mb1242 sensor so I could try it out as well...
alex
Expert
Posts: 137
Joined: Mon Feb 18, 2013 11:36 am
Location: Germany

Re: [SOLVED] Selecting an ultrasonic sensor and interface

Post by alex »

tobias wrote:Great news! We are very exited to follow your progress!

I which it wasn't so hard to get hold of a mb1242 sensor so I could try it out as well...
Now that we know that there's nothing special about the implementation itself, you could have spent the money for something more useful... maybe a book on git for me or so... :) :oops: Just joking...
dbrgn wrote:Haha, that makes for a difficult landing :)

I got my voltage converter (I actually got a TI REG71050). Unfortunately I underestimated the tinyness of the SOT23 SMD casing... Therefore it doesn't fit on the prototyping board.

I guess I'll have to start etching my own PCBs to work around that :)
Yes, but my CF isn't meant to land but to hover! :D

I omitted the step-up voltage regulator NCP1402 on the pics above which I initially had for the breadboard circuit connected to the CF 1.0. The expansion port of the CF 2.0 supplies 3.0 V over VCC at 100 mA. That's enough for powering the MB1242. At least I hope that this voltage is regulated and doesn't fall below 3.0 V. Can someone confirm that?
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: [SOLVED] Selecting an ultrasonic sensor and interface

Post by tobias »

At least I hope that this voltage is regulated and doesn't fall below 3.0 V. Can someone confirm that?
At the very end of the flight the voltage can drop below 3.0V but then you should already have landed ;)
Fucitol
Beginner
Posts: 19
Joined: Wed May 08, 2013 7:49 am

Re: [SOLVED] Selecting an ultrasonic sensor and interface

Post by Fucitol »

Alex, did you have any luck creating a stable altitude hold using the ultrasonic sensor?

I am a bit concerned about the propellor wash that the manufacturer warns about, have you tested this? For instance, you can fix your CF at 1m with no RPM and see what happens when you apply throttle while keeping the CF at 1m. Does this affect the measurement since the air flowing down can interfere with the

I was planning on maybe using an IR-based distance sensor for autonomic landing since they only work on short distances (below 1m) but accurate until 0.5cm.

(found this nice informative thread in your signature from your reply in my thread)
almaz_1c
Member
Posts: 43
Joined: Tue Dec 09, 2014 12:58 pm

Re: [SOLVED] Selecting an ultrasonic sensor and interface

Post by almaz_1c »

I tried maxsonar sensor . I did not like it. Firstly it is heavy (5 grams), and secondly a large dead zone (in fact 35 cm), third - too slow updating the data. I found a better solution - https://www.pololu.com/product/2474
Weighs only 2.5 grams, dead zone - 10 cm and more rapidly data refresh. But the range of only 1.5 meters.
Here is video: https://cloud.mail.ru/public/b9c3f426a4 ... 011800.mp4
Post Reply