I'm working on a robot that uses an SRF08 for object detection. It uses a 16F628A on a board with little debugging capability. I got the SRF08 working well on a 16F877A that can print output to a terminal program. However, when I transfer the program, with an *exact* copy of the i2c routine, to the 628A it appears to output values of zero. The SRF08 signals the correct device address has been reached with an LED flash. It flashes about once each second which seems correct. Also, 1.8k pull-up resistors have been installed on RA2 and RA3. I've been working on this for two days with no progress. I've been using the head servo to try to trouble shoot the problem. I've also gone through the 628A data sheet but haven't come across anything there. Does anyone have any other ideas I could try or some insight into what is happening? Here is the program: #include <16F628A.H> #fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP #use delay(clock = 20000000) #use i2c(Master,sda=PIN_A3,scl=PIN_A2,RESTART_WDT) #define HEAD PIN_B6 main() { int i; int16 range; setup_comparator(NC_NC_NC_NC); while(1) { i2c_start(); //initate start condition i2c_write(0xE0); //device address i2c_write(0x00); //register address i2c_write(0x50); //set units to inches i2c_stop(); delay_ms(105); //wait for returning ping i2c_start(); //initiate a new start condition i2c_write(0xE0); //device address i2c_write(0x02); //address of high byte register i2c_start(); i2c_write(0xE1); //device address but read range = i2c_read(); //read first byte range = range << 8; // shift value left 1 byte range += i2c_read(0); //read second byte and add to 1st i2c_stop(); for (i=0;i<50;i++) { output_high(HEAD); delay_us(1100); delay_us(range*10); output_low(HEAD); delay_ms(18); } } } Thanks, Harry -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist