]> sigrok.org Git - libsigrok.git/commitdiff
scpi-pps: Add infrastructure for controlling output frequency
authorAlexandru Gagniuc <redacted>
Thu, 30 Apr 2015 00:26:47 +0000 (17:26 -0700)
committerUwe Hermann <redacted>
Wed, 6 May 2015 17:41:46 +0000 (19:41 +0200)
This patch only adds the needed infrastructure to control output
frequency in the same manner as output voltage or current limit. This
does require a new field in the channel_spec struct, for the sake of
symmetry.

src/hardware/scpi-pps/api.c
src/hardware/scpi-pps/profiles.c
src/hardware/scpi-pps/protocol.c
src/hardware/scpi-pps/protocol.h

index e68836b7acf34438e1a26e3e8e6a8dcbda3c5a34..c1b4aca44efaf977d929635a3fb77dd1cc306a78 100644 (file)
@@ -38,6 +38,7 @@ static const struct pps_channel_instance pci[] = {
        { SR_MQ_VOLTAGE, SCPI_CMD_GET_MEAS_VOLTAGE, "V" },
        { SR_MQ_CURRENT, SCPI_CMD_GET_MEAS_CURRENT, "I" },
        { SR_MQ_POWER, SCPI_CMD_GET_MEAS_POWER, "P" },
+       { SR_MQ_FREQUENCY, SCPI_CMD_GET_MEAS_FREQUENCY, "F" },
 };
 
 static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
@@ -300,6 +301,14 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
                gvtype = G_VARIANT_TYPE_DOUBLE;
                cmd = SCPI_CMD_GET_VOLTAGE_TARGET;
                break;
+       case SR_CONF_OUTPUT_FREQUENCY:
+               gvtype = G_VARIANT_TYPE_DOUBLE;
+               cmd = SCPI_CMD_GET_MEAS_FREQUENCY;
+               break;
+       case SR_CONF_OUTPUT_FREQUENCY_TARGET:
+               gvtype = G_VARIANT_TYPE_DOUBLE;
+               cmd = SCPI_CMD_GET_FREQUENCY_TARGET;
+               break;
        case SR_CONF_OUTPUT_CURRENT:
                gvtype = G_VARIANT_TYPE_DOUBLE;
                cmd = SCPI_CMD_GET_MEAS_CURRENT;
@@ -378,6 +387,10 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                d = g_variant_get_double(data);
                ret = scpi_cmd(sdi, SCPI_CMD_SET_VOLTAGE_TARGET, d);
                break;
+       case SR_CONF_OUTPUT_FREQUENCY_TARGET:
+               d = g_variant_get_double(data);
+               ret = scpi_cmd(sdi, SCPI_CMD_SET_FREQUENCY_TARGET, d);
+               break;
        case SR_CONF_OUTPUT_CURRENT_LIMIT:
                d = g_variant_get_double(data);
                ret = scpi_cmd(sdi, SCPI_CMD_SET_CURRENT_LIMIT, d);
@@ -497,6 +510,16 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        }
                        *data = g_variant_builder_end(&gvb);
                        break;
+               case SR_CONF_OUTPUT_FREQUENCY_TARGET:
+                       ch_spec = &(devc->device->channels[ch->index]);
+                       g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
+                       /* Min, max, write resolution. */
+                       for (i = 0; i < 3; i++) {
+                               gvar = g_variant_new_double(ch_spec->frequency[i]);
+                               g_variant_builder_add_value(&gvb, gvar);
+                       }
+                       *data = g_variant_builder_end(&gvb);
+                       break;
                case SR_CONF_OUTPUT_CURRENT_LIMIT:
                        g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
                        /* Min, max, step. */
@@ -543,6 +566,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
                return ret;
        if (pch->mq == SR_MQ_VOLTAGE)
                cmd = SCPI_CMD_GET_MEAS_VOLTAGE;
+       else if (pch->mq == SR_MQ_FREQUENCY)
+               cmd = SCPI_CMD_GET_MEAS_FREQUENCY;
        else if (pch->mq == SR_MQ_CURRENT)
                cmd = SCPI_CMD_GET_MEAS_CURRENT;
        else if (pch->mq == SR_MQ_POWER)
index 489f5bdb42e2b30c8af1490fb55189013c3fa60c..7d1da16e76ef01ebf8a0c795a15690ebcc1b6409 100644 (file)
@@ -24,6 +24,7 @@
 #include "protocol.h"
 
 #define CH_IDX(x) (1 << x)
