07-10-2009 05:00 PM - edited 07-10-2009 05:05 PM
I have a very simple perl script to do I-V sweeps with a Keithley 2400 SourceMeter. Despite the script itself being a bit of a kludgy approach, it has worked fine in the past, no problems.
I moved to another computer in a different lab that does not have a serial port. I bought a USB-to-Serial adapter. The adapter works. The script does not work on that computer because the Keithley beeps and displays error 110 "Command header error" on the <:meas?> command in the script. In testing, it also returns 113 "Undefined header" when I send <*idn?>. All the other commands in the script can be run fine. I can turn the output on and off with the usb-to-serial adapter and run every other command in the script with no problems. Only the <:meas?> command fails. The script still works on the old computer with the 'real' serial port, with the same SourceMeter. The only changes to the script between the two computers is the serial port address.
The way I see it, it could be some kind of strange character encoding issue between the two systems, or it could be that the USB-to-Serial adapter is causing the problem on commands that contain the <?> character. I'm at my wits end.
#!/usr/bin/perl
`rm outp.txt`;
`echo "*rst" >> /dev/ttyS0`;
`echo ":sens:func 'curr'" >> /dev/ttyS0`; #all these commands work fine
`echo ":sour:func volt" >> /dev/ttyS0`;
`echo ":sens:curr:prot 1" >> /dev/ttyS0`;
`echo ":trig:coun 1" >> /dev/ttyS0`;
`echo ":form:elem curr" >> /dev/ttyS0`;
for($volts = -1; $volts <= 1; $volts = $volts+.02)
{
`echo ":sour:volt $volts" >> /dev/ttyS0`;
`echo -n "$volts," >> outp.txt`;
`echo ":meas?" >>/dev/ttyS0`; #this is the command that causes the error 110, but only on one computer`cat /dev/ttyS0 >> outp.txt&`;
$oldtime = time + 2;
while($oldtime > time)
{
print("kill!!!!\n");
}
`pkill cat`; #don't laugh, it works
}
`echo "output off" >> /dev/ttyS0`;
print("test finished\n");
07-11-2009 04:03 PM