Sonar HC-SR04 Support now implemented in MW2.4

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download

Re: Sonar HC-SR04 Support now implemented in MW2.4

Postby asti » Sat Jul 30, 2016 11:53 am

I have quick questions:
1. In which unit is the sonarAlt value? (cm,inch,something else)
2. Does the echo pin has to be an interrupt pin?
Your code for reading the sonar value did not work for me (it was a constant), but with the code from http://www.instructables.com/id/Non-blocking-Ultrasonic-Sensor-for-Arduino/ I get good values.

Thanks for your work!
asti
 
Posts: 12
Joined: Thu Apr 21, 2016 8:56 pm

Re: Sonar HC-SR04 Support now implemented in MW2.4

Postby asti » Tue Sep 06, 2016 2:11 pm

To answer my own question: the unit is in cm.

After understanding your code, I have an issue with it.
I don't understand why you do add the flight mode and box for sonar. What your code does is using the sonar value to improve the estimated altitude. This is an addition/improvement to the baro mode. Then you add the sonar flight mode and box which does in most cases what the baro mode does (lots of #if BARO | SONAR). However, the code line that actually applies the calculated baro pid values to the motor is not executed if only the sonar flight mode is activated (in MultiWii.cpp rcCommand[THROTTLE] = initialThrottleHold + BaroPID;). Thus, to have alt hold with sonar sensor one must activate baro mode as well. And so the sonar mode is first redundant and second does not have an effect in your implementation.
asti
 
Posts: 12
Joined: Thu Apr 21, 2016 8:56 pm

Previous

Return to Software development

Who is online

Users browsing this forum: No registered users and 23 guests