currently getting the TinyLiDAR product connected to a PIC programmed in C. It works, seems to work well, I am not getting the sample speeds in single or continuous modes that are claimed in the data sheet. 60HZ speed is claimed, I am getting about 23 HZ. any special setup to get the higher speeds.
my basic code loop is as follows:
[code]while(1) { // endless loop
delay_ms(35); //35ms delay needed or loop locks.
i2c_start();
i2c_write(LIDAR | WR); //we are writing
i2c_write(‘D’); // issue single ‘distance read’ command
i2c_stop();
delay_us(2);
i2c_start(); //restart
i2c_write(LIDAR | RD); //select the read address
msb = i2c_read(); //now read
lsb = i2c_read(0);
i2c_stop();
} // end while loop[/code]
the delay_ms(35) is the minimum delay, anything less will lock the loop up. The stop and start commands are necessary between the write and read commands or the loop will lock up after about five times.
Thoughts are welcome on what I can do to increase speed.
Hi,
It seems like your issue would be related to how your code and I2C library work (and possibly the hardware it runs on).
We tried a few of the examples provided by the manufacturer (see the product page, under Useful Links) on an Arduino Uno and it seems like we get very fast sampling (response rate reaches > 900 Hz, as seen below).
With the “minimalRead” example, we get the expected one reading per 100 ms, as seen here:
If we comment the “delay(100);” our full measurement (start, send “D”, read 2 bytes, stop) takes about 0.55 ms. Every few blocks of readings (~12), there seems to be a delay from the TinyLIDAR, causing a slowdown (probably the buffer is empty). Therefore, the overall rate seems to be about 12 readings every 16 ms, or ~750 Hz. See the logic analyzer screenshots below for details.
Therefore, we recommend that you check your code carefully since it is most likely doing something wrong. As a side note, delays should not needed in I2C communications since the slave can hold the line when it is not ready, therefore blocking the master until it is ready to transmit. Since you seem to be having issues when you remove delays it would mean your I2C code or how you use it is at fault.
Sincerely,