Friday, June 21, 2019

Garmin Lidar Lite V3 on OrangePi PC

Connect Garmin Lidar Lite V3 to the OrangePi PC 40-pin header, either on I2C-0,

 3  
twi0_sda 
blue

 4
+5V        
red
 5 
twi0_sck
green

 6
gnd
black

or I2C-1,

27 
twi1_sda 
blue

28
twi1_sck 
green

Run i2c detection on bus 0:  i2cdetect 0; and the device is detected on 0x62, the default address.

Start by trying a Python version that uses smbus (or smbus2).  But all registers read 0.

Try Garmin's LIDARLite_RaspberryPi_Library.  Note that the library hard coded the i2c bus to i2c-1.  The code compiles and runs fine without modification.  Add code to do a register dump,
0x00
0x05
ACQ_COMMAND
0x01
0x26
STATUS
0x02
0x80
SIG_COUNT_VAL
0x04
0x08
ACQ_CONFIG_REG
0x09
0x67
VELOCITY
0x0c
0xe8
PEAK_CORR
0x0d
0x3d
NOISE_PEAK
0x0e
0x9a
SIGNAL_STRENGTH
0x0f
0x00
FULL_DELAY_HIGH
0x10
0x9e
FULL_DELAY_LOW
0x11
0x01
OUTER_LOOP_COUNT
0x12
0x05
REF_COUNT_VAL
0x14
0x00
LAST_DELAY_HIGH
0x15
0x05
LAST_DELAY_LOW
0x16
0x34
UNIT_ID_HIGH
0x17
0x30
UNIT_ID_LOW
0x18
0x00
I2C_ID_HIGH
0x19
0x00
I2C_ID_LOW
0x1a
0x00
I2C_SEC_ADDR
0x1c
0x00
THRESHOLD_BYPASS
0x1e
0x00
I2C_CONFIG
0x40
0x00
COMMAND
0x45
0x14
MEASURE_DELAY
0x4c
0x43
PEAK_BCK
0x52
0x00
CORR_DATA
0x53
0x00
CORR_DATA_SIGN
0x5d
0x00
ACQ_SETTINGS
0x65
0x00
POWER_CONTROL
Add 0.5 sec delay.  It prints distance at about 1 Hz.  The max update rate appears to be 300Hz , possibly limited by 100KHz I2C speed.  Occasionally, there are errors and the kernel prints error message,
sunxi_i2c_do_xfer()985 - [i2c1] incomplete xfer (status: 0x48, dev addr: 0x62)
 This is using armbian 5.38 with linux image sun8i 3.4.113.

Try to display the distance on the 1.8" LCD.   The simplest way is just to redirect the fb console.  Use con2fbmap to map a tty console to the fb.  And to set to a large font,
sudo setfont -C /dev/tty1 /usr/share/consolefonts/Lat15-TerminusBold14.psf.gz 
 For something fancier, need a graphics library.  The SDL library can be used.  Python Pygame can be set to use SDL to test it out.  Pygame works fine on the LCD.  It is very desirable to stay with Python.  So SWIG is used to add python interface to the Garmin library.  With that, the LCD displays the distance nicely.  However, there are some unresolved issues with console/framebuffer management.  The other option is just to write to the framebuffer directly as images.  Note that the format is hardware dependent; for this particular LCD, the format is packed 16-bit RGB (5/6/5).

No comments:

Post a Comment