01-20-2007 10:01 AM
01-22-2007 07:06 PM
01-23-2007 08:13 AM
01-23-2007 10:30 AM
Two thoughts and maybe you've already been there and done that.
1 - Look at your COM port settings under the Windows Device Manager and compare the settings between the two PC's. If the settings are different, try the two sets of settings on both PC's. Even if it doesn't fix the problem, it will eliminate a potential cause.
2 - Does it make a difference if the instrument is already up and running when you fire up the PC vs. firing up the PC first and then starting the instrument?
01-26-2007 07:46 AM
01-26-2007 08:35 AM
My mistake on point 1. Be sure and double check that all the COM port settings are identical between the cRIO and the PC. I'd consider running it on a 2nd pc and see what happened.
Point 2 was never intended to be a workaround. Running this test may help you isolate the problem and create the fix.
01-26-2007 09:34 AM
The vi you posted has a race condition in it. You are checking "bytes at port" then you do a VISA read. If data shows up after "bytes at port" and before the VISA Read, the VISA Read will empty the buffer. The timing of the "bytes at port" and the VISA read will vary platform to platform. Try modifying your vi so that the VISA Read is only done if there are more that 0 bytes to be read.
Also, you are running your loop at the exact rate at which packets of data are arriving. That means that the timing of when the vi starts running vs the incoming packets is very critical. You need to add some sort of syncronization step to the vi. You might be able to look for the dead time between packets.
01-27-2007 03:05 PM
Thanks again for your persistence. You suggested reversing the order as a troubleshooting method: fire up the vi first, then turn the instrument on. When I did this, my vi in cRIO recognized the start serial stream ten out of ten times. I'm trying to figure out how to interpret that, though...
Are you sure that my vi has a race condition? My VISA read is told to only read the number of bytes that "bytes at port" says are there. When "bytes at port" says zero, VISA read is told to read zero bytes -- so it shouldn't empty the buffer. To check this, I did two things. (1) I put an indicator on "return count" so the VISA read would tell how many bytes it actually read. I never saw it read any bytes when "bytes at port" was zero. In fact, "bytes at port" always matched "return count". (2) As you suggested, I put the VISA read inside a case structure and only read it when "bytes at port" was nonzero. The problem persisted.
I have double checked all port settings. I have tried changing the read loop rate to one 2-5x faster than the rate of the incoming data packets. That lowers the problem frequency from 50% to 20% or so. (Meaning, only two of ten times I try to start the vi does cRIO say it doesn't see any bytes at the serial port, when indeed there are plenty there.)
You're right that I ultimately need to add a synchronization step to the vi. Once I fix the problem of being able to read the data in the first place, I'll hopefully be able to find the dead time between packets.
I'm eager to try any other suggestions you might have.
01-29-2007 07:17 AM
David,
I suspect that reversing the power up order works everytime because this order ensures that the cRIO is up and running with the COM port properly initialized before the serial data starts coming from the instrument. This might also explain why your PC always works. I'm unsure as to how the cRIO COM port reacts if it is receiving data before it is configured properly. It may be that it is hanging up and needs some sort of reset.
I did a test here with another instrument and you are right about the bytes at port. That seems to further point to the port hanging up. I think that I would still alter the vi to not do the VISA read unless there are more than 0 bytes to be read. Especially with how fast you are trying to do all this.
If the port is really hanging up, you need to try and find a way to get it to recover. It may just need time. The vi you posted does not alter the VISA timeout. 10 seconds is the default. Try making it something very short like 1mSec. Try putting a delay between the VISA configure port and the rest of the vi. Alter your vi to give it more attempts to receive data. You may need to talk to someone at NI who knows the cRIO hardware inside out.