06-11-2006 04:24 PM
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
06-12-2006 01:59 AM
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.
06-16-2006 03:30 PM
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
06-18-2006 12:56 PM - edited 06-18-2006 12:56 PM
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 ) 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
06-18-2006 05:33 PM
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.
THANKS!!!! Finally! I was able to fix my errors thanks to you.
- Sammy
06-19-2006 01:27 AM
Hi Sammy,
Sorry, did it again 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.
06-30-2006 01:08 PM
Hey KC,
Wow, placing the while loop instead of running it continuously is definitely a much wiser way of doing things 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
06-30-2006 02:13 PM
Hi Sammy,
Glad to see things are working.
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