LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial communication

Hello,

 

I'm trying to programme serial comm using VISA in Labview and i'm beginner in Labview; never used it before.  I' m trying to read serial data for our project.  I can read it thourgh hyperterminal using "B01' command.  but somehow i can't read in Labview.  Can anyone help me please?  I have attached the sceenshots of hyperterminal and my labview programme.  i've tried all the examples which are included in labview and read all posts.  but no luck.  Thanks.

Download All
0 Kudos
Message 1 of 10
(3,378 Views)

What happens when you run it? Do you want to send the command on each iteration? It looks like you have the termination enabled. This means that the read will stop after that character is received. Do you know that your device sends this termination character? The next time around you are writing the command again even if there are more lines available. You have to put your read in a loop and stop when you know the device has sent everything it is supposed to send.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 10
(3,371 Views)

I'm happy to see that you used Hyperterm to check things out. Very smart.

 

In the LabVIEW code, in the Write Buffer, be sure you are sending the termination character (LF). You can concatenate it as a constant, or add it as you type.

Richard






0 Kudos
Message 3 of 10
(3,367 Views)

Your VI doesn't have the command saved in it to show what you are writing.  You say you are sending B01 in hyperterminal.  Are you hitting the enter key?  Perhaps you need to send a termination character with the B01 such as a carriage return/line feed, or just a carriage return, or just a linefeed, that you are failing to include in your VI.

0 Kudos
Message 4 of 10
(3,360 Views)

Steve,

 

I don't want send command on each iteration.  i don't think my device sends termination character.  i have put termination char to false now.

 

I tried with  \n and \r termination character. it doesn't work. 

 

Ravens,

 

the command i send is same way as hyperterminal B01 and hit enter key.  After hitting the enter key the device would keep outputing data every 1 seconds until i stop serial connection. 

 

Thank you guys.

0 Kudos
Message 5 of 10
(3,345 Views)

No No No.

 

The termination character I'm talking about is the one you send when you send the command to the device.  Not the one the device sends to you.  If you are hitting an enter key, then you are sending a carriage return/linefeed, so you need to put that into the command you are sending.  (Or it could be just a LF, or just a CR).

 

If you send the command once and the device continues to send data, then you don't want to send the Write command on every iteration of the loop.

 

I have modified your VI.  See how this works.

0 Kudos
Message 6 of 10
(3,336 Views)

Alternatively, the concatenation method (shown below) that I mentioned allows the B01 text to remain as is, making that control easier to change - don't have to remember the other characters.

 

 

 

 

Richard






0 Kudos
Message 7 of 10
(3,330 Views)

Raven,

 

I've tried your modifiied VI but no luck. i eve put a delay before reading it.  My device needs to be connected to serial port before i power up so i have a delay loop right after VISA port and before write.  It would be give couple of seconds to power up the unit .  I,m using usb to serial converter then serial to 3 wire.  one the wire is ground. i can't see any serial data. 

Download All
0 Kudos
Message 8 of 10
(3,295 Views)

You are getting something back,.  But it doesn't look like data, but some kind of error flag, "!"  It is possible that the serial write should be ending with something other than a CRLF.  Have you tried just a carriage return?  Just a line feed?

 

Plus, along with getting something, you are getting a timeout.  So perhaps the termination character the device is sending is not a line feed that is the default value for the Serial Configuration VI.  Wire up a constant to that input of the configuration VI and try a carriage return (decimal 13, or hex 0D).

 

Have you read the manual for this device?  What does it say?  What is the name and model of the device you are trying to communicate with.

0 Kudos
Message 9 of 10
(3,282 Views)

Do you ever see any data received in your receive count indicator?


@Amit Patel2 wrote:

Raven,

 

I've tried your modifiied VI but no luck. i eve put a delay before reading it.  My device needs to be connected to serial port before i power up so i have a delay loop right after VISA port and before write.  It would be give couple of seconds to power up the unit .  I,m using usb to serial converter then serial to 3 wire.  one the wire is ground. i can't see any serial data. 


What do you mean you can't see any serial data?  On your fp or are you speaking about the harness?  So your using a different port now correct? Port 3 from port 27?  I just wanted to clarify.

-----------------------------------------------------------------------------------------
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 10 of 10
(3,251 Views)