This is the Revision B verion of the SonarDT1 RoboBrick. The status of this project is finished.

SonarDT1 Robobrick (Revision B)

Table of Contents

This document is also available as a PDF document.

1. Introduction

The Sonar1 RoboBrick is used to provide a RoboBrick interface to the SRF04 sonar range finder from Devantech.

2. Programming

The SonarDT1 RoboBrick is focused on operating the Devantech SRF04. In addition, it has the ability to control 1 servo, so that the SonarDT1 RoboBrick can be mounted on a standard hobby servo as a scanning platform. Lastly, there are some LED's that can provide direct feedback on the current distance being measured by the SRF04. Only the low order 5 bits of the high order byte are shown. (The B revision has a hardware bug that prevents D1 from lighting; this will be fixed in the next revision.)

There are some commands to automatically scan a server back and forth taking readings as it scans. The servo is started at an initial position (see Set/Read Sweep Initial Position.) There is a fixed distance between servo positions (see Set/Read Sweep Increment.) There is a time delay that is used to between changing sweep position that is measured in units of approximiately 20mS (see Set/Read Sweep Delay.) Thers are a total number of different positions that must be less than or equal to 16 (see Set/Read Sweep Positions.) Each time the servo stops a position, a reading is taken and stored into an distance array. The distance array is read using the Read Array High and Low and the Read Array High Only commands. There is a sweep counter that is incremented each time the servo changes directions (see Set/Read Sweep Counter.) Finally, enabling the sweep servo also turns the sonar sensor into continuous measurement mode (See Set/Read Sweep Enable.)

The SonarDT1 commands are summarized in the table below:

x
Command Send/
Receive
Byte Value Discussion
7 6 5 4 3 2 1 0
Read Distance Low Send 0 0 0 0 0 0 0 0 Return the low order byte llllllll of the distance
Receive l l l l l l l l
Read Distance High Send 0 0 0 0 0 0 0 1 Return the high order byte hhhhhhhh of the distance
Receive h h h h h h h h
Read Distance High and Low Send 0 0 0 0 0 0 1 0 Return the low and high order bytes llllllll hhhhhhhh of the distance
Receive l l l l l l l l
Receive h h h h h h h h
Trigger Distance Measure Send 0 0 0 0 0 0 1 1 Trigger a Single Distance Measurement
Disable Servo Send 0 0 0 0 0 1 0 0 Disable Servo
Enable Servo Send 0 0 0 0 0 1 0 1 Enable Servo
Disable Continuous Measurement Send 0 0 0 0 0 1 1 0 Disable Continuous Measurement
Enable Continuous Measurement Send 0 0 0 0 0 1 1 1 Enable Continuous Measurement
Increment Servo Send 0 0 0 0 1 0 0 0 Increment servo position by one.
Decrement Servo Send 0 0 0 0 1 0 0 1 Decrement servo positon by one.
Read Servo Send 0 0 0 0 1 0 1 0 Return servo value ssssssss of the distance
Receive s s s s s s s s
Read Enables Send 0 0 0 0 1 0 1 1 Return servo enable s and continuous distance measurement m
Receive 0 0 0 0 0 0 m s
Set Servo Low Send 0 0 0 1 l l l l Set the low order 4 bits of the servo position to llll.
Set Servo High Send 0 0 1 0 h h h h Set the high order 4 bits of the servo position to hhhh.
Set Sweep Initial Position Send 0 1 0 0 0 0 0 0 Set sweep initial position to pppppppp.
Send p p p p p p p p
Set Sweep Increment Send 0 1 0 0 0 0 0 1 Set the sweep increment to iiiiiiii.
Send i i i i i i i i
Set Sweep Positions Send 0 1 0 0 0 0 1 0 Set the total number of sweep positions to ppppp (≤16).
Send 0 0 0 p p p p p
Set Sweep Delay Send 0 1 0 0 0 0 1 1 Set the sweep delay to dddddddd.
Send d d d d d d d d
Set Sweep Counter Send 0 1 0 0 0 1 0 0 Set the sweep counter to cccccccc.
Send c c c c c c c c
Set Sweep Enable Send 0 1 0 0 0 1 1s. Set the sweep enable to s. Enabling the sweep flag also enables continuous measurement.
Read Sweep Initial Position Send 0 1 0 0 1 0 0 0 Read the sweep low position of pppppppp.
Receive p p p p p p p p
Read Sweep Increment Send 0 1 0 0 1 0 0 1 Read the sweep increment iiiiiiii.
Receive i i i i i i i i
Read Sweep Positions Send 0 1 0 0 1 0 1 0 Read the total number of sweep positions ppppp.
Receive 0 0 0 p p p p p
Read Sweep Delay Send 0 1 0 0 1 0 1 1 Read the sweep delay dddddddd.
Receive d d d d d d d d
Read Sweep Counter Send 0 1 0 0 1 1 0 0 Read the sweep counter cccccccc.
Receive c c c c c c c c
Read Sweep Enable Flag Send 0 1 0 0 1 1 0 1 Read the sweep enable flag s.
Receive 0 0 0 0 0 0 0 s
Read Array High and Low Send 0 1 0 1 i i i i Read sonar distance array value at index iiii (≤15). Both the high order and order bytes of hhhhhhhh llllllll are returned.
Receive h h h h h h h h
Receive l l l l l l l l
Read Array High Only Send 0 1 1 0 i i i i Read sonar distance array value at index iiii (≤15). Only high order byte of hhhhhhhh is returned.
Receive h h h h h h h h
Shared Commands Send 1 1 1 1 1 c c c Execute shared command ccc.

3. Hardware

The hardware consists of a circuit schematic and a printed circuit board.

3.1 Circuit Schematic

The schematic for the Sonar1 RoboBrick is shown below:

SonarDT1 Schematic

The parts list kept in a separate file -- sonardt1.ptl.

3.2 Printed Circuit Board

The printed circuit board files are listed below:

sonardt1_back.png
The solder side layer.
sonardt1_front.png
The component side layer.
sonardt1_artwork.png
The artwork layer.
sonardt1.gbl
The RS-274X "Gerber" back (solder side) layer.
sonardt1.gtl
The RS-274X "Gerber" top (component side) layer.
sonardt1.gal
The RS-274X "Gerber" artwork layer.
sonardt1.drl
The "Excellon" NC drill file.
sonardt1.tol
The "Excellon" tool rack file.

3.3 Construction Instructions

The construction instructions are found in a separate file to make them a little more printer friendly.

4. Software

The software for the SonarDT1 RoboBrick is in the following files:

sonardt1.ucl
The µCL source code.
sonardt1.asm
The PIC16F628 assembly code.
sonardt1.lst
The listing file.
sonardt1.hex
The Intel® hex file.

5. Issues

The following fabrication issues came up:


Copyright (c) 2001-2002 by Wayne C. Gramlich. All rights reserved.