2

i am currently trying to use more than 1 HC-SR04 on my BeagleBone Black (Rev C.) I tried the following script: https://github.com/luigif/hcsr04 And it is also working, but I have no idea, how I am able to change the used PINs and also how to use them in a serial way.

May someone help me please? best regards Ingo

Ingo P.
  • 21
  • 2

1 Answers1

0

One possible solution with the current code is to add two fast enough multiplexer to the echo/trigger pins of the sensors (8:1 or 16:1 depending on how many sensors you want to connect). The first will be to switch between trigger connections and the second to switch between echo connections. To control the mux you'll have connect the select lines of the mux to any of the GPIO pins(easiest are P8_14, P8_15, P8_16 and P8_18 since P8_11 and P8_12 are being used by PRU).

You'll have to change the present code something like this

/* Execute code on PRU */
printf(">> Executing HCSR-04 code\n");
prussdrv_exec_program(0, "hcsr04.bin");

/*Add code here to set GPIO pins high/low to choose the sensor */

/* Get measurements */

mux generally have 5v inputs and outputs, make sure that you step it down to 3V else you'll blow your beaglebone!

basic cheap mux have 35ns max response time which is more that sufficient to match the requirements

https://en.wikipedia.org/wiki/Multiplexer http://socrates.berkeley.edu/~phylabs/bsc/PDFFiles/DM74151A.pdf

Addition: Tie all the trigger pins together and mux only the echo pins so that you'll need only one mux instead of 2