LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

getting sometimes wrong values from Ultrasonic Sensor then i read more than 1 Byte at a time.

Hello,
 
i want to read more than 1 Byte with one read cycle. I tried it with the Ultasonic Sensor and get nearly
every 2nd read wrong Values. I try to read from Register 8  5 bytes. This is the result
 
byte  1. read   2.read   3.read  4. read 
 
1)      76              69        76        76
2)      69              71        0          69
3)      71              79        71        71
4)      79              0          79        79
5)      0                0           0          0
 
and so on. Right is 76 69 71 79 0  which means LEGO
does anyone have an Idea ?  I put the vi into the Attachment
0 Kudos
Message 1 of 4
(7,029 Views)

Hello all,

 

i found my mistake. If you read out the Senor, the bytes read have to be the same count of bytes as discribed in the Documentation.

So if you want to read Register 8 you have to read 8 bytes. If you want to read register 42h you have to read 1 byte.

If you do not so you will get strange Values back.

rgds

Harald

 

0 Kudos
Message 2 of 4
(7,026 Views)
I Guess you are haveing problems of buffer wraping,
NXT has I2C buffer of 16 bytes and wnen you cross this boundry you have problems
that may be the reason you do not see  it when you read 8 bytes ( it should work for 4 as well)
0 Kudos
Message 3 of 4
(7,005 Views)
Hi,
 
i tested it with an EEProm and it works everytime with the Buffersize i choosed. With the US-Sensor it does not.
i think the Problem is the Programming of the MCU inside the US-Sensor. It wants to deliver a count of Bytes. If it
is not able to do it, it will be instable for an amount of reads. If i choose the amount of Bytes the US-Sensor wants to deliver
it is stable every read.
 
rgds
Harald
0 Kudos
Message 4 of 4
(7,002 Views)