[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
testing octave-instrument-control-toolbox
From: |
Jean Dubois |
Subject: |
testing octave-instrument-control-toolbox |
Date: |
Tue, 11 Dec 2012 22:06:14 +0100 |
I'm still struggling with the usbtmc-communication with our Keithley.
I now can make succesfully a series of measurements like in the
following script:
clear
file_id = fopen('mydata.txt', 'w');
readbytes = 10000;
timesleepdefault=1
fd = usbtmc_open("/dev/usbtmc1");
usbtmc_write(fd,"*IDN?");
result = char(usbtmc_read(fd,readbytes))
usbtmc_write(fd,"SYST:REM");
usbtmc_write(fd,"SENS:VOLT:PROT 1.5");
#start 1st measurement
usbtmc_write(fd,"SOUR:CURR 0.025");
usbtmc_write(fd,"OUTP:STAT ON");
pause (timesleepdefault)
usbtmc_write(fd,"MEAS:CURR?");
resultcurr = char(usbtmc_read(fd,readbytes))
#strip line termination
resultcurr = resultcurr(1:end-1);
usbtmc_write(fd,"MEAS:VOLT?");
resultvolt = char(usbtmc_read(fd,readbytes))
fprintf(file_id,'%s',resultcurr,' ',resultvolt)
#start 2nd measurement
usbtmc_write(fd,"SOUR:CURR 0.050");
pause (timesleepdefault)
usbtmc_write(fd,"MEAS:CURR?");
resultcurr = char(usbtmc_read(fd,readbytes))
#strip line termination
resultcurr = resultcurr(1:end-1);
usbtmc_write(fd,"MEAS:VOLT?");
resultvolt = char(usbtmc_read(fd,readbytes))
fprintf(file_id,'%s',resultcurr,' ',resultvolt)
#start 3rd measurement
usbtmc_write(fd,"SOUR:CURR 0.075");
pause (timesleepdefault)
usbtmc_write(fd,"MEAS:CURR?");
resultcurr = char(usbtmc_read(fd,readbytes))
#strip line termination
resultcurr = resultcurr(1:end-1);
usbtmc_write(fd,"MEAS:VOLT?");
resultvolt = char(usbtmc_read(fd,readbytes))
fprintf(file_id, '%s',resultcurr,' ',resultvolt)
#start 4th measurement
usbtmc_write(fd,"SOUR:CURR 0.1");
pause (timesleepdefault)
usbtmc_write(fd,"MEAS:CURR?");
resultcurr = char(usbtmc_read(fd,readbytes))
#strip line termination
resultcurr = resultcurr(1:end-1);
usbtmc_write(fd,"MEAS:VOLT?");
resultvolt = char(usbtmc_read(fd,readbytes))
fprintf(file_id,'%s',resultcurr,' ', resultvolt)
usbtmc_close(fd);
fclose(file_id)
The trouble begins when trying to do more advanced stuff like sending
the commands for a linear staircase current as shown in the script
below. I don't know what exactly I will get back (how many characters,
format...). In fact I just would like to dump everything which is sent
back in a binary format which I then could inspect closer to see
what's in it an how to get usefull data out of it. When I run the
script as it is now I get the following response after which I have to
reset the Keithley sometimes even resulting in a kernel crash...
ans = 14
ans = 19
ans = 18
ans = 20
ans = 19
ans = 19
ans = 18
ans = 18
ans = 17
ans = 15
ans = 11
ans = 12
ans = 7
warning: range error for conversion to character value
resultcurr =
ans = 0
Here is the script for the staircase-current:
clear
file_id = fopen('mydata.txt', 'w');
readbytes = 4095;
timesleepdefault=10;
fd = usbtmc_open("/dev/usbtmc1");
usbtmc_write(fd,"*IDN?");
result = char(usbtmc_read(fd,readbytes))
usbtmc_write(fd,"SYST:REM");
usbtmc_write(fd,"SOUR:FUNC CURR")
usbtmc_write(fd,"SENS:FUNC 'VOLT:DC'")
usbtmc_write(fd,"SENS:VOLT:PROT 1.5")
usbtmc_write(fd,"SOUR:CURR:START 0.01")
usbtmc_write(fd,"SOUR:CURR:STOP 0.05")
usbtmc_write(fd,"SOUR:CURR:STEP 0.01")
usbtmc_write(fd,"SOUR:CURR:MODE SWE")
usbtmc_write(fd,"SOUR:SWE:RANG AUTO")
usbtmc_write(fd,"SOUR:SWE:SPAC LIN")
usbtmc_write(fd,"SOUR:SWE:DIR UP")
usbtmc_write(fd,"TRIG:COUN 5")
usbtmc_write(fd,"SOUR:DEL 0.1")
usbtmc_write(fd,"OUTP ON")
pause (timesleepdefault)
resultcurr = char(usbtmc_read(fd,readbytes))
fprintf(file_id,resultcurr)
Can someone do some suggestions on how to solve this?
thanks
hugo
- testing octave-instrument-control-toolbox,
Jean Dubois <=