LIDAR-Lite Interfacing -- can't read distance

I’m having trouble getting the LIDAR-Lite interfaced to the roboRIO, and could use some input. My code is based on this Java class: https://gist.github.com/tech2077/c4ba2d344bdfcddd48d2.

For reference, here’s the LIDAR-Lite manual: https://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/5006168099/original/LIDAR-Lite-Operating-Manual.pdf?AWSAccessKeyId=AKIAJ2JSYZ7O3I4JO6DA&Expires=1423437983&Signature=28fYertuGqMziLxwyefM6Qrve9M%3D&response-content-type=application%2Fpdf

Power is supplied via one of the prior year KOP 25w 12v-5v regulators, and I’ve verified that there’s 5v on the output. The red wire (pin 1) from the LIDAR-Lite is connected to the yellow (+5) wire and pin 6 is connected to the black (-) wire on the regulator.

Pin 4 on the LIDAR-Lite (SCL) is connected to pin 32 on the MXP port, and pin 5 (SDA) is connected to pin 34.

Here’s some code snippets – initialization (from the constructor):


	this->Lidar = new I2C(port, LIDAR_ADDR);
	if (this->Lidar->AddressOnly())
	{
		printf("[LIDARLite] Device found.
");
	}
	else
	{
		printf("[LIDARLite] Device not found.
");
	}

My reading logic:


void LIDARLite::ReadValue() {
	bool ack = false;
	int count = 0;

	while (!ack && count++ < RETRIES)
	{
		ack = this->Lidar->Write(LIDAR_CONFIG_REGISTER, LIDAR_MEASURE);
		Sleep(10);
	}
	if (!ack)
	{
		printf("[LIDARLite] config failed after %d tries.
", count);
		return;
	}

	ack = false;
	count = 0;
	while (!ack && count++ < RETRIES)
	{
		ack = this->Lidar->Read(LIDAR_DISTANCE_REGISTER, 2, this->readBytes);
		Sleep(10);
	}

	if (!ack)
	{
		printf("[LIDARLite] read failed after %d tries.
", count);
		return;
	}
	printf("[LIDARLite] read completed.
");


	CRITICAL_REGION(semaphore)
	{
		this->distance = this->readBytes[0] << 8 | this->readBytes[1];
	}
	END_REGION;
}

Useful values from the header:


	const int LIDAR_ADDR = 0x62;
	const int LIDAR_CONFIG_REGISTER = 0x00;
	const int LIDAR_DISTANCE_REGISTER = 0x8f;

	static const int NS_PER_MS = 1000000;
	const int RETRIES = 10;

	const int LIDAR_MEASURE = 0x04;
	I2C *Lidar;
	Notifier *updateNotifier;
	int distance = 0;
	unsigned char readBytes[2];
	MUTEX_ID semaphore;

The call to config succeeds after a couple retries, which I’m interpreting as telling me that the unit is on, but the calls to Read never return an ack. I’ve tried bumping up the timeout, but that doesn’t seem to help. Any thoughts?

We had issues as well. We ended up putting a pull-up resistor on the SCL pin. Here is our example:http://www.chiefdelphi.com/forums/showthread.php?t=135043

It is Java, but the look will be similar.