diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-18 16:33:39 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-18 16:33:39 -0500 |
commit | 23eadbf9246280ce6473a4fe4d3605cd730eb8c8 (patch) | |
tree | 99a742ea61a71eb7e65ad881acfa652b3030d096 /servers/gpib_server_lin/src/scope_functions.cpp | |
parent | 3ce46cc90fa5c488f1c41cd4cace0b2a98f3d143 (diff) | |
download | ulab-23eadbf9246280ce6473a4fe4d3605cd730eb8c8.tar.gz ulab-23eadbf9246280ce6473a4fe4d3605cd730eb8c8.zip |
Add channel controls to scope
Diffstat (limited to 'servers/gpib_server_lin/src/scope_functions.cpp')
-rw-r--r-- | servers/gpib_server_lin/src/scope_functions.cpp | 86 |
1 files changed, 83 insertions, 3 deletions
diff --git a/servers/gpib_server_lin/src/scope_functions.cpp b/servers/gpib_server_lin/src/scope_functions.cpp index ce5adcd..0ba0bc1 100644 --- a/servers/gpib_server_lin/src/scope_functions.cpp +++ b/servers/gpib_server_lin/src/scope_functions.cpp @@ -273,9 +273,9 @@ int scope_set_timebase(float desired_timebase,const char * scopeType, int gpibDe } } -int scope_set_volts_div(int desired_channel, float desired_volts,const char * scopeType, int gpibDevice) { +int scope_set_volts_div(int desired_channel, double desired_volts, const char * scopeType, int gpibDevice) { if ((strcmp("HP54600OS", scopeType) == 0) || (strcmp("TDS744AOS", scopeType) == 0)) { - printf("[INFO] Setting scope volts/div on channel %d to %f\n\r", desired_channel, desired_volts/8); + printf("[INFO] Setting scope volts/div on channel %d to %E\n\r", desired_channel, desired_volts); if (strcmp("HP54600OS", scopeType) == 0) { sprintf(falpha, "CHAN%d:RANG %E", desired_channel, desired_volts); #ifdef ENABLE_EXTRA_DEBUGGING @@ -289,7 +289,7 @@ int scope_set_volts_div(int desired_channel, float desired_volts,const char * sc } } else if (strcmp("TDS744AOS", scopeType) == 0) { - sprintf(falpha, "CH%d:SCALE %f", desired_channel, desired_volts/8); + sprintf(falpha, "CH%d:SCALE %E", desired_channel, desired_volts); #ifdef ENABLE_EXTRA_DEBUGGING printf("[DEBG] Writing: %s\n\r", falpha); #endif @@ -387,6 +387,7 @@ int scope_set_channel_state(int desired_channel, int status,const char * scopeTy printf("[DEBG] Writing: %s\n\r", falpha); #endif if (gpib_write(gpibDevice, falpha) == 0) { + usleep(2*1000000); // The scope is slow to respond, and also blind to commands during the update window! [RAJA TESTME] return 0; } else { @@ -1118,4 +1119,83 @@ int scope_get_channel_sample_count(unsigned long * retval, int desired_channel, else { return -1; } +} + +int scope_get_probe_attenuation_multiplier(double * retval, int desired_channel, const char * scopeType, int gpibDevice) { + char floatstring[1024]; + long ai; + int max_num_bytes = 0; + + if (strcmp("HP54600OS", scopeType) == 0) { + // FIXME + // Not supported (yet) + return -1; + } + else if (strcmp("TDS744AOS", scopeType) == 0) { + // Send request + printf("[INFO] Getting trigger level for channel %d\n\r", desired_channel); + sprintf(falpha,"CH%d:PROBE?", desired_channel); + #ifdef ENABLE_EXTRA_DEBUGGING + printf("[DEBG] Writing: %s\n\r", falpha); + #endif + if (gpib_write(gpibDevice, falpha) == 0) { + max_num_bytes = 24; // Request more bytes than are possible to ensure no bytes are left behind + } + else { + return 2; + } + + // Read response + #ifdef ENABLE_EXTRA_DEBUGGING + printf("[DEBG] Trying to read %i bytes from GPIB device...\n", max_num_bytes); + #endif + + ai = gpib_read_array(gpibDevice, max_num_bytes, floatstring); + if (ai == -1) { + return 1; + } + else { + floatstring[ai]=0; + *retval = atof(floatstring); + } + + #ifdef ENABLE_EXTRA_DEBUGGING + printf("[DEBG] Read %li bytes from GPIB device\n", ai); + #endif + + return 0; + } + else { + return -1; + } +} + +int scope_get_permitted_volts_div_settings_at_1x(int * number_of_values, double ** retarray, const char * scopeType, int gpibDevice) { + if (strcmp("HP54600OS", scopeType) == 0) { + // FIXME + // Not supported (yet) + return -1; + } + else if (strcmp("TDS744AOS", scopeType) == 0) { + *number_of_values = 13; + double* values = (double*)malloc(sizeof(double)*(*number_of_values)); + values[0] = 1e-3; + values[1] = 2e-3; + values[2] = 5e-3; + values[3] = 1e-2; + values[4] = 2e-2; + values[5] = 5e-2; + values[6] = 1e-1; + values[7] = 2e-1; + values[8] = 5e-1; + values[9] = 1e0; + values[10] = 2e0; + values[11] = 5e0; + values[12] = 1e1; + *retarray = values; + return 0; + } + else { + return -1; + } }
\ No newline at end of file |