]> sigrok.org Git - libsigrok.git/commitdiff
scpi-pps: Add SR_CONF_REGULATION for HP 66xxB power supplies.
authorFrank Stettner <redacted>
Tue, 9 Apr 2019 13:29:30 +0000 (15:29 +0200)
committerUwe Hermann <redacted>
Wed, 17 Apr 2019 15:11:21 +0000 (17:11 +0200)
include/libsigrok/libsigrok.h
src/hardware/scpi-pps/api.c
src/hardware/scpi-pps/profiles.c

index 508ea3bd0ed7cd75b8e5d3d16f95479fcf8a8cad..bb0b4fe7666d8340b030ad6b8c8cce37b02ab0fa 100644 (file)
@@ -956,6 +956,8 @@ enum sr_configkey {
         * Channel regulation
         * get: "CV", "CC" or "UR", denoting constant voltage, constant current
         *      or unregulated.
+        *      "CC-" denotes a power supply in current sink mode (e.g. HP 66xxB).
+        *      "" is used when there is no regulation, e.g. the output is disabled.
         */
        SR_CONF_REGULATION,
 
index d1dab458bd1b2d5b49e02913852e09485a91eefb..22c79740ed1fada6f042e2b644ebe6b16dd40e86 100644 (file)
@@ -313,6 +313,7 @@ static int config_get(uint32_t key, GVariant **data,
        char *channel_group_name;
        int cmd, ret;
        const char *s;
+       int oper_cond;
 
        if (!sdi)
                return SR_ERR_ARG;
@@ -419,24 +420,45 @@ static int config_get(uint32_t key, GVariant **data,
                channel_group_cmd, channel_group_name, data, gvtype, cmd);
        g_free(channel_group_name);
 
+       /*
+        * Handle special cases
+        */
+
        if (cmd == SCPI_CMD_GET_OUTPUT_REGULATION) {
-               /*
-                * The Rigol DP800 series return CV/CC/UR, Philips PM2800
-                * return VOLT/CURR. We always return a GVariant string in
-                * the Rigol notation.
-                */
-               s = g_variant_get_string(*data, NULL);
-               if (!strcmp(s, "VOLT")) {
-                       g_variant_unref(*data);
-                       *data = g_variant_new_string("CV");
-               } else if (!strcmp(s, "CURR")) {
+               if (devc->device->dialect == SCPI_DIALECT_PHILIPS) {
+                       /*
+                       * The Philips PM2800 series returns VOLT/CURR. We always return
+                       * a GVariant string in the Rigol notation (CV/CC/UR).
+                       */
+                       s = g_variant_get_string(*data, NULL);
+                       if (!g_strcmp0(s, "VOLT")) {
+                               g_variant_unref(*data);
+                               *data = g_variant_new_string("CV");
+                       } else if (!g_strcmp0(s, "CURR")) {
+                               g_variant_unref(*data);
+                               *data = g_variant_new_string("CC");
+                       }
+               }
+               if (devc->device->dialect == SCPI_DIALECT_HP_66XXB) {
+                       /* Evaluate Operational Status Register from a HP 66xxB. */
+                       s = g_variant_get_string(*data, NULL);
+                       sr_atoi(s, &oper_cond);
                        g_variant_unref(*data);
-                       *data = g_variant_new_string("CC");
+                       if (oper_cond & (1 << 8))
+                               *data = g_variant_new_string("CV");
+                       else if (oper_cond & (1 << 10))
+                               *data = g_variant_new_string("CC");
+                       else if (oper_cond & (1 << 11))
+                               *data = g_variant_new_string("CC-");
+                       else
+                               *data = g_variant_new_string("UR");
                }
 
                s = g_variant_get_string(*data, NULL);
-               if (strcmp(s, "CV") && strcmp(s, "CC") && strcmp(s, "UR")) {
-                       sr_dbg("Unknown response to SCPI_CMD_GET_OUTPUT_REGULATION: %s", s);
+               if (g_strcmp0(s, "CV") && g_strcmp0(s, "CC") &&
+                       g_strcmp0(s, "CC-") && g_strcmp0(s, "UR")) {
+
+                       sr_err("Unknown response to SCPI_CMD_GET_OUTPUT_REGULATION: %s", s);
                        ret = SR_ERR_DATA;
                }
        }
index c9ddd61ecb24448a1ba752543d0ef0b9322965ca..6d52b05bad13c8729f72781232ef846d13da8b28 100644 (file)
@@ -460,6 +460,7 @@ static const uint32_t hp_6630b_devopts_cg[] = {
        SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
        SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
+       SR_CONF_REGULATION | SR_CONF_GET,
 };
 
 static const struct channel_spec hp_6633a_ch[] = {
@@ -520,6 +521,7 @@ static const struct scpi_command hp_6630b_cmd[] = {
        { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":CURR:PROT:STAT 0" },
        { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT?" },
        { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT %.6f" },
+       { SCPI_CMD_GET_OUTPUT_REGULATION, "STAT:OPER:COND?" },
        ALL_ZERO
 };