VL53LOX, has anyone tried using it with a PICAXE ?

Buzby

Senior Member
Hi All,

The VL53LOX 'Time of flight' range sensor looks really attractive. It's got 2m range, needs no special target, and interfaces using I2C.

So I bought one, then read the datsheet. ( Some here may notice I got this sequence back to front. ) This when I found the datasheet doesn't have the details of the register mapping etc., it just refers to the API.

Now I'm faced with decoding hundreds of lines of cryptic C to try finding the basic stuff needed to use this device.

Has anyone done this donkey work already, or am I going to be the first ?.

Cheers,

Buzby
 

Pongo

Senior Member
Hi All,

The VL53LOX 'Time of flight' range sensor looks really attractive. It's got 2m range, needs no special target, and interfaces using I2C.

So I bought one, then read the datsheet. ( Some here may notice I got this sequence back to front. ) This when I found the datasheet doesn't have the details of the register mapping etc., it just refers to the API.

Now I'm faced with decoding hundreds of lines of cryptic C to try finding the basic stuff needed to use this device.

Has anyone done this donkey work already, or am I going to be the first ?.

Cheers,

Buzby

I have the cheap ebay module with a UART output. So yes, I have one working, but no, I can't help you with the registers :( One thing that's not completely obvious is that it will not work well in sunlight, but indoors and at night it works well.
 

Buzby

Senior Member
I have the cheap ebay module with a UART output. So yes, I have one working, but no, I can't help you with the registers :( One thing that's not completely obvious is that it will not work well in sunlight, but indoors and at night it works well.
I'm glad I asked !. I didn't see the UART version when I searched. It will be so much easier to spend a few $ than decode a few K lines of code.

However, your statement about 'not work in sunlight' rather puts the kybosh on the whole plan, as the intention was for outdoor use, especially on sunny days !.

Cheers,

Buzby
 

hippy

Technical Support
Staff member
I did some investigation when I first heard mention of the VL53L0X on the forum and came to the same conclusion; there's no handy description of what to do, only example C code which seems to do it.

Some of the code seemed simpler than others so it's likely a case of trawling through code, finding that which is easier to understand and convert, reading blogs which describe why the code is as it is.

Other than a brief foray in that direction I didn't do anything further because I don't have a VL53L0X. It did seem to me it would be possible to get it working with a PICAXE and wouldn't be as complicated as some code made it seem.

A UART version did not appear to exist at the time. I would agree that's probably the route to take; let someone else worry about the harder part.
 

Buzby

Senior Member
OT, a bit.

Would this IR TOF rangefinder suffice? https://www.sparkfun.com/products/14588
Don't know. I need to measure upto about 500mm, usually in outdoor daylight. The datasheets for the TFMINI says upto 3m in bright sunlight, so hopefully my VL53LOX might be the same.

I will plug the VL53LOX into my A***** to test, and if it works OK, do a bit of decoding. If it turns out to be too much effort, I'll just buy the UART version.

