I have a proton basic prog that needs trans lating to gcb. I'm posting the original and my effort at translating.
The device is a VL53L0X laser range finder. It seems the code works and is commented as much simpler than the un-neccessary c stuff. Any help welcome.
I edited the above code. Downloaded proton basic manual pdf. Not sure about hex2 and dec. The i2c values are strange. It doesn't print anything in the terminal but the commented out test loop works.
Last edit: stan cartwright 2018-03-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
data sheet says.
Clock signal (SCL) generation is performed by the master device. The master device
initiates data transfer. The I2C bus on the VL53L0X has a maximum speed of 400 kbits/s
and uses a device address of 0x52.
Figure 13. Data transfer protocol
Information is packed in 8-bit packets (bytes) always followed by an acknowledge bit, Ac for
VL53L0X acknowledge and Am for master acknowledge (host bus master). The internal
data is produced by sampling SDA at a rising edge of SCL. The external data must be stable
during the high period of SCL. The exceptions to this are start (S) or stop (P) conditions
when SDA falls or rises respectively, while SCL is high.
A message contains a series of bytes preceded by a start condition and followed by either a
stop or repeated start (another start condition but without a preceding stop condition)
followed by another message. The first byte contains the device address (0x52) and also
specifies the data direction. If the least significant bit is low (that is, 0x52) the message is a
master write to the slave. If the lsb is set (that is, 0x53) then the message is a master read
from the slave.
; The ack thing is needed. I'm no good at this.
The original proton code is the simplest I've found. The author upgraded it but that uses floats. The device is used through it's own api. 32 bit c stuff.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
data sheet says.
Clock signal (SCL) generation is performed by the master device. The master device
initiates data transfer. The I2C bus on the VL53L0X has a maximum speed of 400 kbits/s
and uses a device address of 0x52.
Yes. So, you have the knowledge to set the baud rate.
Figure 13. Data transfer protocol
Information is packed in 8-bit packets (bytes) always followed by an acknowledge bit, Ac for
VL53L0X acknowledge and Am for master acknowledge (host bus master). The internal
data is produced by sampling SDA at a rising edge of SCL. The external data must be stable
during the high period of SCL. The exceptions to this are start (S) or stop (P) conditions
when SDA falls or rises respectively, while SCL is high.
A message contains a series of bytes preceded by a start condition and followed by either a
stop or repeated start (another start condition but without a preceding stop condition)
followed by another message. The first byte contains the device address (0x52) and also
specifies the data direction. If the least significant bit is low (that is, 0x52) the message is a
master write to the slave. If the lsb is set (that is, 0x53) then the message is a master read
from the slave.
; The ack thing is needed. I'm no good at this.
Yes. So, you have used I2C discovery to proove the device is on address 0x52?
The original proton code is the simplest I've found. The author upgraded it but that uses floats. The device is used through it's own api. 32 bit c stuff.
Is the device 32 bit floats? or, is it integer?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Str ??
This line needs converting I2CIn SDA,SCL,R_ADDRESS,$C2,[DatoVL]
$C2 is a vl53l0x register I'm guessing.
It's another device sorted in rpi and arduino. Gcb, why not to? Like BMP/E 280 was.
Last edit: stan cartwright 2018-03-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Replace the device with a known working solution like a GLCD. Does that work? In not, make the known device work... resistors..... 101 of I2C.. discovery MUST WORK.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I need to convert
'Read 12 raw data of Sensor:
;I2CIn SDA,SCL,R_ADDRESS,[Str DatoSensor] - proton basic
where DatoSensor is dim DatoSensor(12) as byte to gcb.
Is this correct? 0x52 is devicei2c address.
for tmp=1 to 12
I2CSTART
I2CSEND( 0x52 )
I2CSTART
I2CSEND( 0x53 )
I2CReceive( DatoSensor(tmp) , NACK ) ;read byte
I2CSTOP
next tmp
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Depends. Depends on the protocol. You need to review the datasheet. Looks to me like you are reading the same location 12 times but I am guessing without the datasheet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i2c address finder found r/w addresses.
A picaxe user got results in picaxe basic. Here's the code and my attempt at converting to gcb. Not working though.
The basic writes to inialise and then read the bytes with the distance is all needed to use the device.
An include .h file is neater. Arduino has several.
I'll try using it again to get it working.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have started. I have confirmed I2C discovery using the I2C discovery.
The I have commenced data read operations between the UNO to the Sensor.
The datasheet shows the following table as critical reference check - I am not what is at addresses 0xC1, 0x51 and 0x61. I will have to understand, later, why these are important.
So, the datasheet shows as the default values are show below:
The little prototype initialises, the reads the bytes and words at the required locations. The results are shown below.
Test sensor VL53L0x v20/02/19 by Anobium
Default From Device
Revision ID 0x10 0x10
Device ID 0xEE 0xEE
Address 0xC1 0xAA 0xAA
Address 0x51 0x0099 0x0099
Address 0x61 0x0000 0x0000
The means that I have the device talking and the default values match the required values in the datasheet. This is a good start. I have readbyte and readword operational.
:-)
Last edit: Anobium 2019-02-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been hunting for a table of the registers of this device.
Then, I found this message from ST Product Support.
Hello,
VL53L0X is a complex device.
Registers description is not possible [to produce a table of the registers] for this device due to complexity.
It contains hundred of registers with inter-dependance and not straight forward content.
Then, the choice has been to not provide a register list, but instead develop an friendly API.
You can download the API and user's manual on st.com/VL53L0X.
Interesting - they clearly think we are fools.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a proton basic prog that needs trans lating to gcb. I'm posting the original and my effort at translating.
The device is a VL53L0X laser range finder. It seems the code works and is commented as much simpler than the un-neccessary c stuff. Any help welcome.
I got so far-
Last edit: stan cartwright 2018-03-04
I edited the above code. Downloaded proton basic manual pdf. Not sure about hex2 and dec. The i2c values are strange. It doesn't print anything in the terminal but the commented out test loop works.
Last edit: stan cartwright 2018-03-04
Suggest an I2C protocol analyser and the datasheet for the device would make this a lot easier.
data sheet says.
Clock signal (SCL) generation is performed by the master device. The master device
initiates data transfer. The I2C bus on the VL53L0X has a maximum speed of 400 kbits/s
and uses a device address of 0x52.
Figure 13. Data transfer protocol
Information is packed in 8-bit packets (bytes) always followed by an acknowledge bit, Ac for
VL53L0X acknowledge and Am for master acknowledge (host bus master). The internal
data is produced by sampling SDA at a rising edge of SCL. The external data must be stable
during the high period of SCL. The exceptions to this are start (S) or stop (P) conditions
when SDA falls or rises respectively, while SCL is high.
A message contains a series of bytes preceded by a start condition and followed by either a
stop or repeated start (another start condition but without a preceding stop condition)
followed by another message. The first byte contains the device address (0x52) and also
specifies the data direction. If the least significant bit is low (that is, 0x52) the message is a
master write to the slave. If the lsb is set (that is, 0x53) then the message is a master read
from the slave.
; The ack thing is needed. I'm no good at this.
The original proton code is the simplest I've found. The author upgraded it but that uses floats. The device is used through it's own api. 32 bit c stuff.
Yes. So, you have the knowledge to set the baud rate.
Yes. So, you have used I2C discovery to proove the device is on address 0x52?
Is the device 32 bit floats? or, is it integer?
The original proton code is integer.
Did I translate this ok?
Str ??
This line needs converting I2CIn SDA,SCL,R_ADDRESS,$C2,[DatoVL]
$C2 is a vl53l0x register I'm guessing.
It's another device sorted in rpi and arduino. Gcb, why not to? Like BMP/E 280 was.
Last edit: stan cartwright 2018-03-05
i2c finder didn't find device. oh dear again.
Replace the device with a known working solution like a GLCD. Does that work? In not, make the known device work... resistors..... 101 of I2C.. discovery MUST WORK.
I need to convert
'Read 12 raw data of Sensor:
;I2CIn SDA,SCL,R_ADDRESS,[Str DatoSensor] - proton basic
where DatoSensor is dim DatoSensor(12) as byte to gcb.
Is this correct? 0x52 is devicei2c address.
for tmp=1 to 12
I2CSTART
I2CSEND( 0x52 )
I2CSTART
I2CSEND( 0x53 )
I2CReceive( DatoSensor(tmp) , NACK ) ;read byte
I2CSTOP
next tmp
Depends. Depends on the protocol. You need to review the datasheet. Looks to me like you are reading the same location 12 times but I am guessing without the datasheet.
@Stan. I am about to look at this library. How far did you get? Much further?
My research from this morning. There is a good API reference guide and example code.
Three attachments.
i2c address finder found r/w addresses.
A picaxe user got results in picaxe basic. Here's the code and my attempt at converting to gcb. Not working though.
So, the question.
A quick hack to get it going? or, a proper library?
The basic writes to inialise and then read the bytes with the distance is all needed to use the device.
An include .h file is neater. Arduino has several.
I'll try using it again to get it working.
I ha started. I will wait for your work.
@Stan. Any progress? I am waiting.
A new device should arrive Tuesday.
new device arrived. i2c finder gives write 0x52, read 0x53.
no luck with converting i2c code.
What have you tried? Share please.
Just the proton and picaxe code I posted.
Just the proton and picaxe code I posted.
I have started. I have confirmed I2C discovery using the I2C discovery.
The I have commenced data read operations between the UNO to the Sensor.
The datasheet shows the following table as critical reference check - I am not what is at addresses 0xC1, 0x51 and 0x61. I will have to understand, later, why these are important.
So, the datasheet shows as the default values are show below:
The little prototype initialises, the reads the bytes and words at the required locations. The results are shown below.
The means that I have the device talking and the default values match the required values in the datasheet. This is a good start. I have readbyte and readword operational.
:-)
Last edit: Anobium 2019-02-20
I have been hunting for a table of the registers of this device.
Then, I found this message from ST Product Support.
Interesting - they clearly think we are fools.