Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

timeout on serial communication with LS 321 temperature Controller

Hi KC,

I have another question. When you send a query, is it possible for the instrument to send a different number of bytes for different queries? Because I observed that for the "Bytes at Port" function, it would output 3 bytes to see if the heater was either off, low, or high (query command "rang?"). When I sent "setp?" asking for the setpoint, it would output 9 bytes  at the "Bytes at Port" function as opposed to 3.

Also, I always get error code 5000 and source time-out when I am sending command strings. Do you perhaps know why it's doing that?

Thanks,

Sammy

0 Kudos
Message 11 of 18
(2,534 Views)

Hi Sammy,

If I understand you well you can talk to your instrument now ?

Your VI is OK but i don't understand why you are using a frame. Without the frame it will work because of the dataflow by wires. (error cluster and VISA ref.)

Most of the time I don't use the termination character by setting this input to false. It got me into trouble with non ascii transfers.

 

If your manual says to add a <cr> I would do so. You never know if it will react OK with all commands if you don't.

I don't know your instrument but normally you can expect that devices will return answers in different string lengths.

 

My VI: In the first case statement I add a <cr> or nothing depending on the boolean input (default is add). The string is in hex (right mouse click)

In the do while loop I wait till the loopnumber is greater then the timeout divided by 100 (loop time is 100msec) OR if the number of bytes received is equal or greater than expected. 

If no time-out occured (and no error) I read the data (the expected number of bytes !!) from the port.

Message 12 of 18
(2,527 Views)

Hi KC,

Thanks a lot for the help. From your program that you've given me, I finally understood that there are a different number of bytes being sent out depending on which command. And if I have too many number of bytes for the input, I would get a timeout. I fixed the number of expected bytes for each VISA read to the values that I found through your program and I think I have solved the error!

I have a question though. I tried running this program continuously. It works on the first run, but when it runs again, the timeout error seems to have peaked its nasty head out again. Do you think I should implement a VISA Clear function before I initialize the VISA session because there may be data stored in the buffer from the last program run? I tried implementing that, but I got a timeout error again.

Attached is the updated version of my vi.

Thanks!

Sammy

0 Kudos
Message 13 of 18
(2,505 Views)

Hi Sammy,

First some advise: if your program gets bigger then one screen ( i always use a windows never a full screen) start making sub VI's. your program 'reads' better that way even if you use the sub VI's once.

NEVER use the 'run continuously' button (of course there are exceptions)

I removed the sequence structure in your progam (everything if controled through the dataflow i think  Smiley Surprised  ) and place a while loop with a STOP control on your front panel.

The open and close of the COM port are outside the while loop. So they are only executed once when you run the VI.

How does this works ?

 

Message Edited by K C on 06-18-2006 07:57 PM

Message 14 of 18
(2,493 Views)

Hi KC,

I greatly appreciate your help in getting me through this. Unfortunately, I can't load the program you sent me because I only have LabView 7.0. If you can, please send me the 7.0 version.

Smiley Very Happy THANKS!!!! Finally! I was able to fix my errors thanks to you.

- Sammy

0 Kudos
Message 15 of 18
(2,482 Views)

Hi Sammy,

Sorry, did it again  Smiley Wink   I made this yesterday evening at home with 7.1

Here it is in 7.0

If you have any other questions just post it here.

 

0 Kudos
Message 16 of 18
(2,474 Views)

Hey KC,

Wow, placing the while loop instead of running it continuously is definitely a much wiser way of doing things Smiley Tongue Thanks!

I tried running your vi, but the stop button doesn't exit the program, which is really weird. Do you know how I should fix this?

But all in all, the program works! Thank you so much for helping me out. I'm glad there are discussion forums like these.

- Sammy

0 Kudos
Message 17 of 18
(2,413 Views)

Hi Sammy,

Glad to see things are working.  Smiley Happy

I did not see the inside while-loop. This one has to be stopt with your condition and the stop button. See the local variable.

It should work now if your for-loop stops

0 Kudos
Message 18 of 18
(2,408 Views)