LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 Write Problem

Hello, everyone:
 
I have a question about using RS232.
 
I want to use RS232 to remote control an instrument.
I tried Basic Serial Write and Read.vi, and it worked well.
When I input my command into the box of "string to write", the instrument will response.
 
But, I need to input hundreds of the similar commands in one minute.
For example, 300 similar commands (p=0.1; p=0.2; p=0.3; ...) in one minute.
So I decide to use a for loop to input these commands.
But it always does not work.
The circuit is shown below in the attachment.
I think the only difference between my circuit and the "Basic Serial Write and Read.vi" is the input method. In my circuit, I use a "Concatenate Strings" to generate the command then write this command to RS232. However, in "Basic Serial Write and Read.vi", they use "String to Write" to input the string.
Maybe the command written in "String to Write" is different from the "Concatenate Strings"?
 
I am not sure how to fix this problem.
Well, I think I still need to use that for loop to input the commands.
 
Thank you very much for help.

Stone
0 Kudos
Message 1 of 11
(2,847 Views)

I should mention, the commands are exactly the same in "Concatenate Strings"(through the string indicator) and the ""String to Write"( I just coped the commands into it). 

But only the latter one worked.

0 Kudos
Message 2 of 11
(2,837 Views)
Move the Close VISA Session to outside the loop. After the first iteration the VISA session wil be invalid an on further writing will take place. What kind of error message do you get?

Lynn
0 Kudos
Message 3 of 11
(2,829 Views)

Hi, Lynn,

Thanks! I will try your suggestion.

"What kind of error message do you get?"

In fact, there is no error message in Labview. The problem is that the instrument indicates the command has error. The instrument does not understand the command.

 

 

0 Kudos
Message 4 of 11
(2,824 Views)

Hi, Lynn,

"Move the Close VISA Session to outside the loop."

I can not move the VISA Close outside the for loop or the case structure. It is not allowed, the wires (VISA resource name and the error wires) are broken.

Do you have any more suggestions?

 

Thanks!

 

0 Kudos
Message 5 of 11
(2,821 Views)

Yes you can, the wire are most likly broken for one ot both of these reasons.

1. Make sure you disable the auto indexing on the for loop, right click on the tunnel of the for loop and disable indexing.

2. When you have wires leaving a case structure you are required to connect the wires in each case. So in the false case just connect the tunnels on the right side of the case structure to the tunnels on the left, or right click on the tunnels on the left of the case structure and select Use Default if unwired.

Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
0 Kudos
Message 6 of 11
(2,810 Views)
It certainly can be done. I suspect you have one or both of two kinds of errors.

When you extend the wire out of the for loop, does the tunnel have little [] inside it? If so, then autoindexing is enabled, causing it to build an array of errors. Context-click on the tunnel and Disable autoindexing. Another option is to use a shift register rather than tunnels. If an error occurs on an early iteration the Write VI will not attempt to continue writing but just pass the error through.

When you run the wire out of the Case structure do you get a hollow tunnel? If so, you must wire something to the tunnel in all other cases. Since the other case is empty, just wire the error cluster straight across.

If you are seeing these errors and not recognizing them, it suggests that you are very new to LabVIEW. Spending a few hours on the tutorials will be time well spent.

Lynn
0 Kudos
Message 7 of 11
(2,806 Views)
Yes! It works in software. I will test them in the hardware! Thank you very much, Andrew Alford and Lynn!
0 Kudos
Message 8 of 11
(2,800 Views)

Hello, everyone:

It seems that this does not solve the problem.

I even simplify the circuit like below shown, where I tried to input the command string "*CLS\n" into the instrument. But the instrument response an error.

However, if I use "Basic Serial Write and Read.vi", and copy "*CLS\n" into the box of "string to write", the instrument will response without error.

I can not see any difference between these two.

Could you please help me.

Thanks very much for help!

 

Stone

 

Message Edited by Little Stone on 03-09-2007 04:48 PM

Message Edited by Little Stone on 03-09-2007 04:50 PM

0 Kudos
Message 9 of 11
(2,795 Views)
You are not sending the control code \n. You are sending the characters '\' and 'n'. In order to do it correctly like the example, right click on the string constant and select '\' Codes Display.
Message 10 of 11
(2,783 Views)