Devantech-ultrasound

Version 7 (Anthony Rowe, 10/26/2008 05:54 pm) → Version 8/9 (Anthony Rowe, 10/26/2008 05:54 pm)


h1.
= Devantech SRF02 Ultrasound Interface

=
This page describes how to connect the Devantech SRF02 Ultrasound sensor to a [[FireFly]] FireFly sensor node. This could be used for ranging, or with multiple [[FireFly]] FireFly nodes, difference in time of flight ranging can be done using the "fake" mode of the SRF02.

For more information about controlling the SRF02, please see the following "technical specification":http://www.robot-electronics.co.uk/htm/srf02techSer.htm. [http://www.robot-electronics.co.uk/htm/srf02techSer.htm technical specification].

[[Image(ultrasound-schmatic.png)]]

Wire the SRF02 to the [[FireFly]] FireFly node as shown above. The battery is optional, but allows the ultrasound transmitter to produce a stronger signal.

[[Image(ultrasound-1.jpg,400)]]

This is a photograph of the ultrasound connector wired up according to the schematic.

[[Image(stacked-header.jpg,400)]]

By soldering a header on top of the receptical, it is possible to program and receive debugging data from a node even with the ultrasound module attached. Only do this for boards that will be used for debugging. Otherwise just solder directly onto the receptical.

[[Image(jumper.jpg,400)]]

Adding a jumper to the Ultrasounds UART TX line is required for programming the [[FireFly]] FireFly node while the ultrasound board is attached. Since the programming board uses the same UART lines, if the ulrasound TX is left connected during downloads, the ultrasound board may send signals that corrupt the [[FireFly]] FireFly firmware.

[[Image(programmer-connected.jpg,400)]]

The above photo shows the [[FireFly]] FireFly board with the ultrasound and the programmer connected.

h2.


==
Software

==
The following is the most basic software required to make the ultrasound device ping.

<pre>
<code class="c">
{{{
#!c
void Task1()
{
// Setup uart for ultraound board
INIT_UART0( UART_BAUDRATE_9K6, (UART_OPT_NO_PARITY|UART_OPT_8_BITS_PER_CHAR|UART_OPT_TWO_STOP_BITS));
ENABLE_UART0();

// Reset the ultrasound sensor
putc0(0x96);

// Wait for the ultrasound module to reset
nrk_wait_until_next_period();

while(1) {
nrk_led_toggle(ORANGE_LED);
// Ultrasound default address is 0 by default
putc0(0x00);
// Ultrasound fire modulated pulse
putc0(0x5c);
nrk_wait_until_next_period();
}
}

</code></pre>

}}}

The SRF02 can be instructed to listen only for the transmission from another module using a command of 0x56,0x57 or 0x58 depending on
what range type you wish to be generated. The 40khz pulse can then be fired from another module with a command of 0x5C, this will just transmit and not listen for a response.


<pre>
{{{
86 0x56 Fake Ranging Mode - Result in inches
87 0x57 Fake Ranging Mode - Result in centimeters
88 0x58 Fake Ranging Mode - Result in micro-seconds

92 0x5C Transmit an 8 cycle 40khz burst - no ranging takes place
</code></pre>

}}}