LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication

Hi, 

I am using serial communication to communicate with my device. It is some sort of water level data logger with other "options". But it really doesn't matter for my question.

The communication works with my attached file, but the it is very slow becouse. I wait too long for read VISA buffer (100ms). But if I wait less time, there comes to data loss. I tried to enable termination character but it didn't worke for me. I need to code that checks byte per byte and when it detects number 83 in hex it stops and return everything what has been read so far. The output data is every time a different size. 

I make default values in Vi so you can see the input data and output (loggers answer). 

Thanks for your help,

Božidar

0 Kudos
Message 1 of 12
(2,394 Views)

My first question is, is this being used as a SubVI? I ask because I do not see your VISA Config Serial Port. Are you passing this over to your VISA Resource Control?

0 Kudos
Message 2 of 12
(2,369 Views)

If you want to read everything up to the first 0x83 sign, use 0x83 as your termination char with a large number at the input byte count and you are done.

 

On a side node what baud rate are you using? The answer string that you posted in VI has a length of 93 bytes. At a typical rate of 9600 baud the transmission of this 93 bytes already needs about 100 ms.

 

Best regards

Jens

Kudos are welcome...
0 Kudos
Message 3 of 12
(2,368 Views)

Also, you need to wire the error wire (yellow wire) into to and out of your Bytes to Port Property Node. Don't pass this.

0 Kudos
Message 4 of 12
(2,367 Views)

Yes, this is SubVi. I use 38400 baud rate. I tried to use termination character with example Vi (advanced serial write and read communication) but no luck. Not a single byte came out. 

0 Kudos
Message 5 of 12
(2,356 Views)

Bozidar,

 

Can you post the part of your code that opens/configures the COM port?

0 Kudos
Message 6 of 12
(2,345 Views)

Sure

Download All
0 Kudos
Message 7 of 12
(2,337 Views)

Seems that your communication always start with x82 and end with x83.

So  configure the COM to terminate with CHAR x83

 

Try this (untested) with your COM setup before hitting RUN

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 8 of 12
(2,336 Views)

@Bozidar wrote:

Yes, this is SubVi. I use 38400 baud rate. I tried to use termination character with example Vi (advanced serial write and read communication) but no luck. Not a single byte came out. 


Then you've made something wrong in that example.

 

I just tried it by sending your example answer from one RS232 to another on my computer. Using 0x83 as termination char works fine. I either get a time-out or the complete string.

 

Back to timings in your example: Your request string is 23 bytes, your answer 93 bytes. At a baud rate of 38400 it takes about 30 ms to transmit these 116 bytes. Also take into account that your logger needs some time to put your request.

 

Best regards,

Jens

Kudos are welcome...
Message 9 of 12
(2,335 Views)

Why do you use 83dez as termination char in your "ConnectToDevice.vi"?

 

Display the radix on this U8 (right click -> Visible Items -> Radix) and change it to 0x83.

 

Best regards,

Jens

Kudos are welcome...
0 Kudos
Message 10 of 12
(2,327 Views)