Admin

How to Install Dual Sonars on a Pixhawk

Hi All,
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)

Regards,
TCIII ArduRover2 Developer

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hi. Thanks for your answer, for confirming two analog sonars work on virtual pins 13 and 14, and for your parameters.

    Marco Walther said:

    Hello, are you sure, your parameter names are correct? I just did a grep of my list of parameters (from a rover with two working analog sonar sensors), and I see a different name for the type?!

    marcow@feather5:/media/marcow/S WALTHER$ fgrep -i rngfnd px-20180306.param
    RNGFND_ADDR,0
    ...
    RNGFND2_TYPE,1

    Yes, this was a typo because of writing the post by heart. RNGFND_TYPE2 1 should be RNGFND2_TYPE 1

    I think,you can definitely use the MAVLINK messages to help with the debugging?! Connect Mission Planer to the Pixhawk, enable `Tuning' and select the sonarrange value to be plotted. (Similar to second image from http://ardupilot.org/rover/docs/rover-tuning-throttle-and-speed.html) For me, that seems to report the minimum of the two sonar readings.

    Yes, I had seen the graphs, showing 0 for 'sonarvoltage', even with the probe.

    I hope, this helps a little bit.

    -- Marco

    So I decided to start from scratch, but first I loaded an arducopter firmware and do a terminal check with CLI_ENABLED =  1. All that follows is with the resistors probe connected, injecting voltages on virtual pins 2,3, 13 and 14, which should give exagerated values for voltage, current and sonar voltages.

    Things seemed to work on the terminal tests:

    3702418219?profile=original

    Recall that injected voltages were 1.5V and 3V (one doubles the other). Scaling was 3 V/m.

    Graphs were correct:

    3702418488?profile=original

    3702418506?profile=original

    So I flashed again the rover firmware, with parameters loaded from a saved file (with two analog sonars on virtual pins 13 and 14).

    Things work now on the rover, with the resistors probe; I don't know what happened. I regret the lack of terminal on rover, which permits tests without GCS, with a simple terminal program (I use Teraterm, which is excellent and with many possibilities in general, like Kermit transfers).

    How to Install Dual Sonars on a Pixhawk
    Hi All,I just completed installing dual Maxbotix MB1240 sonars on one of my Pixhawk equipped rovers.Since the sonars were from an APM equipped rover…
  • Hello, are you sure, your parameter names are correct? I just did a grep of my list of parameters (from a rover with two working analog sonar sensors), and I see a different name for the type?!

    marcow@feather5:/media/marcow/S WALTHER$ fgrep -i rngfnd px-20180306.param
    RNGFND_ADDR,0
    RNGFND_DEBOUNCE,2
    RNGFND_FUNCTION,0
    RNGFND_GNDCLEAR,10
    RNGFND_MAX_CM,600
    RNGFND_MIN_CM,20
    RNGFND_OFFSET,0
    RNGFND_ORIENT,0
    RNGFND_PIN,14
    RNGFND_POS_X,0.26
    RNGFND_POS_Y,-0.14
    RNGFND_POS_Z,0
    RNGFND_PWRRNG,0
    RNGFND_RMETRIC,1
    RNGFND_SCALING,3.125
    RNGFND_SETTLE,50
    RNGFND_STOP_PIN,52
    RNGFND_TRIGGR_CM,200
    RNGFND_TURN_ANGL,25
    RNGFND_TURN_TIME,1
    RNGFND_TYPE,1
    RNGFND2_ADDR,0
    RNGFND2_FUNCTION,0
    RNGFND2_GNDCLEAR,10
    RNGFND2_MAX_CM,600
    RNGFND2_MIN_CM,20
    RNGFND2_OFFSET,0
    RNGFND2_ORIENT,0
    RNGFND2_PIN,13
    RNGFND2_POS_X,0.26
    RNGFND2_POS_Y,0.14
    RNGFND2_POS_Z,0
    RNGFND2_RMETRIC,1
    RNGFND2_SCALING,3.125
    RNGFND2_SETTLE,50
    RNGFND2_STOP_PIN,53
    RNGFND2_TYPE,1

    I think,you can definitely use the MAVLINK messages to help with the debugging?! Connect Mission Planer to the Pixhawk, enable `Tuning' and select the sonarrange value to be plotted. (Similar to second image from http://ardupilot.org/rover/docs/rover-tuning-throttle-and-speed.html) For me, that seems to report the minimum of the two sonar readings.

    I hope, this helps a little bit.

    -- Marco

    Tuning Speed and Throttle — Rover documentation
  • Hi. This is long (sorry).

    I am assembling an hexa drone and a rover both with similar Pixhawk configurations (two sonars). I use Mission Planner as ground station, and 3DR radios. I'm having problems with analog sonars on the rover.

    On the drone, I mounted an I2C (address 112) and an analog sonar (by now with three pins (supply and analog output)). Both point downwards. Note that this is incorrect since they will interfere, so for flying I will connect one at the time. I connect the sonar analog output to ADC 3.3V connector J404 pin 2 (virtual pin 14). On the graphs I see the I2C sonar on 'sonarrange' and the analog sonar on 'sonarvoltage', and both signals seem to follow each other. Since the drone software admits CLI_ENABLED = 1, I can see both sonars at a terminal ("tests", "rangefinder"), which shows two sonars recognized and their measurements alternatively. The parameters involved are:
      RNGFND_TYPE 1
      RNGFND_PIN 14
      RNGFND_TYPE2 2

    So far, so good.

    Duplicating the configuration on the rover, I cannot see the analog sonar working. I have tried many ways and even made for debugging a test probe with a spare DF13 5p connector and resistors, generating 3V and 1.5V (see attachment), connected to virtual pins 13 and 14 on J404 pins 2 and 4. I use the Dupont 2p connector to inject the same signals on J601 Power connector for more analog checkings.

    3702418451?profile=original

    The problem is that not only with the analog sonar, but also with the test probe I constantly see 'sonarvoltage' 0 ('sonarrange' changes).

    The sonars point forward. Note that this configuration has sense in the rover, since one sonar can point right and the other left, and not interfere.

    If I define two analog sonars:
      RNGFND_TYPE 1
      RNGFND_PIN 14
      RNGFND_TYPE2 1
      RNGFND2_PIN 13
    nothing changes: no analog sonar readings.

    As said, connecting the 3V and 1.5V voltages on J601 Power connector voltage and current sensor pins, I see readings (without sense), so there is overall analog measurement capability. Parameters involved (virtual pins):
      BAT_CURR_PIN 3
      BAT_VOLT_PIN 2

    This happens with rover versions 3.2.1 and beta APMRover2-v2.px4 dated march 8. Another difficulty is that on the rover software CLI_ENABLED = 1 is not admitted, so debugging this way is not possible. Terminal shows Mavlink garbage.

    Questions:
    -Why no analog sonar signal on the rover? I think I miss something obvious.
    -Any way to debug with a terminal on the rover software?
    -Is it possible to inhibit the I2C sonar (similar to using stop pins on the analog sonar)?

    Regards.

  • I should have asked here instead of creating a new discussion.  Thomas, does sonar work over water?

    • Admin

      @DG,

      I would get on the Maxbotix website and see if they offer any information concerning working over water. Otherwise I would try to contact their customer service.

      Regards,

      TCIII AVD

  • 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?

    Thanks;-)

    • Admin

      @Marco,

      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.

      Regards,

      TCIII AVD

    • 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?

    • Admin

      @jon c,

      Unlike the Maxbotic sonars, the LIDAR-Lite puts out a very narrow beam and would have to be scanned across the front of the rover to detect all objects in front of the rover adding an additional level of complexity.

      Regards,

      TCIII AVD

    • True, the beam with the optics installed is 1.5 degrees, not too useful without scanning.  But without the optics the beam is 6 degrees, though the range drops to 5 meters.  Not great if you are at 5m/s+, but possibly still useful at low speeds?  A 12 degree arc for a circle 5m radius circle is about 1 meter wide so two of them could be interesting....

      http://www.dragoninnovation.com/projects/32-lidar-lite-by-pulsedlight

This reply was deleted.