LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modifying user input in for loop

Hi RavensFan,

What would be an example of wiring in a constant (which property do I wire it into)?

Also from what I understand the termination character is the last character the port should read. If you look at my program, you will see that I open and close the port many times and each time ends with a different termination character. So is it possible to wire different termination characters for different times the port is opened/closed? Could you give me an example of this as well..?

Thanks for all your help, really appreciate it
Mridu
0 Kudos
Message 11 of 24
(1,194 Views)

You don't need an example for how to wire a constant,  Instead of a wire from "Bytes at Port: going into the VISA Read, you put a constant.

 

Regularly opening and closing the serial port is generally a bad idea.

 

How do you have a different termination character for different messages?  Any real communication protocol uses a termination character such as the new line/linefeed character,  or a carriage return, consistently, and doesn't change it between messages.

 

If you ever do need to change the termiantion character, there is an input for that in the Serial Configuration subVI.

 

Turn on Context Help and hover over those functions.

Message 12 of 24
(1,179 Views)
So how do you then specify a termination character? Does it get wired into the same spot in the visa read as did the bytes at port? Or is wiring a constant just a better idea than doing anything with a termination character?
0 Kudos
Message 13 of 24
(1,108 Views)

Reread my last post.

 

1.  Turn on Context Help.

 

2.  There is an input for the termination character in the SERIAL CONFIGURATION subVI.  To be more specific, it is called "VISA Configure Serial Port"

 

Do you know what the termination character is for your instrument?  Have you read the manual about the communication protocol?

Message 14 of 24
(1,080 Views)

Sorry, I am really new to labveiw and this is a learning experience for me.

 

When I looked at the instrument manual, here is what I found: 

"When sending commands that require a value, the commands must end with a carriage return (Enter key or Return on most keyboards), comma, or a period."

When I format the string, I am adding commas between each command.. Would I need to add a carrige return at the end of the formatted string as the termination character?

 

Also do you have to use a constant wired into the byte count AND a termination character or will only one of these options suffice? 

 

Thank you again for all your help,

Mridu

0 Kudos
Message 15 of 24
(1,037 Views)

Yes.  You need to end your strings that you write with a carriage return.  If you set your strings to \codes display, then it will look like \r.

 

Yes you need to set the termination character,  Wire the value 13 decimal or 0D hex into the appropriate terminal of the VISA Configure Serial Port.  (I'm assuming that the since it tells you to end the commands with a carriage return, the responses it sends you will end with a carriage return.

 

  Yes you need to write a constant into the VISA write.  You already know you have to wire something in because you had a broken VI when you didn't.

 

If you are new to LabVIEW, you really need to take the tutorials.

LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours

Message 16 of 24
(1,019 Views)

Hi RavensFan,
Do you mean I need to wire a constant into the VISA read?

 

Also I am making progess, but now when I run the program I get the error "timeout expired before the operation completed". From what I understand, the timeout would only expire if it is not picking up on the termination character, which I have put in.. Can you look at my code maybe and tell me what may be the problem?

 

Thanks in advance,

Mridu

0 Kudos
Message 17 of 24
(933 Views)

@mnanda98 wrote:

Hi RavensFan,
Do you mean I need to wire a constant into the VISA read?

 

Isn't that exactly what I said?

 

Also I am making progess, but now when I run the program I get the error "timeout expired before the operation completed". From what I understand, the timeout would only expire if it is not picking up on the termination character, which I have put in.. Can you look at my code maybe and tell me what may be the problem?

 

 

It looks like you've set the termination character to be a carriage retrrun (decimal 13) just fine.  So if you are getting a timeout error, that means you are either not sending the commands correctly and the device is not responding, or the termination character is not actually a carriage return like you said.

 

Do you have any software that the vendor of the device  might have supplied that can prove to you that it is communicating correctly?  Is any data returned in the string indicators when it finally times out?

 

Thanks in advance,

Mridu


 And why do you still have the VISA Close inside the loop closing the port on each iteration?  It belongs after the while loop.

Message 18 of 24
(929 Views)

Hi RavensFan,

 

When I tried to put the VISA close outside the two for loops, I got the following error: "you have connected two terminats of different types" 

0 Kudos
Message 19 of 24
(912 Views)

Did you look more closely at the error?  Hover over the wire?  It will tell you why they are two different types.

 

Spoiler
My guess is that one of the wires such as the VISA reference wire became auto-indexing and you now have a 1-D array of references.  Take the tutorials and you'll understand what autp-indexing means.
0 Kudos
Message 20 of 24
(909 Views)