Go Down

Topic: Array of HC-SR04  (Read 290 times) previous topic - next topic

madmax7897

I am currently a senior in college doing my senior design project. I need to track our robot around a 18 by 18 foot play area so that it can dock and charge itself. I have two questions.

1. I plan on using multiple 16 pwm, 12 bit shield to get many outputs but could not find anything that they can be inputs like the echo pin. Is this possible?

2. Do you have any other ideas for tracking that can be done with Arduino and are accurate (2cm max)

AWOL

Quote
I plan on using multiple 16 pwm, 12 bit shield
Can I ask "why?" ?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

madmax7897

The echo pin must use a PWM pin and the arduino mega only has 16 pwm pins. By using this pwm shield number of PWMs can be increased up to 992 ports.

wvmarle

The echo pin must use a PWM pin
Not for an HC-SR04. Just time the length of the signal.

How many of those do you plan to use?
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

AWOL

#4
Dec 05, 2018, 08:58 am Last Edit: Dec 05, 2018, 10:42 am by AWOL
The echo pin must use a PWM pin and the arduino mega only has 16 pwm pins. By using this pwm shield number of PWMs can be increased up to 992 ports.
The echo pin is an output from the sensor, connected to an input on the processor.
PWM pins are processor outputs.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

wvmarle

More than 16 such sensors on a single MCU (i.e. all of them in close proximity of one another) is of course a recipe for disaster in itself...
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

zhomeslice

#6
Dec 08, 2018, 04:21 am Last Edit: Dec 08, 2018, 04:21 am by zhomeslice
Done this with 8 and I can see it max out an Arduino Uno (Every pin including analog pins can be an interrupt trigger) you will need to modify the code for a mega but you could have even more Ping sensors.

How this works a single (which it could be from any clock source even external! trips all the trigger pins at once. The Echo pins all go high at the same time (or so close it is irrelevant) the time each pin changes is logged as the echo start. The sound is traveling outward in all different directions all at the same time with my example. and we are looking for the closest items in the path of this sound. so any reflected sound will be captured by the receiver side for each HC-SR04 that can sense the reflection. This drops the echo pin low and we trigger a second falling interrupt to get the duration of sound traveling from the sensor. This continues until all devices are accounted for and we start over.

I've hit the trigger pin more often than needed even if the return echo hasn't made it back without any adverse results the only advantage is that the closer items are sampled more often than the further ones. triggering the HC-SR04 before the echo has returned doesn't affect the reading it will not trigger another echo until it times out.

The attached code is my base example for this site.

Heres my setup with 8 HC-SR04 sonar sensors (they trigger simultaneously with one trigger pin and receive echoes individually on separate pins).


HC

Go Up