SRF08 sensor code
June 11, 2008, 6:24 pm
Filed under: process

There are a number of Arduino code examples out there to hook up a Devantech Ultrasonic SRF08 sensor, however only one (found here), that I saw, clearly shows how to change the two main customizable features; the analog gain, and the range. However, after much trouble shooting it was discovered that there are a few typos in the code sections referring changing these options.

The full spec sheet for the SRF08 can be found here on the Robot Electronics website. This page shows the correct addresses and codes to properly communicate with it. The example Arduino code from the website above makes a few mistakes with reference to these numbers.

One under the “sensitivity adjust” section when sending the analog gain code to address 01. The current 0×21 is not a valid “gain hex register” according to the spec sheet. I changed it to 0×00 giving it a max gain of 94.

There’s also a mistake under the “range select” section where it needs to call address 2 to write the hex to, however it’s written as 0×20 instead of 0×02. Then the next line, sending 0×00, will give it a range of 43mm. This can be changed to any number of options as found on the spec sheet. Typing 0×8C will give it it’s maximum 6m range.

In addition, comments under both sections referring to “0×51 centimeters” and “0×52 ping seconds” are not relevent in this specific case. The section to change the feedback (what it measures in) is done in step 1 of the code, where these same comments then appear again.

Here is the code I used with the appropriate edits. Also, I made them both functions that I could call just in order to clean up the actual process loop.

//setSensitivity() sets the max range
void setSensitivity(int address){
//start i2c transmission
Wire.beginTransmission(address);

//send command
Wire.send(0×01); //set to reg1
Wire.send(0×00); //hex code for sensitity (0×00 = 94)

//end i2c trans
Wire.endTransmission();
}

//setRange() sets the max range
void setRange(int address){
//start i2c transmission
Wire.beginTransmission(address);

//send command
Wire.send(0×02); //set to reg2
Wire.send(0xFF); //hex code for range (0xFF = max avail)

//end i2c trans
Wire.endTransmission();
}

/AB



reflection in front of the school
June 10, 2008, 6:23 pm
Filed under: Uncategorized | Tags:



top mirror in action
June 10, 2008, 6:19 pm
Filed under: Uncategorized | Tags:



building the model (on the roof!)
June 10, 2008, 6:05 pm
Filed under: Uncategorized | Tags:


designs II
June 10, 2008, 5:59 pm
Filed under: Uncategorized | Tags:

the two options



building the model (on the ground)
June 10, 2008, 5:54 pm
Filed under: Uncategorized | Tags:


different designs
June 10, 2008, 5:48 pm
Filed under: Uncategorized | Tags:

first design steps