Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Read an 8 byte hex-coded message

Trying to read a hex-coded in which every byte represents two numbers or A-F letters coded in hexadecimal.The baud rate of the bus is 115200 and I want to read at an interval of 10 times per second.

Message format=8 bytes.
The first byte(The frame) starts with AB(This is the synchronization point to split the message in 8 bytes ans show every byte separately)to read the 8 byte messages continuosly.
One start and one stop bit in every byte.
0 Kudos
Message 1 of 7
(4,177 Views)
What development environment are you working in? LabVIEW, CVI, etc?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 7
(4,177 Views)
LabVIEW 6.1
0 Kudos
Message 3 of 7
(4,177 Views)
Take a look at the example located in

Search examples>>>Hardware input and output>>>Serial.

Take a look at all three because none of them do EXACTLY what you want, but they show how to take care of the I/O you need to do.

What you will end up doing is put you serial read function inside a while loop that is controled by a front panel boolean switch. Set the read operation up to read the number of bytes you expect to recieve. The returned string should then be wired to a

numeric>>>conversion>>>String to byte array

Drop a "wait" in the loop and wire a constant of 100 to the input.

THis approach should get you started. It stands for a lot of improvement particularly with issues like starting to read in the middle of a previously transmitted packet, er
ror recovery etc.

If you have specific questions regarding what you find, let me know and I will see if I can help.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 7
(4,177 Views)
I have been doing what you recomended.The wait in the loop specified with 100ms is not needed. At 8 bytes the loop is already slowed down. You figured out the problem of reading from the midddle of the frame. I am trying to identify the bytes start before I read in the main loop.
When I read in the main loop,after string to byte I use an array subset( having peviosly captured the part of the string after its start, say AB synchronization point, with the match pattern vi and reading from the after match terminal of this vi)
When I read more than 8 bytes, say 64 bytes, the loop is already very slow-approx 1 update per second.
0 Kudos
Message 5 of 7
(4,177 Views)
Two possible ideas come to mind.

1) Thedevice is not transmitting very often.

2) Are you opening and configuring the port once before you enter the loop and only doing reads inside the loop? Repeated re-configs of the port could take a while.

If these don't help post a picture so I can take a peak.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 7
(4,177 Views)
Two possible ideas come to mind.

1) Thedevice is not transmitting very often.

2) Are you opening and configuring the port once before you enter the loop and only doing reads inside the loop? Repeated re-configs of the port could take a while.

If these don't help post a picture so I can take a peak.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 7
(4,177 Views)