Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Lidar-Lite and Labjack : 2 bytes I2C read


  • Please log in to reply
1 reply to this topic

#1 francoisdt

francoisdt
  • Members
  • 12 posts

Posted 08 July 2015 - 06:19 AM

Hi, 

 

I'm trying to get the LidarLite laser range finder to work with my Labjack UE9. This range finder outputs the distance measurement on two bytes via an I2C bus. 

 

I'm therefore using the low level command for I2C read. As suggested in the LidarLite's documentation ( http://kb.pulsedligh...ick-start-guide ), I'm first sending a command contaning two data bytes : 0x00 and 0x04, the first being the register to write, and the second the value to write, corresponding to an request for a measurement cycle. 

 

Then, and it's where it gets tricky, I have to read the measured value. The guide suggests to either read the high byte in a first register (0x0f), and the low byte in an other register (0x10), or to perform a 2-byte read on register 0x8f. 

 

I successfully realized the first method, by sending a first I2C command containing a single byte (0x0f, the first register address), reading the response containing the high byte, then sending a second I2C command containing the second register address and reading the low byte in the response. 

 

Problem is, I can't do this to quickly to avoid overpolling the I2C bus, so I'd really like to use the second method, and read the 2 bytes in a single call. But, when I tried to build an I2C command asking to read 2 bytes, and containing only 0x8f as command byte, I only get the low byte of the measurement in return, and a second value that does'nt make sense. 

 

Is there a way to specify that I want a two byte read starting from a specific register? Because on Arduino, there is a dedicated function taking as argument the register to read from, and the number of bytes to read...



#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 09 July 2015 - 02:47 AM

I would try reading two bytes starting from 0x0F. In my experience it is unusual to start a value that consumes more than one register on an odd address, so I would try adjacent addresses as well.

 

Can you provide a few of the results that you are getting from 0x8F.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users