Browse Source

this drives the keithley correctly

git-svn-id: https://bucket.mit.edu/svn/nilm/zoom@7603 ddd99763-3ecb-0310-9145-efcb8ce7c51f
tags/zoom-1.0
jim 13 years ago
parent
commit
b9e312caf5
1 changed files with 11 additions and 10 deletions
  1. +11
    -10
      pc/calibrate.c

+ 11
- 10
pc/calibrate.c View File

@@ -77,8 +77,8 @@ int serial_open(const char *device, int rate)

int main(int argc, char *argv[])
{
char *zoomdev=strdup("/dev/ttyUSB0");
char *gpibdev=strdup("/dev/ttyUSB1");
char *zoomdev=strdup("/dev/ttyUSB1");
char *gpibdev=strdup("/dev/ttyUSB0");
int getopt_index;
int i;
char buf[1024];
@@ -116,17 +116,17 @@ int main(int argc, char *argv[])
fprintf(stderr, "Zoom Nilm Calibration Tool\n");
fprintf(stderr, "usage: %s [options]\n\n", *argv);
fprintf(stderr, " -z, --zoom-device %-14s zoom NILM serial port\n", zoomdev);
fprintf(stderr, " -z, --gpib-device %-14s GPIB serial port\n", gpibdev);
fprintf(stderr, " -g, --gpib-device %-14s GPIB serial port\n", gpibdev);
fprintf(stderr, " -h, --help this help\n");
return 1;
}

if ((zoom = serial_open(zoomdev, 115200)) == -1)
errx(1, "zoom open failed");
if ((gpib = serial_open(zoomdev, 9600)) == -1)
if ((gpib = serial_open(gpibdev, 9600)) == -1)
errx(1, "gpib open failed");

signal(SIGTERM, handle_sig);
signal(SIGINT, handle_sig);
calibrate();

close(zoom);
@@ -136,6 +136,7 @@ int main(int argc, char *argv[])

void gputs(char *s)
{
info("%s\n", s);
if (write(gpib, s, strlen(s)) != strlen(s) ||
write(gpib, "\r", 1) != 1)
err(1, "error writing GPIB string '%s'", s);
@@ -143,7 +144,6 @@ void gputs(char *s)

void keithley_on(void)
{
gputs("++mode 1");
gputs("++mode 1");
gputs("++auto 0");
gputs("++eos 1");
@@ -156,6 +156,7 @@ void keithley_on(void)
gputs(":sour:func:mode curr");
gputs(":sour:del 0");
gputs(":sour:curr 0");
gputs(":sour:curr:range:auto on");
gputs(":outp on");
}

@@ -186,13 +187,13 @@ void calibrate(void)
{
int ma;

info("Initializing Keithley");
info("Initializing Keithley\n");
keithley_on();

info("Sweep");
info("Sweep\n");
for (ma = -1000; ma <= 1000; ma += 10) {
keithley_current(ma / 1000.0);
sleep(1);
keithley_current(ma);
usleep(100000);
if (quit) break;
}



Loading…
Cancel
Save