07-05-2012 10:44 AM
Hi, I have a question. Is it possible to put a VISA Read inside a whie loop, while a VISA Serial Port is outside the while loop, then connected each other. Are there any issues with this? If yes, which while loop stop condition should I use in this case?
My VI acquires the data from the port only once at the begeinning, then never obtains any data again. It might be an issue with while loop.
I also put my VISA Read in a sub VI which I am not sure if it can cause a problem.
07-05-2012 11:00 AM
Yes, it is typical to put the initilization outside the loop and the reads inside the loop.
However, your SubVI, which calls another SubVI, then re-initilizes the connection. Don't re-initilize the connection, just pass the reference.
Also, when I unzip the sub VI's, and open the thesis VI, all the wires are broken as if this is not the correct top level VI. SPlitting Values is also missing.
07-05-2012 11:05 AM
Not at all. In fact, that's how it's supposed to be done.
Initialize outside of loop, read/write/whatever repeatedly inside of loop, close outside of loop.
I'm getting a lot of broken wires and subVIs that need relinked and one VI missing. Did you give us older version of the subVIs or was this just where you got stuck? I also noticed that you are initializing the serial port twice (main VI and read VI).
07-05-2012 11:25 AM - edited 07-05-2012 11:27 AM
Sorry for your inconvenience to download my sub VIs but I dont have Winzip now. There is only one initial VISA serial port and one VISA inside the big while loop. As I told you, the VISA reads only once at the beginning, then no more response . Is it related with bit or baudrate? Or mv VI is too big? I notice that while it is measuring the data, it's quite slow too. Very slow!! What should I change or add into my VI in this case?
Thanks for your helps
07-05-2012 12:30 PM - edited 07-05-2012 12:32 PM
I used all the individual SUBVI's you posted. Still, the 'VI connection' SubVI doesn't match with the name for top level Thesis. The name the top level is looking for is 'VI connection', the Sub you provided is 'VIs connection'. The names are different, but I used the Sub provided.
So, just to be sure, previously from the ZIP files, the VI connection called another Sub that Re-initialized the connection, and you don't want to do that. But that is gone now.
Now, the VI looks correct (no re-init), but it is not the name the Thesis top level VI is looking for. So it is possible that you are running the Thesis VI with a SubVI that is different than what was posted. I just wanted to mention that.
What are you getting from the Read of the device after the first read? If there is no read, the VISA should time out and kick out an error as it is reading a fixed number of bytes. Are you getting the "#" that you are looking for after the first read? Maybe this "#" is not in subsequent messages, and this makes the data look like it is not reading.
On the surface, the code appears to be functional, you are reading based on a number of bytes, you might have better luck looking for a termination character instead.
07-05-2012 12:52 PM
Sorry I attached VI connection for you. They are the same files with different names. It shouldn't be the issue about calling the wrong sub VI because I have both VI and VIs connection on my computer.
After the first read, the acquired values still change (but randomly). I tested it by adding tempertaure to a specific sensor, but it did not respond anymore after the program is started. It measures only one time. VISA doesn't kick out or do anything. The values keep changing randomly (I have no clue by they are changing all the time, even though they don't respond anymore)
What is a termination character? Which fucntion is it responsible for? How should I change it?
I think it might be an issue about the while loop because the VISA read obtains the read values only once. However, you said it isn't related with that, so I have no clue!!!
I also attached the original sub VI for the data acquisition that I received from the test bench, and then extracted all block diagrams inside the while loop and put into my big VI's while loop. And connected the VISA serial part outside the while loop.
I am pretty desperate now. I don't know how to make it work
07-05-2012 01:15 PM - edited 07-05-2012 01:17 PM
Can you describe a bit more about the second loop read. You are saying the acquired values still read, but they are random.
The program sets the buffer quite large 40960, was this supposed to be only 4096? It is possible that you are putting a lot of data in the buffer, but only reading the values set by the number of bytes (200). So, this could appear that you are getting random or incomplete data each subsequent read. Do you know what size data you will be reading? You might try setting the number of bytes to read to 40960.
I see now that the program is setting and enabling the termination character ( on the init VISA serial). It is currently set to "\n". This means the VISA read will stop when it encounters a "\n". I think you should choose one or the other, termination character or byte count.
The way you are set up now I think the VISA is looking for either the byte count (200) or the termination character (\n), so set the byte count high.
I don't see any write commands. Is this instrument "just broadcasting" all the time?
Did the original 'data read' VI ever work ? (which you say is the foundation fo the Thesis VI)