( No work on this till the weekend. I'm away from home. Brought PICAXE, breadboard/scope, and VL53LOX, but no A***** )

Cheers,

Buzby
 

Pongo

Senior Member
Don't know. I need to measure upto about 500mm, usually in outdoor daylight. The datasheets for the TFMINI says upto 3m in bright sunlight, so hopefully my VL53LOX might be the same.
It will be interesting to hear how you get on. The datasheet admits that the outdoor performance is quite limited, max range is reduced to 50%. The outdoor test condition is:

"Outdoor overcast corresponds to a parasitic noise of 10kcps/SPAD for VL53L0X module. For reference, this corresponds to a 1.2W/m² at 940nm, and is equivalent to 5k Lux daylight, while ranging on a grey 17% chart at 40cm"

Quote from someone who also tested it: "From my and one other Finnish tester tests have we figured out it shows correct from ca 30 min after sunset to ca 30 min before sunrise."

Note that Parallax also has a sensor based on the VL53LOX, but theirs has an analog conversion on board.
 

stan74

Senior Member
A link I found for proton basic http://www.protonbasic.co.uk/showthread.php/76045-VL53L0X-laser-ranging-sensor
edit http://www.protonbasic.co.uk/content.php/4621-VL53L0X-laser-ranging-sensor-sample-code-for-PIC16F628A
Code I tried but faulty device I think. I can find it's address and version works but not distance. All 0s but may be I not converted proton basic right.
;in progress VL50L0X range finder
;proton basic to gcb v2
#chip mega328p, 16
#option explicit

#define I2C_MODE Master
#define I2C_DATA PORTC.4
#define I2C_CLOCK PORTC.5
#define I2C_DISABLE_INTERRUPTS ON

'Variables


'Set up hardware serial connection
#define USART_BAUD_RATE 9600
#define USART_DELAY 10 ms
#define USART_BLOCKING

#define VL53L0x_device 0x52



'Variables
Dim tmp As Byte
Dim DatoVL As Byte
Dim DatoSensor(12) As Byte
Dim Distance As Word
Dim devError As Byte
Dim SPAD As long
Dim Signal As Word
Dim Ambient As Word

wait 100 ms

Info_VL53 ;Send info data

wait 1 s

'Loop of program
do
'Sys range start
VL53L0x_sendbyte( 0x00 )
VL53L0x_sendbyte( 0x01 )
;I2COut SDA,SCL,W_ADDRESS,[0x00,0x01]
wait 5 s
'Range status
VL53L0x_sendbyte( 0x14 )
;I2COut SDA,SCL,W_ADDRESS,[0x14]
wait 5 ms
'Read 12 raw data of Sensor:
;I2CIn SDA,SCL,R_ADDRESS,[Str DatoSensor]
for tmp=1 to 12
I2CSTART
I2CSEND( VL53L0x_device )
I2CSTART
I2CSEND( VL53L0x_device + 1)
I2CReceive( DatoSensor(tmp) , NACK )
I2CSTOP
next tmp
' 'Activate for view raw data

For tmp=1 To 12
hserprint str(DatoSensor(tmp))
If tmp<12 Then hserprint ","
Next tmp
crlf
'Resolve sensor error list:
devError = (DatoSensor(1) and 0x78 ) /8 ; // Check for errors
HSerprint "Status: "
select case devError
case 0x00
HSerPrint "Data OK!"
case 0x01
HSerPrint "VCSEL CONTINUITY TEST FAILURE!"
case 0x02
HSerPrint "VCSEL WATCHDOG TEST FAILURE!"
case 0x03
HSerPrint "NO VHV VALUE FOUND!"
case 0x04
HSerPrint "MSRC NO TARGET!"
case 0x05
HSerPrint "SNR CHECK!"
case 0x06
HSerPrint "RANGE PHASE CHECK!"
case 0x07
HSerPrint "SIGMA THRESHOLD CHECK!"
case 0x08
HSerPrint "TCC!"
case 0x09
HSerPrint "PHASE CONSISTENCY!"
case 0x0A
HSerPrint "MIN CLIP!"
case 0x0B
HSerPrint "RANGE COMPLETE!"
case 0x0C
HSerPrint "ALGO UNDERFLOW!"
case 0x0D
HSerPrint "ALGO OVERFLOW!"
case 0x0E
HSerPrint "RANGE IGNORE THRESHOLD!"
end select
crlf
HSerPrint str(devError)

'Resolve info of sensor VL53L0x:
'If devError = 0x00 or devError = 0x06 update Distance
'If devError = 0x00 Or devError = 0x06Then
Distance=DatoSensor(11)*256+DatoSensor(12)
'endif
'Effective SPAD Return Count
SPAD = DatoSensor(3) + DatoSensor(4)/255
'Signal Rate
Signal = DatoSensor(7)*256+DatoSensor(8)
'Ambient Rate
Ambient= DatoSensor(9)*256+DatoSensor(10)




'Send terminal info:
hserprint "Distance: "+str(Distance)+" mm"
crlf
hserprint "Ambient Rate = "+str(Ambient)+"mc/s"
crlf
hserprint "Signal Rate = "+str(Signal)+"mc/s"
crlf
hserprint "SPAD = "+str(SPAD)
crlf

'wait a moment for view info
wait 1 s
loop
'Read sensor info
sub Info_VL53
'IDENTIFICATION REVISION ID
;I2CIn SDA,SCL,R_ADDRESS,0xC2,[DatoVL]
I2CStart
I2CSEND( 0x52 )
I2CSEND( 0xC2 )
I2CStart
I2CSEND( 0x53)
I2CReceive(DatoVL , NACK )
I2CStop

hserprint "Revision ID: "+str(DatoVL)
crlf

'IDENTIFICATION MODEL ID
;I2CIn SDA,SCL,R_ADDRESS,0xC0,[DatoVL]
I2CStart
I2CSEND( 0x52 )
I2CSEND( 0xC0 )
I2CStart
I2CSEND( 0x53)
I2CReceive(DatoVL , NACK )
I2CStop
hserprint "Device ID: "+str(DatoVL)
crlf

'PRE RANGE CONFIG VCSEL PERIOD
;I2CIn SDA,SCL,R_ADDRESS,0x50,[DatoVL]
I2CStart
I2CSEND( 0x52 )
I2CSEND( 0x50 )
I2CStart
I2CSEND( 0x53)
I2CReceive(DatoVL , NACK )
I2CStop
hserprint "Pre Range Config Period: "+str(DatoVL)
crlf

'FINAL RANGE CONFIG VCSEL PERIOD
;I2CIn SDA,SCL,R_ADDRESS,0x70,[DatoVL]
I2CStart
I2CSEND( 0x52 )
I2CSEND( 0xC0 )
I2CStart
I2CSEND( 0x53)
I2CReceive(DatoVL , NACK )
I2CStop
hserprint "Final Period: "+str(DatoVL)
crlf

end sub

sub crlf
HSersend 13
HSersend 10
end sub

sub VL53L0x_sendbyte( in VL53L0x_data )

I2CSTART
I2CSEND( VL53L0x_device )
I2CSEND( VL53L0x_data )
'initiate Stop Condition
I2CSTOP

end sub

sub VL53L0x_readbyte( Out VL53L0x_data )
I2CSTART
I2CSEND( VL53L0x_device )
I2CSTART
I2CSEND( VL53L0x_device + 1)
I2CReceive( VL53L0x_data , NACK )
'initiate Stop Condition
I2CSTOP
end sub
 
Last edited:

Pongo

Senior Member
Pongo please post your code for serial version. I sent off for one from your link.
Here's my test code with (hopefully) extraneous functions removed. If your module is like mine the top and bottom board legends do not match, the laser module side is correct.

Code:
'PICAXE-20X2 - VL53LOX test program
'Eventual objective is to measure height of an object between sensor and fixed target
'but this test code simply reports measured distance to target.
'Tests communication between 20X2 and laser module. Sends hex C0 setup
'command and hex A0 to module to request measurement. Responses and measured distance 
'displayed on PC. Note that module responds very quickly to hex C0, I could not reliably
'detect the response echo with non-hardware serial.
#Picaxe 20X2
#No_Data
#No_Table
#Terminal 9600
Setfreq M8
Symbol LED = C.5 'LED indicates that most recent measurement is good
Symbol LASERMAX = W24 'Distance laser is mounted above target in mm, used to validate distance value. 
Symbol LASERTOL = b47 'Because the laser distance measurement varies we need to allow some 
'tolerance so as not to reject good zero measurements. A measurement of less than LASERMAX + LASERTOL is
'considered to be good. 
Low LED
W26 = 0
W27 = 0
LASERMAX = 1000 'Distance in mm sensor is mounted above target 
LASERTOL = 5 'Tolerance in mm, to be adjusted based on experience
W22 = LASERMAX + LASERTOL
sertxd ("W22 ",#W22,cr,lf)
'setup hardware serial
hsersetup b9600_8,%001
setintflags %00100000,%00100000
pause 1000
'off to the races
main:
	Do 
	sertxd ("Start measurement",cr,lf)	
	ptr = 0
	hserout 0,($C0) ;	   
   	pause 1000   'waiting for hser interrupt
	get 0,b51
	if b51 = $C0 then 
   	sertxd ("Setup confirmed",cr,lf)   ' For debugging
	else
	sertxd ("Bad/no response",cr,lf)   ' For debugging
	goto main
	endif
	pause 1000 'can probably be less
   	hserout 0,($A0) ;
   	pause 4000 'can probably be less
   	sertxd ("Distance data sent",cr,lf)   ' For debugging
	get 1,b55
	get 2,b54
	if b51 = $C0 and w27 <=  W22 then 'validate the measurement
	sertxd ("Measured distance = ",#w27," mm",cr,lf)
	else
	sertxd ("Out of range value",cr,lf)
	low LED
	endif
  	ptr = 0
   	hserptr = 0  'Reset hserial pointer 
    	flags = 0    'clear the flags byte
	for ptr = 0 to 10
	@ptr = $FF	
	next
	loop
     
interrupt:   
   	sertxd ("Reply from laser - ")   ' For debugging
    	pause 3000   'Allow entire packet to be received
     	ptr = 0      'Set SP pointer to zero 
    	flags = 0    'clear the flags byte
    	setintflags %00100000,%00100000  'enable the interrupt
Return
laser conn.jpg
 

erco

Senior Member
Note that Parallax also has a sensor based on the VL53LOX, but theirs has an analog conversion on board.
Yes, I have some samples of the new Laser Ping. As you said, it's a ToF sensor but the support electronics do all the heavy lifting and signal conversion. The sensor outputs a pulse, calibrated exactly like their PING ultrasonic sensor. So a Picaxe can read it quite simply using the ULTRA command. I'll make a demo video when I get a chance.

The sensor has a secondary serial communication mode at 9600 baud. Details at https://www.parallax.com/sites/default/files/downloads/28041-LaserPING-2m-Rangefinder-Guide.pdf

Here it is on another robot: https://www.youtube.com/watch?v=z7SFWSsY9YE
 
Last edited:

Buzby

Senior Member
I've started to decode the register map, but not got very far. Lots of A****** and other code been studied, and this is what I've got working so far ...

Rich (BB code):
hi2csetup I2CMASTER, $52, i2cfast, i2cbyte

do
      hi2cin $C0,(b0)
      sertxd (b0,cr,lf)
      pause 1000
loop
This read the 'WHO_AM_I' register, which should return $EE, and it does !!!.

Not much luck with the rest of the code, but at least I know I'm talking to it.

Cheers,

Buzby
 
Last edited:

stan74

Senior Member
Thank you Pongo. I'll get no info when it arrives so any will be welcome.
My robot avoid has found srf04 ultra sonic best. Sharp 80cm range sensors output is erratic and slow. Thought I'd try the tof version.
How to read the 12 bytes it sends.
erco $30 is a bit
 

Pongo

Senior Member
Here are the commands for the UART module:

Code:
No.	Command	Return value	Description

1		0XA0		BYTE1,BYTE2		Word output mode, the output distance is (BYTE1 < 8) &BYTE2;
								        the conversion to 10 is the actual measurement distance, the unit is mm

2		0XA1		BYTE1,BYTE2		VL53L0X initialization (initialization time is 500mS)

3		0XB0		0XB0			The module baud rate is set to 9600, and it takes effect in time (default)

4		0XB1		0XB1			The module baud rate is set to 19200, and it takes effect in time

5		0XB2		0XB2			The module baud rate is set to 115200, and it takes effect in time

6		0XC0		0XC0			Set up as a long distance measurement mode (default)

7		0XC1		0XC1			Set up as a high-speed measurement model

8		0XC2		0XC2			Set to high precision measurement mode (measurement interval is greater than 180mS)

9		0XD0		0XD0			Set XSHUT to high level, module work normally and initialize module

10	        0XD1	        0XD1			Setting XSHUT to low level, VL53L0X closes

11	        0XF0		        BYTE1--BYTE4 	        Current baud rate (MSB)
			                
			                BYTE5  	                0X00 long distance mode
	                                                                0X01 high speed measurement mode
					                                0X02 high precision measurement mode
			                BYTE6	                The status of the current XSHUT
 

stan74

Senior Member
Thank you again Pongo. From your code I'll sort init and see...when it arrives 2 to 6 weeks :(
I'm no good at i2c protocol and how this sends 12 bytes to use as info.I'm just using scl and data.
serial should be easier.
 

stan74

Senior Member
Pongo- setintflags %00100000,%00100000 and again in the interrupt suggests a timer overflow int. omg.
 

Pongo

Senior Member
Pongo- setintflags %00100000,%00100000 and again in the interrupt suggests a timer overflow int. omg.
I got that from some hserial background code that Goeytex was kind enough to share with me a few years ago. But I'm always open to correction/improvement.
 

stan74

Senior Member
Pongo. When I see the set timer and again in the interrupt it's a reset timer for timer overload. I was no good at picaxe interrupts.
It can't be cos the interrupt has pause 3000.
There must be a setup like sersend codes from list and see what you recive. No example code.
1 0XA0 BYTE1,BYTE2 Word output mode, the output distance is (BYTE1 < 8) &BYTE2;
the conversion to 10 is the actual measurement distance, the unit is mm
is vague.
 

Buzby

Senior Member
It works !

Not quite sure how, but I'm glad to get something sensible out of this little critter.

Judging from the datasheet, there's lot's more work needed to get this thing calibrated properly.
However, if I can get stable and repeatable results, then I can compensate in the PICAXE.

Cheers,

Buzby

Code:
#NO_TABLE
#NO_DATA


'VL53L0x Registers Write and Read

Symbol Da1    	  = b10	
Symbol Da2    	  = b11
Symbol Da3    	  = b12
Symbol Da4    	  = b13
Symbol Da5    	  = b14	
Symbol Da6    	  = b15
Symbol Da7    	  = b16
Symbol Da8    	  = b17
Symbol Da9    	  = b18	
Symbol Da10   	  = b19
Symbol Da11   	  = b20
Symbol Da12   	  = b21

Symbol devError	  = b22
Symbol datoVL	  = b23
Symbol Distance	  = w12
Symbol Signal	  = w13
Symbol SPAD		  = w14
Symbol Ambient 	  = w15


hi2csetup I2CMASTER, $52, i2cfast, i2cbyte

do
	hi2cin $C0,(b0)
	sertxd (b0,cr,lf) ' EE
	pause 10

	hi2cin $C1,(b0)
	sertxd (b0,cr,lf) ' AA
	pause 10

	hi2cin $C2,(b0)
	sertxd (b0,cr,lf) ' 10
	pause 1000




'loop
	

'do ' Main loop


' Soft reset
hi2cout $89,($01)
pause 200



'Sys range start
hi2cout $00,($01)
pause 50
  
  
'Read 12 raw data of Sensor:
hi2cin $14,(da1,da2,da3,da4,da5,da6,da7,da8,da9,da10,da11  ,da12)

sertxd (#da1," ",#da2," ",#da3," ",#da4," ",#da5," ",#da6," ",#da7," ",#da8," ",#da9," ",#da10," ",#da11," ",#da12,cr,lf)

'Resolve sensor errors
devError = Da1 & 0x78 >> 3 ' // Check for errors
sertxd("Status: ")
If devError = $00 Then  sertxd ("Data OK!") : endif  ' No device error
If devError = $01 Then  sertxd ("VCSEL CONTINUITY TEST FAILURE!") : endif
If devError = $02 Then  sertxd ("VCSEL WATCHDOG TEST FAILURE!") : endif
If devError = $03 Then  sertxd ("NO VHV VALUE FOUND!") : endif
If devError = $04 Then  sertxd ("MSRC NO TARGET!") : endif
If devError = $05 Then  sertxd ("SNR CHECK!") : endif
If devError = $06 Then  sertxd ("RANGE PHASE CHECK!") : endif
If devError = $07 Then  sertxd ("SIGMA THRESHOLD CHECK!") : endif
If devError = $08 Then  sertxd ("TCC!"): endif
If devError = $09 Then  sertxd ("PHASE CONSISTENCY!") : endif
If devError = $0A Then  sertxd ("MIN CLIP!" ): endif
If devError = $0B Then  sertxd ("RANGE COMPLETE!") : endif
If devError = $0C Then  sertxd ("ALGO UNDERFLOW!") : endif
If devError = $0D Then  sertxd ("ALGO OVERFLOW!") : endif
If devError = $0E Then  sertxd ("RANGE IGNORE THRESHOLD!") : endif

sertxd (" (",devError,")",cr,lf)


'Resolve info of sensor VL53L0x:
  'If devError = $00 or devError = $06 update Distance
  'If devError = $00 Or devError = $06Then 
Distance=Da11*256+Da12 
'endif
  'Effective SPAD Return Count        
SPAD = Da3 + Da4 /255
  'Signal Rate
Signal = Da7*256+Da8
  'Ambient Rate 
Ambient= Da9*256+Da10

'Send terminal info:
sertxd ( "Distance: ", #Distance," mm",13,10 )
sertxd ( "Ambient Rate = ", #Ambient,"mc/s",13,10 )
sertxd ( "Signal Rate = ",#Signal,"mc/s",13,10 )
sertxd ( "SPAD = ",#SPAD,13,10 )


loop
[video]https://youtu.be/2c7-Tb32bdE[/video]
 

Pongo

Senior Member
1 0XA0 BYTE1,BYTE2 Word output mode, the output distance is (BYTE1 < 8) &BYTE2;
the conversion to 10 is the actual measurement distance, the unit is mm
is vague.
The description (from the supplier) is vague, but the reality is very simple. Byte1 is the high byte, Byte2 is the low byte, stuff them into a word variable and the decimal value of the word is the measured distance in mm.
 

hippy

Technical Support
Staff member
Pongo- setintflags %00100000,%00100000 and again in the interrupt suggests a timer overflow int. omg.
Bit 5 is "hserflag"; interrupt on serial received which would seem to be appropriate.
 

stan74

Senior Member
ta hippy. info overload at the moment,I still don't understand serial,spi,i2c protocols or all the different interrupt events.
Buzby's code is a good start.
 

Jeremy Harris

Senior Member
Slightly off-topic, but related. Does anyone know of a similar module that would work over a longer range (around 5 to 8 metres) in total darkness, by any chance?

I still haven't got around to building a water level sensor for our well/borehole, and I like the idea of just having a sealed box with a laser sensor just shining out of a sealed acrylic window, as I could lower this down to just above the highest water level we ever get and then see how that changes when we are drawing water normally (I know from doing the initial tests that the level dropped by around 5m when we were pumping at flat out for a couple of days to clean out the well). I guess it's possible that the variation might be less than the 2m limit of these devices under normal use, but it'd be nice to be able to have a bit more range to be sure.
 

hippy

Technical Support
Staff member
A Google search for "laser ranging module" turns up quite a few options. Not sure how appropriate or expensive any will be.

The VL53L0X appears to have become popular because it's fairly compact, easy to use with their API, relatively cheap, and designed with those things in mind. That suggests to me other options may not be.
 

AllyCat

Senior Member
Hi,

The VL53L0X appears to have rather a wide field of view so perhaps a suitable convex lens could be used? That might help the performance in higher light levels, but not if the measurement algorithm has a "window" limited to a maximum of 2 metres. :(

However, there are several "real" laser rangefinder modules available with a "pencil" beam and an RS232 interface for less than $30, e.g. from AliExpress. But be careful with your search, one includes the words "NOT RS232" in its title !

Rather than duplicate lots of detail here, see this thread on another forum, intended primarily to measure the depth of (lots of) snow. Several of these laser rangefinders are discussed, using an RS232 interface, or I believe in one case (SNDWAY) the drive to the LCD drive is "hacked" (by an Arduino) to effectively read the distance information directly from the screen.

Cheers, Alan.
 

Jeremy Harris

Senior Member
Sparkfun has been showing this RFD77402 Simblee&#8482; module in some projects.

Here's a Mouser listing and datasheet.
Thanks, but it seems limited to 2000mm, like the VL53LOX. I'm curious as to why there is such a high demand for short distance laser measurement as to make this chips cheap. There must be a really big commercial application that only needs to measure distances out to this distance.

A Google search for "laser ranging module" turns up quite a few options. Not sure how appropriate or expensive any will be.

The VL53L0X appears to have become popular because it's fairly compact, easy to use with their API, relatively cheap, and designed with those things in mind. That suggests to me other options may not be.
That aligns with my thoughts, but I can't help wondering whether there is a single chip solution for the cheaper laser distance measures. Many years ago (in the early 1980's) I made an optical reflective distance measurement system for doing cave surveys. For that I used a pinpoint source red LED, intended for use as a fibre optic driver, collimated with a simple lens to give a pretty close to parallel beam of around 20mm diameter. I used a 40mm diameter lens for the receiver side, with a fast photodiode at the focal point. It was largely analogue, in that the transmitter side had a second photodiode, identical to the receiver photodiode, set into the side of the housing to pick up some of the transmitted light. I modulated the transmitter at 100Hz, and then fed both the photodiode signals through two identical narrow band tuned amplifiers, with zero crossing detector comparators at the output, to digitise the 100Hz signals. The phase difference between the transmitted 100Hz and the received 100Hz was measured using a 6800 µprocessor, (programmed in assembly language!) which then drove an LED seven segment display giving the distance in metres, with about a 20mm accuracy. To get it to work I had to use a fairly large bike rear reflector as a retro-reflector that was positioned at the remote end, just to both get enough light back to the receiver and to show the operator when he was "on target" at the measurement point. At the time it was a useful step forward from using Fibron surveyors tapes to measure distance when doing cave surveys, but the thing was very heavy, due to the big batteries needed to run the 6800!

Hi,

The VL53L0X appears to have rather a wide field of view so perhaps a suitable convex lens could be used? That might help the performance in higher light levels, but not if the measurement algorithm has a "window" limited to a maximum of 2 metres. :(

However, there are several "real" laser rangefinder modules available with a "pencil" beam and an RS232 interface for less than $30, e.g. from AliExpress. But be careful with your search, one includes the words "NOT RS232" in its title !

Rather than duplicate lots of detail here, see this thread on another forum, intended primarily to measure the depth of (lots of) snow. Several of these laser rangefinders are discussed, using an RS232 interface, or I believe in one case (SNDWAY) the drive to the LCD drive is "hacked" (by an Arduino) to effectively read the distance information directly from the screen.

Cheers, Alan.
Thanks, they look worth a look at in more detail. Hacking a distance measurement unit may well be the easiest/cheapest way to get a longer range, if not the neatest.
 

Buzby

Senior Member
... I'm curious as to why there is such a high demand for short distance laser measurement as to make this chips cheap. There must be a really big commercial application that only needs to measure distances out to this distance. ...
Yep, there are a few I can think of. Mobile phones that turn the screen off when against your ear, and auto focus the camera when it's not. Drones that hover at a fixed distance, then land softly. Those 'flying disco balls' that you control by waving a hand under them.

Regarding my specific requirement, the VL53 is looking less attractive as I discover more about it. Latest 'feature' seems to be that although it has a programmable I2C address, it forgets it after a power cycle. Not good when I need eight on one bus.

Cheers,

Buzby
 

hippy

Technical Support
Staff member
Regarding my specific requirement, the VL53 is looking less attractive as I discover more about it. Latest 'feature' seems to be that although it has a programmable I2C address, it forgets it after a power cycle. Not good when I need eight on one bus.
It seems you are right. You effectively need a 'chip initialise' signal to each device. There is an application note which suggests using an I2C I/O expander which avoids using additional I/O on the PICAXE -

http://www.st.com/resource/en/application_note/dm00280486.pdf
 

AllyCat

Senior Member
Hi,

Also, I'm surprised by the relatively wide field of view and (thus) the reported poor tolerance to even modest ambient light levels (outdoors). I guess it's a limitation of the particular (laser) technology used?

Snow would reflect a laser but would water? It would be like glass.
The thread I linked suggests the use of a float, but light will be reflected back from any interface which has a change of refractive index. For water/air it's about 2% normally, not like a sheet of glass which reflects back about 4% from each face and thus may confuse a TOF rangefinder. Therefore, it might be possible to use the water surface alone, provided that the bottom of the "well" is sufficiently dark-coloured and far enough away.

Which raises an interesting principle: Classically, a swimming pool appears less deep than actual because the light rays are bent by the change in refractive index at the water surface. However, the speed of light is slower in water than in air, so a TOF rangefinder will see the depth as greater than actual. And yes, my laser rangefinder does measure the bottom of a glass of water as further away than the table top on which it's standing. ;)

Cheers, Alan.
 

Buzby

Senior Member
... There is an application note which suggests using an I2C I/O expander which avoids using additional I/O on the PICAXE ...
On one site I looked at the author programmed a seperate chip for each VL53. Each chip had two I2C ports, one as a Master to the VL53, and the other as a Slave for the main controller. I could maybe do similar, preferably using 08M2's.

Now, I can bit-bang a Master, but don't know how to build a Slave, other than using a 20X2, which is a bit of overkill, and expense, seeing as I need eight.

This VL53 is definitely not as friendly as it appears at first sight !.

Cheers,

Buzby
 

Buzby

Senior Member
... And yes, my laser rangefinder does measure the bottom of a glass of water as further away than the table top on which it's standing. ...
Maybe this effect could be used in some kind of classroom experiment to measure the speed of light. ( A lot less messy than a bar of chocolate in a microwave oven. )

Cheers,

Buzby
( in half-baked idea mode. )
 

Jeremy Harris

Senior Member
That 6800 based unit sounds truly clever Jeremy. I'm 'proper impressed'!
I wouldn't be that impressed, I nicked the idea from a Texas Instruments Application Note, about how to use modulated light as a way of measuring distance. My guess is that it's still how some laser distance measuring systems work, as it's a heck of a lot easier to just measure the phase difference between the transmitted and received modulated signal than it is to try and use the true "time of flight" of light.

Measuring 0 to 2000mm by just using the "time of flight" of a pulsed laser, to a resolution of 2mm, would mean being able to measure picosecond time delays, which doesn't seem practical for such a cheap device. Modulating the beam and then measuring the phase difference of the modulated signals means even a Picaxe could give a pretty good resolution.

The hardest part of the project was making two identical tuned high gain, narrow band, amplifiers, with exactly the same phase response. I used a design similar to the IF strip in a radio, but tuned down to the low modulation frequency. Each just had an LM311, IIRC, as the zero crossing detector, to square up the signals before gating them into a pulse with a width proportional to distance.
 

hippy

Technical Support
Staff member
square up the signals before gating them into a pulse with a width proportional to distance.
And a common trick used for measuring the length of very short pulses is to do it indirectly; for example charging up a capacitor and then measuring what voltage it reached which will reflect the time it was being charged for.

The technique can be demonstrated on a PICAXE with just a resistor, capacitor and push button to measure how long the button was pushed for.
 
Top