LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert to number


@makewayforkhairil wrote:

And my checksum shows weirddd numbers, like AF, B0, 50, 6.


Those numbers aren't weird if you are thinking in hexadecimal. To convert to decimal, right-click the indicator on the FP and set Display Format to decimal. Otherwise, learn to think in hex (it really isn't that hard).

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 31 of 36
(704 Views)

Hes is some code to extract the data. You will need to set up the serial reads.

 

If it is just spewing serial data you could just do massive reads and use match pattern on the header, or you could read a byte at a time until you find the $, then do block reads from there.

 

deceased.

0 Kudos
Message 32 of 36
(668 Views)

This should do pretty much what you want.

 

The feedback nodes look a bit odd. But they would catch packets from strange data like $M$M>....etc

At the moment it only deals with cmd(104) ... if you need to implement others it should be easy enough.

 

The xor part will XOR all the data bytes, the cmd#  and the checksum.

If the packet is good, the result will be the cmd#

 

You will need to set up the Baud rate etc.

 

Make sure the termination character is set OFF when configuring the port.

 

 

0 Kudos
Message 33 of 36
(649 Views)

Hi deceased! Thank you so much for your help and effort. However, I'm having some problem. I am unable to run the VI due to an error.

 

"VISA: (Hex 0xBFFF006C) An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived."

0 Kudos
Message 34 of 36
(607 Views)

Hi makeway…,

 

that error occurs when you read the VISA buffer too slow. You need to read faster (using deceased's single byte approach) or more bytes at once!

 

I would read a fixed amount of bytes at once (let's say 16 bytes) and concatenate them in a string or byte array hold in a shift register…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 35 of 36
(582 Views)

What Baud rate have you set?

 

In the config.h file it says

/* This is the speed of the serial interface. 115200 kbit/s is the best option for a USB connection.*/
#define SERIAL_COM_SPEED 19200

 

Try setting it to 19200 in LabVIEW.

 

Picking bytes out of the buffer one at a time hasn't caused me issues before, but if it is problematic here you can resort to large serial reads, then parse out the string.

 

deceased

0 Kudos
Message 36 of 36
(563 Views)