Devantech-ultrasound

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

1 7 Anthony Rowe
= Devantech SRF02 Ultrasound Interface =
2 2 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. 
3 2 Anthony Rowe
4 6 Anthony Rowe
For more information about controlling the SRF02, please see the following [http://www.robot-electronics.co.uk/htm/srf02techSer.htm technical specification].
5 2 Anthony Rowe
6 2 Anthony Rowe
[[Image(ultrasound-schmatic.png)]]
7 2 Anthony Rowe
8 3 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.
9 2 Anthony Rowe
10 3 Anthony Rowe
11 2 Anthony Rowe
[[Image(ultrasound-1.jpg,400)]]
12 2 Anthony Rowe
13 3 Anthony Rowe
This is a photograph of the ultrasound connector wired up according to the schematic.
14 2 Anthony Rowe
15 3 Anthony Rowe
16 2 Anthony Rowe
[[Image(stacked-header.jpg,400)]]
17 2 Anthony Rowe
18 3 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.
19 2 Anthony Rowe
20 3 Anthony Rowe
21 2 Anthony Rowe
[[Image(jumper.jpg,400)]]
22 2 Anthony Rowe
23 3 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.
24 2 Anthony Rowe
25 3 Anthony Rowe
26 2 Anthony Rowe
[[Image(programmer-connected.jpg,400)]]
27 3 Anthony Rowe
28 3 Anthony Rowe
The above photo shows the FireFly board with the ultrasound and the programmer connected.
29 4 Anthony Rowe
30 4 Anthony Rowe
== Software ==
31 4 Anthony Rowe
The following is the most basic software required to make the ultrasound device ping.
32 4 Anthony Rowe
33 4 Anthony Rowe
34 4 Anthony Rowe
{{{
35 4 Anthony Rowe
#!c
36 4 Anthony Rowe
void Task1()
37 4 Anthony Rowe
{
38 4 Anthony Rowe
//  Setup uart for ultraound board
39 4 Anthony Rowe
INIT_UART0( UART_BAUDRATE_9K6, (UART_OPT_NO_PARITY|UART_OPT_8_BITS_PER_CHAR|UART_OPT_TWO_STOP_BITS));
40 4 Anthony Rowe
ENABLE_UART0();
41 4 Anthony Rowe
42 4 Anthony Rowe
// Reset the ultrasound sensor
43 4 Anthony Rowe
putc0(0x96);
44 4 Anthony Rowe
45 4 Anthony Rowe
// Wait for the ultrasound module to reset
46 4 Anthony Rowe
nrk_wait_until_next_period();
47 4 Anthony Rowe
48 4 Anthony Rowe
  while(1) {
49 4 Anthony Rowe
        nrk_led_toggle(ORANGE_LED);
50 4 Anthony Rowe
        // Ultrasound default address is 0 by default
51 4 Anthony Rowe
        putc0(0x00);
52 4 Anthony Rowe
        // Ultrasound fire modulated pulse
53 4 Anthony Rowe
        putc0(0x5c);
54 4 Anthony Rowe
        nrk_wait_until_next_period();
55 4 Anthony Rowe
        }
56 4 Anthony Rowe
}
57 4 Anthony Rowe
58 4 Anthony Rowe
}}}
59 4 Anthony Rowe
60 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
61 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.
62 4 Anthony Rowe
63 4 Anthony Rowe
 
64 4 Anthony Rowe
{{{
65 4 Anthony Rowe
     86 0x56 Fake Ranging Mode - Result in inches
66 4 Anthony Rowe
     87 0x57 Fake Ranging Mode - Result in centimeters
67 4 Anthony Rowe
     88 0x58 Fake Ranging Mode - Result in micro-seconds
68 4 Anthony Rowe
69 4 Anthony Rowe
     92 0x5C Transmit an 8 cycle 40khz burst - no ranging takes place
70 4 Anthony Rowe
}}}