02-08-2012 09:01 PM
The VI is designed to read a stream of data from a CO2 sensor. (See attached for the setup). It's a very simple read, process and then close the port. The VI is designed such that it will be running from anywhere from 2 hours to 2 days and the error seems to pop up at very random moments. Its says that the com port is in used but thats the only VI i have running and the only thing connected using that COM port is the sensor. There is another USB that is currently connected a DAQ but i dont think it matters.
Any ideas?
02-09-2012 06:49 PM
Hi Danwhc,
Try disabling the problematic com port via the Device Manager and restart the machine. After the computer restarts, re-enable the port and run your program to see if the error pops up again. If the error keeps coming up, let us know! I hope this helps.
02-09-2012 07:47 PM
02-09-2012 11:02 PM
Hi Aldo,
I did that and it happened on two different laptops so I'm pretty sure its not a problematic com port.
The error pops up every 5-10mins and its rather bad.
FYI. The com port is connected to a CO2 sensor that outputs 2 reading every second. Could that be the problem? I've thought about it and I think it might be the loop that is going faster opening the port again before the port is closed. I'm not sure if this is possible but I've yet to try to put in a wait function for 100mS to try to slow it down,
02-09-2012 11:05 PM
Hi Dennis,
I'm actually very new at this VISA and I'm not exactly proficient in the programming skills. I only have about 5 weeks worth and still on the learning curve. I'm basically doing my senior year project and i've been never been trained in software techniques. My major is bioengineering which focus alot on research so this is rather new. I'm willing to learn.
Please explain. Can I just open the COM port and leave it open? How does work in a loop?
02-09-2012 11:27 PM
02-09-2012 11:57 PM
Attached is the file i've been working with for your reference. It's a gas control system that would respond to the reading from the CO2 sensor and O2 sensor. Essentially, its an incubator that has a cyclic, variable control environment to study the effects of hypoxia and hypercania on the cellular level.
Dennis, I will try to implement the line of thought as soon as I can but I'm unsure if I can. I did try to pass in stuff using a tunnel into the while loop but was unable to do so.
Thanks.
02-10-2012 04:37 AM
02-10-2012 11:00 AM
Hi Albert
Thanks for that. I'll try that out as well. I forgot to mention that the sensor outputs in the following format. K ####### k ####### /r/n
Numbers following the K is the digitally filtered signal processed by the sensor while the k is the raw data. I dont need the raw data hence, i thought i only read in enough bits just for my purposes. I only need to read.
02-10-2012 12:09 PM
@Danwhc wrote:
Hi Albert
Thanks for that. I'll try that out as well. I forgot to mention that the sensor outputs in the following format. K ####### k ####### /r/n
Numbers following the K is the digitally filtered signal processed by the sensor while the k is the raw data. I dont need the raw data hence, i thought i only read in enough bits just for my purposes. I only need to read.
NO. That is simply not how serial communication works. You must read the entire buffer or else keep flushing it. Otherwise, as Albert mentioned, you lose sync with the data.
Since you have the termination character enabled and it appears that the device is actually sending one, you specify a high number for the bytes to read. The read will automatically terminate when the termination character is detected. Your very first read (i.e. one outside the loop) might be a partial read that you would simply discard. After that, you would read the entire string. You can parse the string with a single Scan From String as I previously mentioned. Your parsing is needlessly complex.
The rest of your code does not make much sense to me. You do not have your event structure inside a loop. Then, you have a timed sequence inside one event and while loops inside each sequence. All of this is bad program design. Please explain what you are attempting to do with this code.