LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading serial from 3rd party device

Solved!
Go to solution

Hello GerdW

 

I checked my string constants, but still it fails..

Serial_3.png

0 Kudos
Message 11 of 24
(2,056 Views)

According to the manual you should include in the frame also the ckecksum. Are you including it? What is the command in the example you has shown? 

 

Thanks,

Arev

 

CTO | RAFA Solutions

 

Certified-LabVIEW-Embedded-Systems-Developer_rgb.jpgCertified-LabVIEW-Architect_rgb.jpg

0 Kudos
Message 12 of 24
(2,034 Views)

Hello,

 

If you see in the manual under 5.1, you have the command: 'd' 0x9C

 

I include the checksum which is 0X9C, so my command is 649C 0D, where 0D is \r. I managed to get out data now by disabling -> enabling the COM20 port.

 

My result string is: 64FF FFFF FFFF FFFF FFFF 4800 5D. The format looks correct compared to example in 5.1, but values are strange. Why FF FFFF FFFF FFFF FFFF? The device is connected and ON.

 

Serial_4.png

 

br,

paalbrok

0 Kudos
Message 13 of 24
(2,021 Views)

Hello,

 

If you see in the manual under 5.1, you have the command: 'd' 0x9C

 

I include the checksum which is 0X9C, so my command is 649C 0D, where 0D is \r. I managed to get out data now by disabling -> enabling the COM20 port.

 

My result string is: 64FF FFFF FFFF FFFF FFFF 4800 5D. The format looks correct compared to example in 5.1, but values are strange. Why FF FFFF FFFF FFFF FFFF? The device is connected and ON.

 

Serial_4.png

 

br,

paalbrok

0 Kudos
Message 14 of 24
(2,015 Views)

Hi paalbrok,

 

on the content of the device answer you should ask the manufacturer of your device!

 

Nice to see the communication is working now!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 24
(2,002 Views)

Hello GerdW,

 

I've got another problem. I actually read out the HEX string only when I run the code using highlight execution. If I run the code at full speed, it doesn't read out anything. I've tried to put code inside a loop and slow it down, but it doesn't work.

 

Do you have any ideas?

 

br,

paalbrok

0 Kudos
Message 16 of 24
(2,001 Views)
Solution
Accepted by topic author paalbrok

Hi paalbrok,

 

when you run the code shown above (without any loop) it's no wonder it will not work.

 

You call BytesAtPort immediatly after writing the command to the serial write buffer. At this very moment your device didn't receive any command yet - and there surely is no answer in the serial receive buffer!

General answer: Using BytesAtPort most often is the wrong way to have a serial communication. You either use the TermChar or you read a certain number of bytes.

In your case you know from the manual how many bytes you expect as answer of the "d" command. Just read that number!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 17 of 24
(1,992 Views)

Hi GerdW,

 

Thank you for your answer.

 

Of course... Need to delay down before bytes at port to get response back to program. I use a while loop, but your tips seems to be a better way to do it. Do you have the possibility to modify my code and return it to me?

 

br,

paalbrok

 

0 Kudos
Message 18 of 24
(1,978 Views)

@paalbrok wrote:

Hi GerdW,

 

Thank you for your answer.

 

Of course... Need to delay down before bytes at port to get response back to program. I use a while loop, but your tips seems to be a better way to do it. Do you have the possibility to modify my code and return it to me?

 


No!!! Get rid of Bytes at Serial Port and read the right amount of characters! If you start to add delays in device communication software to make it work you can be almost 100% sure that you are doing something wrong! Your device protocol is a binary fixed size protocol. Every message has a specific size that is determined by the message type. For a simple driver you can simply read the number of bytes that a response has, since you know what command you send and what answer you expect.

For a more robust driver you would most likely read the first byte and from that determine the message type that is to follow and then read as many characters as that message type is supposed to contain. VISA Read has a timeout and will only return when:

 

- an error occures in an underlaying driver

- the timeout occures

- the number of requested bytes has been read

- the termination character is received (if enabled, which you don't need here since there is no specific termination character in the messages)

Rolf Kalbermatter
My Blog
0 Kudos
Message 19 of 24
(1,963 Views)

Hi,

 

I'm a newbie in labview

 

I want to import to labview 4 signals from equipment that have the following outputs:

 

- 4-20mA Pressure signal;

- 4-20mA Flowrate signal;

- 4-20mA rotation speed signal;

- 4-20mA Torque signal;

 

I have this 4 signals in RS232.

 

What's the better way to import this data to labview?

 

Thanks advance

0 Kudos
Message 20 of 24
(1,944 Views)