I just completed installing dual Maxbotix MB1240 sonars on one of my Pixhawk equipped rovers.
Since the sonars were from an APM equipped rover they already had single pair shielded cables terminated with three pin servo connectors providing power, rtn, and the sonar output signal.
You will need a DF13 five pin connector cable to connect to the Pixhawk ADC3.3vdc Analog Input. The cable should be wired as follows:
Pin 1 5vdc (red)
Pin 2 Left Sonar Signal Input (Sonar)
Pin 3 RTN
Pin 4 Right Sonar Signal Input (Sonar2)
Pin 5 RTN
Since I am using two sonars, I had to trigger them sequentially to avoid having them see each other. Therefore I used two of the Aux Servo pins as Digital Outputs:
Aux Servo pin 5 (Virtual pin 54) Right sonar trigger
Aux Servo pin 4 (Virtual pin 53) Left sonar trigger
These two outputs go to the Left and Right sonar trigger pins.
Then go to the MP's Full Parameter List and set up the Sonar and Sonar2 parameters. For the Maxbotix MB1240 setup described above use the following parameters:
BRD_PWM_CNT 0 (Makes all the Aux Servo pins digital)
Sonar Function 0
Sonar Enable 1
Sonar Debounce 2
Sonar Max Cm 700
Sonar Min Cm 20
Sonar Offset 0
Sonar Pin 14 (Left sonar)
Sonar Scaling 2.04 (Adjust as necessary to display the correct distance to the target)
Sonar Settling Ms 50
Sonar Stop Pin 53 (Left sonar trigger)
Sonar Trigger Cm Whatever distance you want in cm
Sonar Turn Angle Whatever distance you want in deg
Sonar Turn Time Whatever distance you want in sec
Sonar2 Function 0
Sonar2 Enable 1
Sonar2 Debounce 2
Sonar2 Max Cm 700
Sonar2 Min Cm 20
Sonar2 Offset 0
Sonar2 Pin 13 (Right sonar)
Sonar2 Scaling 2.04 (Adjust as necessary to display the correct distance to the target)
Sonar2 Settling Ms 50
Sonar2 Stop Pin 54 (Right sonar trigger)
TCIII ArduRover2 Developer
Since I do not use the sonars any longer, as they are not effective at speeds above 3m/s, there must have been a change to the sonar input pin acronym that I am not aware of.
It sounds like the sonar function in the ArduRover stable firmware is possibly broken if you cannot get your sonars to work.
You might have to wait until our Developer/Programmer Tridge is available after the AU OBC to fix the issue if there is one.
Are you sure that the HC-SRO4 output is compatible with the present sonar function?
HC-SR04 signal is not fed directly to Pixhawk/APM - the signal activation, calculations, processing and conversion is done with Arduino Micro. The output is just voltage from 0 to 3V - analog. I modified the code so that it will not go above 3V, although ADC should support also 5V signal.
"It sounds like the sonar function in the ArduRover stable firmware is possibly broken if you cannot get your sonars to work."
How can that happen?
There have been major changes to the general rangefinder firmware recently to accommodate the integration of additional types of sensors and the changes to the ArduRover2 rangefinder firmware have not been verified.
I have tried one of my Maxbotix MB1240 on my test bench Pixhawk and it is definitely a no go.
Will have to wait for Tridge to resolve this sonar non-functional issue.
Have you been in contact with Tridge, is there any hope it will be resolved in near future, year 2014?
Unfortunately I have yet to hear from Tridge since the completion of the AU OBC.
I believe that the sonar issue will be corrected in the near future, but as to when, I do not know.
This thread is a little bit older, but I just got into the Pixhawk Rover universe;-)
I do have a question however. The Pins 13 & 14 mentioned above should only be 3.3V save. But the MB1240 would output up to Vcc/5V. Did everybody add a Voltage divider or just live with it? What would be good resistor values for a voltage divider? I'm currently thinking about 33k/68k? Would that work?
If a voltage divider would have been required to reduce the 5vdc to 3.3vdc, it would have been in the instructions. It is not required.
Also note, the sonar/rangefinder does not work well at speeds over 3 m/s due to processing delays.
Can any of the MaxSonars, in the 3DR store, be used with Pixhawk?
Is the more expensive 1240 required for dual sonar setup?
You can use any of the Maxbotix sonars as long as they are analog. You will have to adjust the scaling factor to your particular sonar.
Thanks a lot for your info
How about replacing with LIDAR lite, or other lidar? Should be faster than sonar, though at 6+m/s it may still not be fast enough. Are there any changes you'd need to make for LIDAR lite instead of sonar?