+#define FREQ_DC_ONLY {0, 0, 0}
 
 const char *pps_vendors[][2] = {
        { "RIGOL TECHNOLOGIES", "Rigol" },
@@ -61,7 +62,7 @@ static const uint32_t chroma_61604_devopts_cg[] = {
 };
 
 const struct channel_spec chroma_61604_ch[] = {
-       { "1", { 0, 300, 0.1 }, { 0, 16, 0.1 } },
+       { "1", { 0, 300, 0.1 }, { 0, 16, 0.1 }, FREQ_DC_ONLY },
 };
 
 const struct channel_group_spec chroma_61604_cg[] = {
@@ -108,20 +109,20 @@ static const uint32_t rigol_dp800_devopts_cg[] = {
 };
 
 const struct channel_spec rigol_dp821a_ch[] = {
-       { "1", { 0, 60, 0.001 }, { 0, 1, 0.0001 } },
-       { "2", { 0, 8, 0.001 }, { 0, 10, 0.001 } },
+       { "1", { 0, 60, 0.001 }, { 0, 1, 0.0001 }, FREQ_DC_ONLY },
+       { "2", { 0, 8, 0.001 }, { 0, 10, 0.001 }, FREQ_DC_ONLY },
 };
 
 const struct channel_spec rigol_dp831_ch[] = {
-       { "1", { 0, 8, 0.001 }, { 0, 5, 0.0003 } },
-       { "2", { 0, 30, 0.001 }, { 0, 2, 0.0001 } },
-       { "3", { 0, -30, 0.001 }, { 0, 2, 0.0001 } },
+       { "1", { 0, 8, 0.001 }, { 0, 5, 0.0003 }, FREQ_DC_ONLY },
+       { "2", { 0, 30, 0.001 }, { 0, 2, 0.0001 }, FREQ_DC_ONLY },
+       { "3", { 0, -30, 0.001 }, { 0, 2, 0.0001 }, FREQ_DC_ONLY },
 };
 
 const struct channel_spec rigol_dp832_ch[] = {
-       { "1", { 0, 30, 0.001 }, { 0, 3, 0.001 } },
-       { "2", { 0, 30, 0.001 }, { 0, 3, 0.001 } },
-       { "3", { 0, 5, 0.001 }, { 0, 3, 0.001 } },
+       { "1", { 0, 30, 0.001 }, { 0, 3, 0.001 }, FREQ_DC_ONLY },
+       { "2", { 0, 30, 0.001 }, { 0, 3, 0.001 }, FREQ_DC_ONLY },
+       { "3", { 0, 5, 0.001 }, { 0, 3, 0.001 }, FREQ_DC_ONLY },
 };
 
 const struct channel_group_spec rigol_dp820_cg[] = {
@@ -181,7 +182,7 @@ static const uint32_t hp_6632b_devopts[] = {
 };
 
 const struct channel_spec hp_6632b_ch[] = {
-       { "1", { 0, 20.475, 0.005 }, { 0, 5.1188, 0.00132 } },
+       { "1", { 0, 20.475, 0.005 }, { 0, 5.1188, 0.00132 }, FREQ_DC_ONLY },
 };
 
 const struct channel_group_spec hp_6632b_cg[] = {
index df7d478d75e3412d0aa36491a4849b108004152a..26ff82163a744aa205a6573005971dee8bd10583 100644 (file)
@@ -227,6 +227,8 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
        pch = devc->cur_channel->priv;
        if (pch->mq == SR_MQ_VOLTAGE)
                cmd = SCPI_CMD_GET_MEAS_VOLTAGE;
+       else if (pch->mq == SR_MQ_FREQUENCY)
+               cmd = SCPI_CMD_GET_MEAS_FREQUENCY;
        else if (pch->mq == SR_MQ_CURRENT)
                cmd = SCPI_CMD_GET_MEAS_CURRENT;
        else if (pch->mq == SR_MQ_POWER)
index bd0dc9332c8169f7e0ac550eea3ef60db4bdedad..e1ed8cb8d7d9230e20f82b72e0e9146008390ce0 100644 (file)
@@ -37,8 +37,11 @@ enum pps_scpi_cmds {
        SCPI_CMD_GET_MEAS_VOLTAGE,
        SCPI_CMD_GET_MEAS_CURRENT,
        SCPI_CMD_GET_MEAS_POWER,
+       SCPI_CMD_GET_MEAS_FREQUENCY,
        SCPI_CMD_GET_VOLTAGE_TARGET,
        SCPI_CMD_SET_VOLTAGE_TARGET,
+       SCPI_CMD_GET_FREQUENCY_TARGET,
+       SCPI_CMD_SET_FREQUENCY_TARGET,
        SCPI_CMD_GET_CURRENT_LIMIT,
        SCPI_CMD_SET_CURRENT_LIMIT,
        SCPI_CMD_GET_OUTPUT_ENABLED,
@@ -100,6 +103,7 @@ struct channel_spec {
        /* Min, max, programming resolution. */
        float voltage[3];
        float current[3];
+       float frequency[3];
 };
 
 struct scpi_command {