06-16-2009 08:01 AM
Hey Folks, I'm using labwindows/CVI to communicate with Keithley 2400 Voltage Current Source meter, to make digital curve traces. I am using RS-232. I can successfully initiate a serial COM and send the data set to the Keithley, I can also successfully read back the results but here is the catch, I can only read back up to 2000 data points, once it hits 2000 results it freezes up. I'm not sure if this is an issue with Labwindows or RS-232 Communication or the Keithley 2400, I looked through the entire 2400 manual but see nothing about a limitation on data points.
The serial setting I'm using are: 9600 baud/ odd parity / 8 data bits / 1 stop bit / cts off / xon-xoff enabled / 5sec timeout / 512 input queue / 512 output queue.
Below is a snippet of code I use to read the data back, I am sure there are more specifics that you all might need so I will be happy to give more details.
Thanks for your time and any help!
for(i=0;i<=num;i++){
read_data[0] = '\0';
buf[0] = '\0';
bytes_read = ComRdTerm (comport, read_data, 70, 13);
p = strtok (read_data," ,");
if(p != NULL){
n=sprintf(buf,"%s",p);
results[i].param1 = atof(buf);
p = strtok (NULL, " ,");
buf[0]='\0';
n=sprintf(buf,"%s",p);
results[i].param2 = atof(buf);
}
}
06-18-2009 01:45 PM
Hi dsappet,
When you say that it freezes up, do you mean that the Keithley device freezes up or your computer freezes up? Or is just the exe you created in CVI freezing up?
If it's the Keithley freezing up, how big are the data sets that you're sending data sets to the Keithley? Are there limitations on how big the data sets can be that you're sending to it?
06-18-2009 01:56 PM
06-19-2009 09:39 AM
Hi Douglas,
I suspect that the lock-up is not related to rs-232 calls.
If it is, it may be related to xon-xoff.
I have no experience with it, but I did not understand what you need it for?
Are you sure your reader loop does not fail to exit?
Maybe you end up with an infinite loop that freezes the GUI.
Can you debug your code and identify which function failse to return, so that the code freezes?
You can put a conditional breakpoint, so that you do not have to press F10 many thousand times.
Hope this helps,
06-19-2009 10:05 AM
thanks for your continued help on this, so it is definatly not stuck in the loop i will make steps so that num is 3000 or something it gets stuck on the bytes_read = ComRdTerm (comport, read_data, 70, 13); at i=2000 i have tried with the xon-off thing enabled and disabled. As far as I know it adds something to know when the buffer is full so it won't loose data, i thought maybe that was happening so I enabled it but to no benifit. So it seems to be failing the ComRdTerm function as if there is a problem talking with the com port. IF there was no data from the device it should just return null and I have conditions for that but its as if the com port became disabled or something.
Thanks again
06-19-2009 10:07 AM
It stops when it gets to exactly 2000? Every time? That seems to be a suspiciously human-related number. How many elements have you specified for your array of results structures?
JR
06-19-2009 10:10 AM
06-19-2009 10:26 AM
Are you using a USB-Serial converter? A few years ago we had a similar issue, where a serial input stream into a laptop USB via a converter would suddenly stop for no apparant reason, after several thousand bytes were read by a CVI program. The convertor had been borrowed, and when we replaced it with our own (a different make, with different drivers) we had no more problems.
About how many bytes would you say corresponds to your 2000 lines? Anywhere near 32767?
JR
06-19-2009 10:30 AM
Hi again, I am not using a usb-serial converter it is a motherboard serial port on a dell pc. I am not sure how many bytes this cooresponds too I will have to do a little digging to figure it out. I think it is two doubles per data point but I will have to double check if they are doubles (no pun intended) lol
Thanks,
06-19-2009 10:32 AM
There is no condition that would normally make ComRdTerm wait forever.
If it is waiting for the bytes to arrive (when they are not) then it should timeout and return.
Can you make the for loop like this and try again:
for (i=0; i<num; i++) instead of for (i=0; i<=num; i++)