LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 comunicaation doubt

Hi all

I have a Doubt with serial comunication. I need read and write data. The data for read comes for external hardaware(microcontroller), and data for write is for send to microcontroller. The read and write work very well separately, but when I want user the two in a single VI, no work well. I use a stacked sequence with 3 frames. one for read, one with a delay and the last for write.but No work well....

Can you help me?

I need know how use read and write

0 Kudos
Message 1 of 8
(2,756 Views)

Post your VI.

0 Kudos
Message 2 of 8
(2,748 Views)

Do you mean you have a question?  Don't have a doubt.  It will work.

 

You will need to attach a VI so we can see what you might be doing wrong.  The fact you said you have a 3 frame stacked sequence worries me to start with.  Stacked sequences should be avoided.  If you do need a sequence, then use a flat sequence structure.

 

Most devices, you need to write first to send out a command, then do a read to read back the response from the device.  The way you describe it, it sounds like you have it backwards.

0 Kudos
Message 3 of 8
(2,747 Views)
0 Kudos
Message 4 of 8
(2,739 Views)

Your cases for 1 and 2 don't have a new line/linefeed character within the string constants 1 and 2 like your cases for 4 and 8 do.

 

Replace your Stacked Sequence with a Flat sequence then do a block diagram cleanup to make your code easier to read.

 

Other than that, nothing else seems obviously wrong.

0 Kudos
Message 5 of 8
(2,730 Views)

Other than what Raven's Fan has pointed out, I don't see anything either.  You are intending to see a carriage return to terminate your received data, correct?  This is how you have it set up.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 8
(2,714 Views)

After you clean up the BD as Raven's Fan suggests, add an indicator on the output of Bytes at Port. Then you'll be able to see if you're getting the full number of bytes to complete the message. Changing the read buffer indicator to '\' Codes display any non-printable characters in your message.

 

If you know the length of the message, then you can monitor the Bytes at Port until you get the right number of bytes or see the termination character (\n). If you don't know how many bytes to expect, wait for some bytes then read until you get the termination character. Then you can eliminate those waits.

0 Kudos
Message 7 of 8
(2,706 Views)

You can just probe the wire at Bytes at Port instead of using an indicator.  Less clean-up that way.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 8 of 8
(2,688 Views)