Harry Mueller
Joined: 17 Oct 2005 Posts: 116
|
SRF08 with 16F877A using I2C not working |
Posted: Tue Mar 14, 2006 1:08 pm |
|
|
Just wondering if anyone has any experience with the SRF08 sonar unit from Acroname. I've got 5 volts going to the unit and a small LED tells me I've got the I2C address correct.
The I2C address of the unit is 0xE0, the unit specification to go in that address for inches is 0x50 and 17 separate echos from one ping can be read from 0x02 to 0x23.
When I read the first four locations I just get an "ff".
Here is my code: Code: | #include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#use i2c(Master,sda=PIN_B1,scl=PIN_B0)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
main()
{
int i;
int echo_reading[4];
port_b_pullups(TRUE);
while(1)
{
i2c_start();
i2c_write(0xE0);
i2c_write(0x50);
delay_ms(66);
echo_reading[0]=i2c_read(0x02);
echo_reading[1]=i2c_read(0x03);
echo_reading[2]=i2c_read(0x04);
echo_reading[3]=i2c_read(0x05);
printf("one = %x two= %x three = %x four= %x",echo_reading[0],echo_reading[1],echo_reading[2],echo_reading[3]);
}
}
|
Thanks, Harry |
|