Devantech-ultrasound

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

1 2 Anthony Rowe
2 8 Anthony Rowe
h1. Devantech SRF02 Ultrasound Interface
3 1 Anthony Rowe
4 8 Anthony Rowe
This page describes how to connect the Devantech SRF02 Ultrasound sensor to a [[FireFly]] sensor node.  This could be used for ranging, or with multiple [[FireFly]] nodes, difference in time of flight ranging can be done using the "fake" mode of the SRF02. 
5 8 Anthony Rowe
6 8 Anthony Rowe
For more information about controlling the SRF02, please see the following "technical specification":http://www.robot-electronics.co.uk/htm/srf02techSer.htm.
7 8 Anthony Rowe
8 2 Anthony Rowe
[[Image(ultrasound-schmatic.png)]]
9 2 Anthony Rowe
10 8 Anthony Rowe
Wire the SRF02 to the [[FireFly]] node as shown above.  The battery is optional, but allows the ultrasound transmitter to produce a stronger signal.
11 2 Anthony Rowe
12 3 Anthony Rowe
13 2 Anthony Rowe
[[Image(ultrasound-1.jpg,400)]]
14 2 Anthony Rowe
15 3 Anthony Rowe
This is a photograph of the ultrasound connector wired up according to the schematic.
16 2 Anthony Rowe
17 3 Anthony Rowe
18 2 Anthony Rowe
[[Image(stacked-header.jpg,400)]]
19 3 Anthony Rowe
20 1 Anthony Rowe
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.
21 2 Anthony Rowe
22 3 Anthony Rowe
23 2 Anthony Rowe
[[Image(jumper.jpg,400)]]
24 1 Anthony Rowe
25 8 Anthony Rowe
Adding a jumper to the Ultrasounds UART TX line is required for programming the [[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]] firmware.
26 1 Anthony Rowe
27 1 Anthony Rowe
28 2 Anthony Rowe
[[Image(programmer-connected.jpg,400)]]
29 1 Anthony Rowe
30 8 Anthony Rowe
The above photo shows the [[FireFly]] board with the ultrasound and the programmer connected.
31 3 Anthony Rowe
32 8 Anthony Rowe
33 8 Anthony Rowe
h2. Software
34 8 Anthony Rowe
35 4 Anthony Rowe
The following is the most basic software required to make the ultrasound device ping.
36 4 Anthony Rowe
37 4 Anthony Rowe
38 8 Anthony Rowe
<pre>
39 8 Anthony Rowe
<code class="c">
40 4 Anthony Rowe
void Task1()
41 4 Anthony Rowe
{
42 4 Anthony Rowe
//  Setup uart for ultraound board
43 4 Anthony Rowe
INIT_UART0( UART_BAUDRATE_9K6, (UART_OPT_NO_PARITY|UART_OPT_8_BITS_PER_CHAR|UART_OPT_TWO_STOP_BITS));
44 4 Anthony Rowe
ENABLE_UART0();
45 4 Anthony Rowe
46 4 Anthony Rowe
// Reset the ultrasound sensor
47 4 Anthony Rowe
putc0(0x96);
48 4 Anthony Rowe
49 4 Anthony Rowe
// Wait for the ultrasound module to reset
50 4 Anthony Rowe
nrk_wait_until_next_period();
51 4 Anthony Rowe
52 1 Anthony Rowe
  while(1) {
53 4 Anthony Rowe
        nrk_led_toggle(ORANGE_LED);
54 4 Anthony Rowe
        // Ultrasound default address is 0 by default
55 4 Anthony Rowe
        putc0(0x00);
56 4 Anthony Rowe
        // Ultrasound fire modulated pulse
57 1 Anthony Rowe
        putc0(0x5c);
58 4 Anthony Rowe
        nrk_wait_until_next_period();
59 4 Anthony Rowe
        }
60 4 Anthony Rowe
}
61 4 Anthony Rowe
62 8 Anthony Rowe
</code></pre>
63 4 Anthony Rowe
64 5 Anthony Rowe
The SRF02 can be instructed to listen only for the transmission from another module using a command of 0x56,0x57 or 0x58 depending on
65 4 Anthony Rowe
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.
66 4 Anthony Rowe
67 4 Anthony Rowe
 
68 8 Anthony Rowe
<pre>
69 4 Anthony Rowe
     86 0x56 Fake Ranging Mode - Result in inches
70 4 Anthony Rowe
     87 0x57 Fake Ranging Mode - Result in centimeters
71 4 Anthony Rowe
     88 0x58 Fake Ranging Mode - Result in micro-seconds
72 4 Anthony Rowe
73 4 Anthony Rowe
     92 0x5C Transmit an 8 cycle 40khz burst - no ranging takes place
74 8 Anthony Rowe
</code></pre>