-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
Dear all,
We are interfacing the Garmin LIDAR-LITE V3HP with our hardware and using the datasheet to send the i2C commands to make a distance measurements. We use ATmega1284p AVR as Host MCU.
It seems that what we receive is garbage, and/or not correct measurement data. Below is the i2C session which we initiate with device. Any information regarding the i2C transaction and its commands being sent to achieve the correct data will be highly appreciated....
David
uint8_t receiver_reply;
i2cStart(); // start a i2C session
i2cSend(0xC4); // LIDAR address with write bit
receiver_reply = TWSR; // MCU register with session codes, to checkup on errors....
receiver_reply = receiver_reply & 0b11111000;
printBinaryByte(receiver_reply);
printString("\r\n");
if(receiver_reply == 0x18){ // if Ack receieved from LIDAR
printString("\r\n issuing start condition ok, device accessible\r\n");
i2cSend(0x00); // send the register address
receiver_reply = TWSR; // again checkup on Ack and errors.....
receiver_reply = receiver_reply & 0b11111000;
printBinaryByte(receiver_reply);
printString("\r\n");
if(receiver_reply == 0x28){
printString("\r\n register 0x00 address sent >> ok\r\n");
i2cSend(0x04); // writing 0x04 to register 0x00 to start a distance measurement
receiver_reply = TWSR; // again checkup on Ack and errors.....
receiver_reply = receiver_reply & 0b11111000;
printBinaryByte(receiver_reply);
printString("\r\n");
i2cStop();
if(receiver_reply == 0x28){ // again checkup on Ack and errors.....
printString("\r\n wrote 0x04 to register 0x00\r\n");
i2cStart();
i2cSend(0xC5); // put LIDAR in Read mode
receiver_reply = TWSR; // again checkup on Ack and errors.....
receiver_reply = receiver_reply & 0b11111000;
printBinaryByte(receiver_reply);
printString("\r\n");
if(receiver_reply == 0x40){
i2cSend(0x01);
for(int i = 0; i < 100; i ++){
uint8_t lidar_busy_flag = i2cReadAck();
printBinaryByte(lidar_busy_flag);
printString("\r\n");
if((lidar_busy_flag & 0b00000001) == 0x00){
i2cSend(0x0f); // send address of highbyte
receiver_reply = TWSR;
receiver_reply = receiver_reply & 0b11111000;
printBinaryByte(receiver_reply);
uint8_t distance_high = i2cReadAck(); // read highbyte
i2cSend(0x01); // send address of lowbyte
uint8_t distance_low = i2cReadNoAck(); // read lowbyte
uint16_t range = distance_high << 8;
range = range | distance_low;
printWord(range);
printString("\r\n");
}
else{
printString("busy flag!");
printBinaryByte(lidar_busy_flag);
printString("\r\n");
}
}
Metadata
Metadata
Assignees
Labels
No labels