Two years ago I decided to build an autonomous RC car. There were two main reasons I wanted to build an autonomous RC car, first I wanted to use an RTOS core I made in school, second reason was because I wanted to build an autonomous vehicle/robot.
I ordered a small 1/18th scale RC car to be the platform. The reason I chose an RC car to be the platform was because it has motor speed control electronics already built in. As the vehicles brains I selected Arduino Mega 2560. It has 256 kB of program memory and 8 kB of variable memory.
For the vehicles eyes I selected the well used and cheap HC-SR04 ultrasonic sensors. These sensors are controlled by giving a roughly a 10 uS pulse to the trigger pin. After that the sensor measures the distance and sends a pulse back with the echo pin, and the width of the pulse is proportional to the distance.
I wanted to check all the sensors with only five pins. One for trigger control, one for echo and three for sensor address. First I decided to use 74HC238 3 to 8 decoder to control the trigger and 74HC151 digital multiplexer to control the echo.Both of these would be driven with the same address pins. Next I thought only using diodes at the echo line so I could get away with only one IC. I tried this but it didn’t work mostly because of the diode voltage drop and higher resistance. After this next idea was to directly wire the sensors echo pin to the input capture pin, surprisingly it didn’t work either because how the sensors are wired. So finally I wen’t back to the original plan of using two IC’s this worked nicely.