Increasing number of HC-SR04s per digital pin by using multiplexers

Thread Starter

ardaeden

Joined Mar 1, 2019
2
Hi,
For a contemporary art project, I need to build an array of ultrasonic sensors (maybe up to 30 or more) to read some data from them, in order to create an interactive soundscape. In theory, it sounds possible to use a multiplexer (74HC4051 for x8 or 4067 for x16) to increase the number of HC-SR04s per Arduino pins. Is this reasonable ? or Are there any other ways that you can suggest ?
Thanks in advance.
 

KeithWalker

Joined Jul 10, 2017
3,090
Hi,
For a contemporary art project, I need to build an array of ultrasonic sensors (maybe up to 30 or more) to read some data from them, in order to create an interactive soundscape. In theory, it sounds possible to use a multiplexer (74HC4051 for x8 or 4067 for x16) to increase the number of HC-SR04s per Arduino pins. Is this reasonable ? or Are there any other ways that you can suggest ?
Thanks in advance.
The 74HC4051 analogue multiplexer is not the best choice for multiplexing inputs from HC-SR04 ultrasonic sensors. The reason is that the output from these transducers is a pulse which has a length proportional to the distance sensed. The timing of this signal is critical to the accuracy of the results. The TI CD4051BEE4 or a similar digital multiplexer would be a much better choice. The trigger signal from the Arduino can be connected in parallel to all of the sensors. You will only need to multiplex the outputs back to the Arduino.
 

crutschow

Joined Mar 14, 2008
34,408
The 74HC4051 analogue multiplexer is not the best choice for multiplexing inputs from HC-SR04 ultrasonic sensors.
I see no problem with that device.
It simply acts as an analog switch and should have more than sufficient frequency response for the ultrasonic signals.
The TI CD4051BEE4 or a similar digital multiplexer would be a much better choice.
That's an analog/digital multiplexer.
How is that significantly different from the 74HC4051 as far as the transmission of ultrasonic signals?
 

Thread Starter

ardaeden

Joined Mar 1, 2019
2
I have checked the spec sheets of both CD and 74HC series. I am not an electronics professional but they both are described as analog multiplexers and the main difference between them are: CD series are CMOS and 74HCs are TTL. CDs can work on a larger range of voltage, 74HCs are 5 volt only but their TTL design makes them more faster switching devices. I hope I got it right.

I checked the trigger and echo pins of HC-SR04 on the oscilloscope. The longest measured distance from the sensor outputs a pulse of approx. 480 microseconds width on echo pin. Switching times of 4051s are in nanoseconds range. Looks fast enough. So I'll give it a try.

Thank you all.
 

AnalogKid

Joined Aug 1, 2013
11,036
HC stands for High speed CMOS; all HC devices are pure CMOS inside. With a 74 in front, it is a faster, 5 V-only version of the standard 4051. The reason the HC part is faster is that it has faster parts inside, not that it is TTL compatible. Because the sendor output is a TTL-level signal, you are not constrained to analog mux parts. Two 16:1 digital mux parts will do what you want.

Separate from that, the main problem with muxing these sensors is the response time of the Arduino. Youdon't say what you want in the way of response time, and that is critical. In order to capture accurately the width of 30 random pulses, you have to be scanning *very* fast. The time delay between a sensor edge changes and when the Arduino gets around to sampling the signal and noticing the change is an error component of the signal, and translates into extra length being added to the measurement. The datasheet says the output pulse varies between 118 us and 23 ms, or about 148 us per inch. What kind of distance resolution are you trying to achieve?

OTOH, if you are going to trigger one sensor, wait, read its output, then move on to the next sensor, the scanning timing is much less important. I doubt that you will be able to update all 30 sensors in one second.

ak
 
Top