Good morning,I try to use a time of flight sensor (type VL53L0X) but the reading results are false and unstable. (at 30 cm, it gives me +- 6cm error)! Does anyone have any experience with this type of sensor?Thank you for your response.....BernardThe source cod:do Gosub LectureGosub Evaluer
Gosub Resultat
Lecture:
I2cstart
I2cwbyte Cjvl53_write
I2cwbyte &H00
I2cwbyte &H01
I2cstop
Waitms 5
I2cstart
I2cwbyte Cjvl53_write
I2cwbyte &H14
Waitms 5
I2crepstart
I2cwbyte Cjvl53_read
For I = 1 To 11
I2crbyte Daten(i) , Ack
Next
I2crbyte Daten(12) , Nack
I2cstop
Return
Evaluer:
I = Daten(1) And &H78
I = I / 8
Select Case I
Case $00 : Print "Data OK!"
Case $01 : Print "VCSEL CONTINUITY TEST FAILURE!"
Case $02 : Print "VCSEL WATCHDOG TEST FAILURE!"
Case $03 : Print "NO VHV VALUE FOUND!"
Case $04 : Print "MSRC NO TARGET!"
Case $05 : Print "SNR CHECK!"
Case $06 : Print "RANGE PHASE CHECK!"
Case $07 : Print "SIGMA THRESHOLD CHECK!"
Case $08 : Print "TCC!"
Case $09 : Print "PHASE CONSISTENCY!"
Case $0a : Print "MIN CLIP!"
Case $0b : Print "RANGE COMPLETE!"
Case $0c : Print "ALGO UNDERFLOW!"
Case $0d : Print "LGO OVERFLOW!"
Case $0e : Print "RANGE IGNORE THRESHOLD!"
Case Else Print "Hurz " ; Hex(i)
End Select
Return
Resultat:
Mesure_ir = Daten(11) * 256
Mesure_ir = Mesure_ir + Daten(12)
print Mesure_ir
waitms 100
loop
Gosub Resultat
Lecture:
I2cstart
I2cwbyte Cjvl53_write
I2cwbyte &H00
I2cwbyte &H01
I2cstop
Waitms 5
I2cstart
I2cwbyte Cjvl53_write
I2cwbyte &H14
Waitms 5
I2crepstart
I2cwbyte Cjvl53_read
For I = 1 To 11
I2crbyte Daten(i) , Ack
Next
I2crbyte Daten(12) , Nack
I2cstop
Return
Evaluer:
I = Daten(1) And &H78
I = I / 8
Select Case I
Case $00 : Print "Data OK!"
Case $01 : Print "VCSEL CONTINUITY TEST FAILURE!"
Case $02 : Print "VCSEL WATCHDOG TEST FAILURE!"
Case $03 : Print "NO VHV VALUE FOUND!"
Case $04 : Print "MSRC NO TARGET!"
Case $05 : Print "SNR CHECK!"
Case $06 : Print "RANGE PHASE CHECK!"
Case $07 : Print "SIGMA THRESHOLD CHECK!"
Case $08 : Print "TCC!"
Case $09 : Print "PHASE CONSISTENCY!"
Case $0a : Print "MIN CLIP!"
Case $0b : Print "RANGE COMPLETE!"
Case $0c : Print "ALGO UNDERFLOW!"
Case $0d : Print "LGO OVERFLOW!"
Case $0e : Print "RANGE IGNORE THRESHOLD!"
Case Else Print "Hurz " ; Hex(i)
End Select
Return
Resultat:
Mesure_ir = Daten(11) * 256
Mesure_ir = Mesure_ir + Daten(12)
print Mesure_ir
waitms 100
loop