| Posted: 09:08pm 01 Dec 2018 |
Copy link to clipboard |
 Print this post |
|
Hi JohnS
My problem is to find documentation on register map
Here is the code, really basic, but I can not find documentation on the registers map to understand if I can improve the noise I have in reading.
Dim from As integer = 30 Dim maxregs As integer = from+2 Dim buff(maxregs) As integer Dim R As Float SetPin 38,dout : Pin(38)=1
Do ReadI2C Pause 50 Loop
Sub ReadI2C I2C OPEN 400, 1000 I2C WRITE &H29, 0, 2, 0, 1 I2C READ &H29, 0, maxregs,buff() If MM.I2C Then Print "Slave did not respond" I2C CLOSE x = (buff(from)<<8)+buff(from+1) If X>20 Then Print Timer,Str$(x/10,3,1)"cm" End Sub
This is the result,with the sensor still and placed in front of a fixed and smooth object:
597845 69.8cm 598001 68.1cm 598055 67.8cm 598211 68.9cm 598265 67.9cm 598319 67.6cm 598373 67.2cm 598529 67.5cm 598583 68.3cm 598637 67.8cm 598691 67.1cm 598745 69.5cm 598799 68.0cm 598853 66.9cm 598907 67.6cm 599063 67.8cm 599117 69.1cm 599171 67.8cm 599225 68.3cm 599279 68.6cm 599333 70.2cm 599387 67.3cm 599543 66.7cm 599597 68.7cm 599651 68.0cm >
Thanks Antonio |