02-16-2012 02:37 PM
Hello everyone,
Using the serial port at the back of an OHAUS Ranger balance, I have managed to connect it to my PC via serial to USB connection. Through Hyperterminal, I was able to get a reading of the mass as shown on the balance on my computer screen. However, the problem came when I tried to implement a mass reading to LabVIEW (8.6). Attached is an image of what my code looks like.. It's very brief for it is just a test program.
Though I am getting something on the read buffer, it seems as though it is just unreadable characters refreshing with my set timer. I have set the Baud rate, the parity and the stop to how it is set on the balance. Could anyone throw me some advice? I am pretty new to LabVIEW so chances are, I am definitely messing something up!
Thanks,
Justin
Solved! Go to Solution.
02-16-2012 02:50 PM
02-16-2012 03:45 PM
Thanks for the tip. I have moved the initiate out of the while look and set the Enable Termination to True. This has seemed to stabilize the signal and is constantly sending a value of 0.0 g no matter what the reading is on the balance. Also, every now and then, the number shown on the read buffer will go from the 0.0 g to a set of unreadable characters and back to 0.0 g. Though it is considerably better than before!
02-17-2012 10:40 AM
It turns out that the timer of in the loop is what was preventing me from getting a live reading. I have removed the timer and now it seems to give me the proper reading but now that the timer is gone I am having some new issues.
1) A couple seconds into running my program, I will get a blue screen which restarts my computer. It said something about STOP: 0x0000008E or something and apparently that has to do with memory issues. What in my program could be causing this issue?
2) For the seconds that the program runs before crashing my computer, the values seem to show '0.5g?'. I have noticed while running hyperterminal that whenever the mass is changing, the read values will have a ? after the reading but when the mass stabilizes, it'll just show the reading without a '?'. I am assuming this has something to do to distinguish between stable balance readings. Is there a way to remove the ? and the unit 'g' in the reading indicator?
Thanks,
Justin
02-17-2012 10:43 AM
Oops, sorry, I forgot to attach my VI. Here it is.
Also, here are the settings for the COM port. These settings are matched on the balance as well.
BAUD RATE - 2400
PARITY - NONE
data bits - 7
Stop - 2
02-17-2012 02:40 PM
I see no reason for crashing in this vi.
Maybe you were reading to liitle data, (too small bytecount) and that would fill up the buffer and together with a bad serial driver that is the only thing I could see.
I changed that part to read a whole string and convert it into a double, but maybe that generates an error itself.
02-17-2012 03:06 PM
I had the byte count set to Bytes at Serial Port. I updated both NI Serial and NI VISA drivers. Are there any other drivers of concern that I should be trying to update? By setting the byte count to bytes at serial port and enabling termination characters, I do get very good readings, no weird characters and the reading stays in the correct frame. However, still, a couple seconds in, i get the blue screen. I have read through other DRIVER_IRQL_NOT_LESS_OR_EQUAL forum discussions and thats where I got the idea to set the byte count to bytes at serial port. Where it worked for them, it didn't work for me. I'm thinking it has to do with drivers and my specific PC.
02-17-2012 05:23 PM
Normally you do not need both termination character enabled and Bytes at Port. If the balance sends a termination character, get rid of Bytes at Port. Wire a constant with a value much larger than the maximum message length to the Byte Count input of VISA Read. Except for the first time through the loop, this should always give you a complete message. You do not need a timer because the Read will wait for the termination character.
I agree with Albert that the VI you posted should not crash anything. You are not using Run Continuously are you? If you run the program with the balance disconnected, does it crash? Which USB to Serial adapter are you using?
Lynn
02-21-2012 08:12 AM
Thanks for your inquiry. To answer your questions Lynn, I am not running continuously and the adapter that I am using is the following:
http://www.byteccusa.com/product/adapter/BT-DB925/BT-DB925.htm
I will try running the program now without the balance plugged in.
02-21-2012 08:16 AM
As a follow up to the last question, running the program with just the adapter plugged in but not the balance does not result in the BSOD error.