Asked — Edited
Resolved Resolved by Jeremie!

Lidar Lite Causes Ez-B V4 To Disconnect After 150-400 Reads

Hello,

Lidar Lite causes EZ-B v4 to disconnect after 150-400 reads. Here are the symptoms:

With the sample code in the Lidar Lite tutorial my board is disconnecting and producing the error below. My board's firmware v16.6 hasn't been updated since my November 2014 purchase. I'm using a 9v 200MA wall wart to power the board. And a 5V 1Amp wall wart to power the Lidar Lite. The software disconnects and a non-flashing red light on the board with the blue light continuing to flash.

Below is the output of the error:

7/28/2015 1:42 AM - Attempting connection on 192.168.1.1:23 7/28/2015 1:42 AM - Connected to 192.168.1.1:23 7/28/2015 1:42 AM - EZ-B reports EZ-B v4 OS 7/28/2015 1:42 AM - Welcome to EZ-B v4 Beta! 7/28/2015 1:42 AM - EZ-B v4 ID: 63-54-0-0-47-255-59-57-56-37-38-37 7/28/2015 1:42 AM - Connected 7/28/2015 1:42 AM - Setting battery monitor voltage: 6.6 7/28/2015 1:42 AM - Setting battery protection: True 7/28/2015 1:42 AM - Setting i2c rate: 100000 7/28/2015 1:43 AM - Comm Err: System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.IO.Stream.ReadByte() at EZ_B.EZB.(Int32 , Byte[] ) 7/28/2015 1:43 AM - BbytesToExpect: 2 7/28/2015 1:43 AM - ? Received: 7/28/2015 1:43 AM - Disconnected

Here's my code:


$Inches=1
$cnt=0
:loop
$cnt=$cnt+1

ControlCommand("Lidar Lite", RunOnce)
$Inches=floor($lidar*0.39370)
 
print("Distance: " + $Inches+"Count="+$cnt)

sleep(100)
 
goto(loop)

Thanks for all you do,

Bill


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
Canada
#9  

This is what I was just reading on a google group about the Lidar lite April 2015 version (which we have at ezrobot):

Quote:

I recommend pwm mode for that lidar lite Version. They are releasing a new hardware version soon which has significant changes to the i2c interface, it had a blue label.

Link here

#10  

You can still pick up the Neato Lidar for around $100. Interface via UART and ASCII output.

#11  

Just confirmed my Febuary 2015 version of the LIDAR Lite isn't uselessly defective by getting it to run indefinitely without error on an Arduino Leonardo on the i2C port.

Per the link below, they apparently had an issue with Arduino's original I2C code so I was pointed to the link below for an alternative I2C library to include. Perhaps there's something in this link that might help without breaking existing ARC communications.

www.dsscircuits.com/index.php/articles/66-arduino-i2c-master-library

User-inserted image

This code contains some suggested work-a-rounds also that keep the unit from locking up. One issue was when the device would read a zero / zed it would freeze. It would also take longer to return longer distances and it a read request came in prior to it giving an answer it would also freeze.:


/* 

http://pulsedlight3d.com

This sketch demonstrates getting distance with the LIDAR-Lite Sensor

It utilizes the 'Arduino I2C Master Library' from DSS Circuits:
http://www.dsscircuits.com/index.php/articles/66-arduino-i2c-master-library 

You can find more information about installing libraries here:
http://arduino.cc/en/Guide/Libraries


*/

#include <I2C.h>
#define    LIDARLite_ADDRESS   0x62          // Default I2C Address of LIDAR-Lite.
#define    RegisterMeasure     0x00          // Register to write to initiate ranging.
#define    MeasureValue        0x04          // Value to initiate ranging.
#define    RegisterHighLowB    0x8f          // Register to get both High and Low bytes in 1 call.


void setup(){
  Serial.begin(9600); //Opens serial connection at 9600bps.     
  I2c.begin(); // Opens & joins the irc bus as master
  delay(100); // Waits to make sure everything is powered up before sending or receiving data  
  I2c.timeOut(50); // Sets a timeout to ensure no locking up of sketch if I2C communication fails
}

void loop(){
  // Write 0x04 to register 0x00
  uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses     
  while (nackack != 0){ // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
    nackack = I2c.write(LIDARLite_ADDRESS,RegisterMeasure, MeasureValue); // Write 0x04 to 0x00
    delay(1); // Wait 1 ms to prevent overpolling
  }

  byte distanceArray[2]; // array to store distance bytes from read function
  
  // Read 2byte distance from register 0x8f
  nackack = 100; // Setup variable to hold ACK/NACK resopnses     
  while (nackack != 0){ // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
    nackack = I2c.read(LIDARLite_ADDRESS,RegisterHighLowB, 2, distanceArray); // Read 2 Bytes from LIDAR-Lite Address and store in array
    delay(1); // Wait 1 ms to prevent overpolling
  }
  int distance = (distanceArray[0] << 8) + distanceArray[1];  // Shift high byte [0] 8 to the left and add low byte [1] to create 16-bit int
  
  // Print Distance
  Serial.println("Inches=");Serial.println(distance*0.39370);
}

Hope this helps because this is such a powerful, cheap and easy to use device.

Thanks,

Bill

PRO
Canada
#12  

Just got a response from a Pulsed Light rep about this issue:

Quote:

The issue with I2C communications is related to the fact that most micro-controller I2C drivers do not support a NACK response on the I2C bus - even though that is part of the standard I2C protocol. So to make your sensor work reliably the communications has to operate on a timing only basis. In other words, you would need to wait for the sensor to finish it’s acquisition before attempting to read the data. Typically 20 milliseconds is adequate to avoid the NACK condition. We are also aware of an issue with the Cortex M3/4 processors where any low to high transition of the SDA line without data would cause the I2C peripheral to lock up.

In V2 we’ve completely updated the hardware and this has resulted in improvements in the signal processing of the Signal Processing Core as well as hardwired the I2C port to the chip rather than running it through a soft interface. While these improvements have enhanced performance and added several new features to LIDAR-Lite, the V1 Silver Label sensor is not upgradeable to V2.

Sadly because we have a Cortex M3 processor on the ez-bv4 the LIDAR-Lite V1 issue stated above exists. Pulsed Light recommends that we upgrade to the V2 sensor. As @DJ suggested somewhere, they likely released the LIDAR-Lite sensor a bit too early and it wasn't compatible with a bunch of new hardware out there. Looks like they have fixed the issues now.

#13  

I looked up a Lidar lite version 2 on Ebay. Sells for $115.00 Has a blue label with a manufacturing date of July 2015. Does have improved I2c communications and operates at 5VDC.

#14  

Hi Jeremie,

It's the curse of the early adopter!:)

I'm able to connect to it on that other board through the EZB UART control with Luis Vazquez methods:
synthiam.com/Community/Questions/6491&page=2

I won't need microsecond levels of accuracy so timing issues won't be problematic.

Thanks much for looking into this.

Cheers,

Bill