Lidar Lite V4

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
TekTao
 
Posts: 9
Joined: Fri Sep 08, 2017 11:30 am

Re: Lidar Lite V4

Post by TekTao »

dastels wrote:The arduino library from Garmin provides a method for setting the alternate address. What you have looks good, but there's more to their method: (optionally) disabling the default address, and disabling/relocking flash, plus 100mS delays at appropriate times. See https://www.kickstarter.com/projects/co ... escription

Dave
Is this the correct link for what you want me to look at?

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: Lidar Lite V4

Post by dastels »

Doh... my copy buffer was stale for some reason.. I swear I copied the github link. Let's try again: https://github.com/garmin/LIDARLite_Ard ... _v4LED.cpp

That looks better. BTW if you fancy Norse themed D&D, Svilland does look pretty sweet, though the kickstarter is long closed.

I fixed the original link for posterity.

Dave

User avatar
TekTao
 
Posts: 9
Joined: Fri Sep 08, 2017 11:30 am

Re: Lidar Lite V4

Post by TekTao »

I attempted this and it gets me nothing

Code: Select all

sensor._write_reg(0xEA,0x11)
time.sleep(0.1)
sensor._write_reg(0x16,0x00) 
time.sleep(0.1)
sensor._write_reg(0x17,0x00)
time.sleep(0.1)
sensor._write_reg(0x18,0x00)
time.sleep(0.1)
sensor._write_reg(0x19,0x00)
time.sleep(0.1)
sensor._write_reg(0x1A,0x55) # any new address
time.sleep(0.1)
sensor._write_reg(0x1B,0x02) # use new address
print('turkey')
Adding the sleep into this does not seem to work. Also, I noticed on the Arduino version that the code sends all of this information to address 0x16. I do not understand why this works on the Arduino I2C address change function.

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: Lidar Lite V4

Post by dastels »

It uses a multi-register write starting at 0x16 in a single transaction. That might be what you need to do.

You put a delay after each byte. The C++ code doesn't do that. It has a delay:
- after enabling flash
- after writing the new address
- after disabling the default
- after disabling flash

When you get it working, we can add it to the class.

Dave

User avatar
imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Lidar Lite V4

Post by imhavoc »

Using Dave's library, I'm getting solid readings until the whole thing comes crashing down:

Code: Select all

python3 lidartest.py 
(355,)
(353,)
(354,)
(354,)
(353,)
(354,)
(353,)
(354,)
(353,)
(353,)
(354,)
(352,)
Traceback (most recent call last):
  File "lidartest.py", line 15, in <module>
    print((sensor.distance,))
  File "/home/pi/adafruit_lidarlite.py", line 132, in distance
    return self.read_distance(self._bias_count == 0)
  File "/home/pi/adafruit_lidarlite.py", line 121, in read_distance
    self.wait_while_busy()
  File "/home/pi/adafruit_lidarlite.py", line 155, in wait_while_busy
    while self.status & STATUS_BUSY:
  File "/home/pi/adafruit_lidarlite.py", line 139, in status
    i2c.write_then_readinto(buf, buf)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_bus_device/i2c_device.py", line 131, in write_then_readinto
    in_end=in_end,
  File "/home/pi/.local/lib/python3.7/site-packages/busio.py", line 183, in writeto_then_readfrom
    stop=stop,
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 88, in writeto_then_readfrom
    address, buffer_out[out_start:out_end], in_end - in_start
  File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_PureIO/smbus.py", line 273, in read_i2c_block_data
    ioctl(self._device.fileno(), I2C_RDWR, request)
OSError: [Errno 121] Remote I/O error

User avatar
imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Lidar Lite V4

Post by imhavoc »

Oh, by the way, I'm running a Raspberry Pi 3A.

User avatar
imhavoc
 
Posts: 42
Joined: Thu Oct 05, 2017 10:32 pm

Re: Lidar Lite V4

Post by imhavoc »

I am still getting failed samples, but the script stopped crashing when I gave up on printing the exception error.

Code: Select all

import time
import board
import busio
import adafruit_lidarlite

# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)

# Default configuration, with only i2c wires
sensor = adafruit_lidarlite.LIDARLiteV4LED(i2c)

while True:
    try:
        distance = sensor.distance
        print((distance,))
        time.sleep(1) # you can remove this for ultra-fast measurements!
    except:
        print ("failed sample")

User avatar
Robaird
 
Posts: 1
Joined: Sat Oct 22, 2016 9:26 pm

Re: Lidar Lite V4

Post by Robaird »

Thank you dastels, for the revised v4 module!

Someone should drop a note on Garmin Lidar Lite v4 product page to this thread--rather than the current link to the v3 adafruit.lidar.msy module which after a couple hours of angst, I now know isn't forward compatible with the v4. Thank goodness you posted the link to this thread on github--saved halloween, haha (using the Lidar Lite v4 and the Feather RP2040 as a distance triggered air harp playing a couple software synths).

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”