Home > Software engineering >  Three axis sensor serial data using VB6 problem of how to parse, help you god
Three axis sensor serial data using VB6 problem of how to parse, help you god

Time:10-01

RT, for example: a serial port receives a group of data is now 23 51 00 00 2 e 15 08 F5 F0 F9
0 0 x55 baotou
1 0 x51 identify this package is acceleration package
AxL 2 X axis acceleration low byte
3 AxH X axis acceleration high byte
4 AyL y axis acceleration low byte
5 AyH y acceleration high byte
6 AzL z axis acceleration low byte
7 AzH z axis acceleration high byte
8 TL temperature low byte
High temperature in the 9 TH bytes
10 Sum checksum

Acceleration formula:
Ax=((AxH<8) | AxL)/32768 * 16 g (g as the acceleration of gravity, 9.8 m/s2)

Ay=((AyH<8) | AyL)/32768 * 16 g (g as the acceleration of gravity, 9.8 m/s2)

Az=((AzH<8) | AzL)/32768 * 16 g (g as the acceleration of gravity, 9.8 m/s2)

Temperature calculation formula:
T=((TH<8) | TL)/340 + 36.53
The checksum:
Sum=0 x55 + 0 x51 + AxH + AxL + AyL AyH + + + + TH AzL AzH + TL
My small white, would like to ask you how to use VB6 under the parsing code, to write the code structure, thanks

CodePudding user response:

VB 0 x55 writing & amp; H55 0 x00 VB writing & amp; H0

CodePudding user response:

I estimate that the original poster is not taking out data from serial port,,,

CodePudding user response:

Shift to the left of eight is multiplied by the, moves to the right is the eighth divided by 2

CodePudding user response:

 Dim (a) As Byte 
Dim ax As Double
Dim ay As Double
Dim az As Double

A=MSComm1. Input ()

If a (0)=& amp; H55 And a (1)=& amp; H51 Then
Ax=(a (3) * & amp; H100 & amp; + a (2))/& amp; H800 & amp; * 9.8
Ay=(a (5) * & amp; H100 & amp; + a (4))/& amp; H800 & amp; * 9.8
Az=(a (7) * & amp; H100 & amp; + a (6))/& amp; H800 & amp; * 9.8
.
End the If
  • Related