Dual analogic sonars, interference?

Hello, i’m running ardurover on my old-dated APM 2.5, i purchased 2 of analogic sonars for rangefinder feature. I’ve read the method to avoid interference: setting a STOP_PIN to pull down the sonar i don’t want ranging for the moment. However i don’t have the classic maxbotix module, so i was thinking to connect the positive pin of the sonar module to the signal STOP_PIN, to effectively turn off the module when the STOP_PIN is pulled down. However this setup doesnt work, and i would request clarifications:

  • does the board automatically switches STOP_PINs (1 and 2) HIGH and LOW, for reading left and right sonars ? does the switch occurs with a regular frequency ? (eg. 5 Hz)
  • does the pin really be pulled high or its changed in undetermined state ? (I’ve seen maxbotix got a pullp resistor)
  • how much time does the pin be pulled down to avoid ranging ?

I will briefly explain my setup again:
RNGFND_PIN=0
RNGFND_STOP_PIN=56
RNGFND2_PIN=1
RNGFND2_STOP_PIN=57

sonar sensors
Analogic pins plugged to A0 and A1, positive to A2(=digital 56) and A3(=digital 57), negative to ground.
Error-> Status led never blinkin on sonar modules
Thank you for your help

I bypassed running the sonars through the autopilot on my rover. I just run the PWM signals from the autopilot (Pixhawk) through an arduino and hook the sonars up to the arduino. My arduino sketch adjusts the PWM signals accordingly. I don’t know if this is bad practice but it seems to work for me, it at least keeps my machine from running things over and I can add as many sonars as my arduino mega can handle.

1 Like

Oh excuse me. I just remembered sonar is different from ultrasonic. I don’t know if my solution will work for you. But it might.

Thank you really for your suggestion, if I understood well you let Arduino “communicate” in between the sonar readings and the pixhawk, acting as a translator. I didn’t know the difference between sonar and ultrasonic, because mine are ultrasonic, can i ask you what is your sonar (or ultrasonic) sensor module ? My only concern is about timing phases between sensors, because about 100ms to take reading with Arduino , 100ms to wait between readings, for 2 sensors let me update at about 2.5Hz that’s not much.
For curiosity, do you use this multiple-senors setup on the large rover of your discussion ? How do you manage to get orientation of the sensors on the pixhawk for smart obstacle avoidance ? Again thank you

Well I only need my rover to stop when something gets in front of it so I do not know about obstacle avoidance.

I don’t think there is a difference in the sensors. I am using these:
https://www.amazon.com/Smraza-Ultrasonic-Distance-Mounting-Duemilanove/dp/B01JG09DCK/ref=sr_1_1_sspa?crid=MYUYMN7OQI3X&dchild=1&keywords=ultrasonic+sensor+arduino&qid=1615938912&sprefix=ultrasonic+sensor%2Caps%2C185&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEySlVaWTlBVDBYN08xJmVuY3J5cHRlZElkPUEwNjc4MDk5MThDSFFFV0NFVDhQRiZlbmNyeXB0ZWRBZElkPUEwNDIyMDEyMjNLSDE1TkdLU0lJQSZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=

To counter timing phases I am actually running all of my sensors to another arduino that sends a high signal to the main arduino. I’m not super tech savy but I know what you are talking about and I didn’t like it either so thats how I countered it. You could probably do even more by using an arduino nano for each sensor that sends a simple high signal to the main arduino. This will cut down a lot on timing in between each. I think I have 8 sensors made for my large rover. Like I said, all I need mine to do is stop, so when the main arduino gets a signal from the sensor arduino it adjusts the PWM signals to my throttle servo.

Hopefully you can create your own solution out of the info I have given you. I like using arduinos in between, I can think of a lot of other things I can add. But if you have something that needs to be super fast I don’t know if it is the best solution.

And I bet if you got crafty enough with your arduino code you could build your own obstacle avoidance algorithm.