]> sigrok.org Git - libsigrok.git/blame - src/hardware/scpi-pps/profiles.c
Change type of SR_CONF keys to uint32_t.
[libsigrok.git] / src / hardware / scpi-pps / profiles.c
CommitLineData
d4eabea8
BV
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
22c18b03 20#include <string.h>
d4eabea8
BV
21#include "protocol.h"
22
23#define CH_IDX(x) (1 << x)
24
22c18b03
BV
25const char *pps_vendors[][2] = {
26 { "RIGOL TECHNOLOGIES", "Rigol" },
bc4a2a46 27 { "HEWLETT-PACKARD", "HP" },
d4eabea8
BV
28};
29
22c18b03
BV
30const char *get_vendor(const char *raw_vendor)
31{
32 unsigned int i;
33
34 for (i = 0; i < ARRAY_SIZE(pps_vendors); i++) {
35 if (!strcasecmp(raw_vendor, pps_vendors[i][0]))
36 return pps_vendors[i][1];
37 }
38
39 return raw_vendor;
40}
41
584560f1 42static const uint32_t devopts_none[] = { };
bfc86799 43
d4eabea8 44/* Rigol DP800 series */
584560f1 45static const uint32_t rigol_dp800_devopts[] = {
d4eabea8
BV
46 SR_CONF_POWER_SUPPLY,
47 SR_CONF_CONTINUOUS,
48 SR_CONF_OVER_TEMPERATURE_PROTECTION,
49};
50
584560f1 51static const uint32_t rigol_dp800_devopts_cg[] = {
d4eabea8
BV
52 SR_CONF_OUTPUT_REGULATION,
53 SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED,
54 SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE,
55 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD,
56 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED,
57 SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE,
58 SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD,
59 SR_CONF_OUTPUT_VOLTAGE,
60 SR_CONF_OUTPUT_VOLTAGE_MAX,
61 SR_CONF_OUTPUT_CURRENT,
62 SR_CONF_OUTPUT_CURRENT_MAX,
63 SR_CONF_OUTPUT_ENABLED,
64};
65
3222ee10
BV
66struct channel_spec rigol_dp831_ch[] = {
67 { "1", { 0, 8, 0.001 }, { 0, 5, 0.0003 } },
68 { "2", { 0, 30, 0.001 }, { 0, 2, 0.0001 } },
69 { "3", { 0, -30, 0.001 }, { 0, 2, 0.0001 } },
d4eabea8
BV
70};
71
3222ee10
BV
72struct channel_spec rigol_dp832_ch[] = {
73 { "1", { 0, 30, 0.001 }, { 0, 3, 0.001 } },
74 { "2", { 0, 30, 0.001 }, { 0, 3, 0.001 } },
75 { "3", { 0, 5, 0.001 }, { 0, 3, 0.001 } },
76};
77
78struct channel_group_spec rigol_dp800_cg[] = {
d4eabea8
BV
79 { "1", CH_IDX(0), PPS_OVP | PPS_OCP },
80 { "2", CH_IDX(1), PPS_OVP | PPS_OCP },
81 { "3", CH_IDX(2), PPS_OVP | PPS_OCP },
82};
83
3222ee10 84struct scpi_command rigol_dp800_cmd[] = {
d4eabea8
BV
85 { SCPI_CMD_KEY_UNLOCK, "SYST:KLOCK OFF" },
86 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT? CH%s" },
87 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR? CH%s" },
88 { SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWE? CH%s" },
89 { SCPI_CMD_GET_VOLTAGE_MAX, ":SOUR%s:VOLT?" },
90 { SCPI_CMD_SET_VOLTAGE_MAX, ":SOUR%s:VOLT %.6f" },
91 { SCPI_CMD_GET_CURRENT_MAX, ":SOUR%s:CURR?" },
92 { SCPI_CMD_SET_CURRENT_MAX, ":SOUR%s:CURR %.6f" },
93 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP? CH%s" },
94 { SCPI_CMD_SET_OUTPUT_ENABLED, ":OUTP CH%s,%s" },
95 { SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE? CH%s" },
96 { SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP?" },
97 { SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP %s" },
98 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP? CH%s" },
99 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP CH%s,%s" },
100 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES? CH%s" },
101 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL? CH%s" },
102 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL CH%s,%.6f" },
103 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP? CH%s" },
104 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP CH%s,%s" },
105 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES? CH%s" },
106 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL? CH%s" },
107 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL CH%s,%.6f" },
108};
109
bfc86799 110/* HP 663xx series */
584560f1 111static const uint32_t hp_6632b_devopts[] = {
bc4a2a46
BV
112 SR_CONF_POWER_SUPPLY,
113 SR_CONF_CONTINUOUS,
114 SR_CONF_OUTPUT_ENABLED,
115 SR_CONF_OUTPUT_VOLTAGE,
116 SR_CONF_OUTPUT_CURRENT,
117 SR_CONF_OUTPUT_VOLTAGE_MAX,
118 SR_CONF_OUTPUT_CURRENT_MAX,
bc4a2a46
BV
119};
120
121struct channel_spec hp_6632b_ch[] = {
122 { "1", { 0, 20.475, 0.005 }, { 0, 5.1188, 0.00132 } },
123};
124
125struct channel_group_spec hp_6632b_cg[] = {
126 { "1", CH_IDX(0), 0 },
127};
128
129struct scpi_command hp_6632b_cmd[] = {
130 { SCPI_CMD_GET_OUTPUT_ENABLED, "OUTP:STAT?" },
131 { SCPI_CMD_SET_OUTPUT_ENABLED, "OUTP:STAT %s" },
132 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
133 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
134 { SCPI_CMD_GET_VOLTAGE_MAX, ":SOUR:VOLT?" },
135 { SCPI_CMD_SET_VOLTAGE_MAX, ":SOUR:VOLT %.6f" },
136 { SCPI_CMD_GET_CURRENT_MAX, ":SOUR:CURR?" },
137 { SCPI_CMD_SET_CURRENT_MAX, ":SOUR:CURR %.6f" },
138};
139
140
d4eabea8 141SR_PRIV const struct scpi_pps pps_profiles[] = {
bc4a2a46
BV
142 /* HP 6632B */
143 { "HP", "6632B", 0,
144 ARRAY_AND_SIZE(hp_6632b_devopts),
bfc86799 145 ARRAY_AND_SIZE(devopts_none),
bc4a2a46
BV
146 ARRAY_AND_SIZE(hp_6632b_ch),
147 ARRAY_AND_SIZE(hp_6632b_cg),
148 ARRAY_AND_SIZE(hp_6632b_cmd),
149 },
150
d4eabea8 151 /* Rigol DP800 series */
3222ee10
BV
152 { "Rigol", "^DP831A$", PPS_OTP,
153 ARRAY_AND_SIZE(rigol_dp800_devopts),
154 ARRAY_AND_SIZE(rigol_dp800_devopts_cg),
155 ARRAY_AND_SIZE(rigol_dp831_ch),
156 ARRAY_AND_SIZE(rigol_dp800_cg),
157 ARRAY_AND_SIZE(rigol_dp800_cmd),
158 },
159 { "Rigol", "^(DP832|DP832A)$", PPS_OTP,
160 ARRAY_AND_SIZE(rigol_dp800_devopts),
161 ARRAY_AND_SIZE(rigol_dp800_devopts_cg),
162 ARRAY_AND_SIZE(rigol_dp832_ch),
163 ARRAY_AND_SIZE(rigol_dp800_cg),
164 ARRAY_AND_SIZE(rigol_dp800_cmd),
d4eabea8
BV
165 },
166};
167SR_PRIV unsigned int num_pps_profiles = ARRAY_SIZE(pps_profiles);
168