LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read hex data from serial

Solved!
Go to solution

Header

Message Info

Period

Not Using

0xAB

0xCD

0x0A

Period Low Byte

Period High Byte

0x0000

0xBC

0xDF

 

-set period=1=> my code: “AB CD 0A 01 00 00 00” PC sending to Device

-period is ok response code: "DC BA A0 00 01 00 00" Device sending to PC

-Start measure code: "AB CD BC 00 00 00 00" PC sending to Device

-Example Measuring: "DC BA D0 XX XX 00 00" Device sending to PC

"DC BA D0 XX XX 00 00" Device sending to PC

"DC BA D0 XX XX 00 00" Device sending to PC

"DC BA D0 XX XX 00 00" Device sending to PC

 

-Finish measure code: "AB CD DF 00 00 00 00" PC sending to Device

 

I can do that with any SerialPortCommunication programs. But not with labview.

bytes at port value zero

 

 

0 Kudos
Message 1 of 10
(3,995 Views)

You are supposed to send the binary representation of the Hex values, not the ASCII characters hex numbers. You are sending the ASCII character 'A' (which is 1 byte) instead of the numeric value in hex (4 bits).

 

Use an array of U8's - each one containing the hex pairs and then use array of U8 to string to send over serial.

 

Like this:

ByteArray.png

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 10
(3,983 Views)
And you should not be enabling the termination character.
Message 3 of 10
(3,975 Views)
If SamSharp is right, you could alternately right click the string constantsconstants and change them to hex format, then reenter the values. Although if it is the case that you need to send the raw values, then I'm not sure why it's working for you in any other serial communication program. Are the string constants identical to what you're entering in the serial com program, including spaces? Also, I'm not sure you want to enable the termination character on writes, unless that's also part of the protocol.
Message 4 of 10
(3,971 Views)
Solution
Accepted by topic author YFA

Oh yes, I had forgotten you could do that nathand. Thanks for reminding me!

 

StringByte.png


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 5 of 10
(3,954 Views)

Thank you now i can read data from my device but my read data is:

 

0000 DCBA 0DE1 3000 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00DC BA0D 56F4 0000 DCBA 0D56 F400 00

 

for one itteration and my period is "10". Why its not synchronize. You can see serial communication program from attachment. And my vi.

I need read data like serial comminication program.

 

Download All
0 Kudos
Message 6 of 10
(3,876 Views)

Thank you. Now i can read data from my device. But its still not synchronize.

 How can i get datas like serial communication program (in attachment ss.png)

 

Download All
0 Kudos
Message 7 of 10
(3,933 Views)

Do NOT use the Bytes At Port.  That can easily throw things off unless you have your waits just right.

 

So let's look at your data structure.  It looks like there are 7 bytes in each message.  So just set the number of bytes to read on the VISA Read to 7.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 10
(3,919 Views)

Don't use the Bytes at Port method immediately after a Write.  Use a small wait statement in there to give the device time to read the message and output a full reply.  Then you can use Bytes at Port to determine how long the reply is and read it.

Message 9 of 10
(3,906 Views)

Thank you all. Now its working perfectly.

 

0 Kudos
Message 10 of 10
(3,853 Views)