05-11-2009 10:33 AM
Hello,
I'm trying acquisitionning the value of my KERN scale, through a USB port (the output of the device is RS 232) with the vi attached. My problem is that I would like to make one acquisition every hour or so. If I put a wait time in my while loop of even 1 second, it seems that the device keeps the value until we ask for it. So the more time is running, the bigger the time shift is. Any idea about what I am doing wrong ?
Thanks in advance for your help 🙂
Sylvian
Solved! Go to Solution.
05-11-2009 10:44 AM - edited 05-11-2009 10:46 AM
You have the while loop running as fast as it can, with no wait.
Also, I would use the 'bytes at port' function:
05-11-2009 11:02 AM
Cory,
If you use the Wait(ms) with such a large value, the stop button will not operate until the wait times out. In other words, you might have to wait an hour for the while loop to stop.
Also, the VISA Bytes at Serial Port is not at all necessary when the instrument sends a termination character. You just need to specify some arbitrary byte count larger than what yuo would expect. The VISA Read will automatically terminate when the term character is detected.
Sylvian,
You should calculate the elapsed time or just use the Elapsed Time function with the serial read code inside a case statement.
05-12-2009 05:08 AM
Thanks both of you for your answers.
I did what you advised Dennis (see in attachment), but I need to connect something in the false case, whereas I don't really want... Do you have an idea ?
05-15-2009 06:08 AM
Hi sylvian,
I would also go with the elapsed time express VI.Put a case structure around the Serial Commands and connect it to the Time has Elapsed output of the express VI. Use a shift register to store your array of measured values. Inside the case structure use Build Array to append the last value to your array.
Regards,
05-15-2009 06:20 AM
Thanks everybody for yours suggestions. I finally found a way (see VI attached).
Sylvian
05-15-2009 09:31 AM
It all seems silly to write values to the array and then remove them. The use of the local variable is also completely unnecessary.
To save when the loop finishes, you should be using a shift register and only update the shift register in the true case. To save while the loop is running, just place the file write code inside the case statement.
Shift registers are a basic element of LabVIEW. Check the tutorials, the online help, and the example VIs that come with LabVIEW.