The US8 peripheral gives you eight channels of distance measurement using the SRF04 ultrasonic distance sensor.
The us8 peripheral uses a us8 card to connect to up to eight SRF-04 ultrasonic sensors. The sensors have one input pin and one output pin. A 10 us pulse on the input starts a ping. The echo time of the ping is given as a pulse width on the output pin. The echo response starts about 100 us after the end of the start pulse. The FPGA measures the pulse width of the echo reply and does an auto-send of that time up to the host. To avoid multiple echoes the peripheral pings only one sensor at a time with pings sent every 60 millisecond.
You can select which sensors are enabled. The scan rate per sensor is faster if you disable unused sensors.
More information about the US8 card is available here cards/us8.html.
enable : enable/disable sensors.
Enable is a read-write resource that enables or disables individual sensors. Enabled sensors are specified as a two digit hexadecimal number terminated by a newline. The LSB of the enable register corresponds to the lowest numbered sensor, sensor #0. A set bit enables the sensor and a cleared bit disables it. You may wish to disable unused sensors since their presense slows the sampling process. At start-up all sensors are disabled.
distance : stream of sensor ID and distances.
The read-only distance resource gives the sensor number and distance reported by each sensor as the readings come in. The distance resource works with dpcat. This means that several programs can monitor at the same time if you're using distance measurements for both navigation and obsticle avoidance.
The output is a digit that indicates the sensor number followed by the distance in units of one-tenth of an inch. The sensor ID and readings are separated by a space and terminated by a newline. A distance of zero indicates that the sensor is not connected or is not responding. Typical output from the distance resource might appear as:
0 1055 1 55 2 0 3 1848 0 1094
Enable the first four distance sensors and start a data stream of distance measurements.
dpset us8 enable 0f dpcat us8 distance