2 * This file is part of the libsigrok project.
4 * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
5 * Copyright (C) 2015 Google, Inc.
6 * (Written by Alexandru Gagniuc <mrnuke@google.com> for Google, Inc.)
7 * Copyright (C) 2017,2019 Frank Stettner <frank-stettner@gmx.net>
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #define CH_IDX(x) (1 << x)
29 #define FREQ_DC_ONLY {0, 0, 0, 0, 0}
30 #define NO_OVP_LIMITS {0, 0, 0, 0, 0}
31 #define NO_OCP_LIMITS {0, 0, 0, 0, 0}
33 /* Agilent/Keysight N5700A series */
34 static const uint32_t agilent_n5700a_devopts[] = {
36 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
37 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
40 static const uint32_t agilent_n5700a_devopts_cg[] = {
41 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
42 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
43 SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
44 SR_CONF_VOLTAGE | SR_CONF_GET,
45 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
46 SR_CONF_CURRENT | SR_CONF_GET,
47 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
50 static const struct channel_group_spec agilent_n5700a_cg[] = {
51 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
54 static const struct channel_spec agilent_n5767a_ch[] = {
55 { "1", { 0, 60, 0.0072, 3, 4 }, { 0, 25, 0.003, 3, 4 }, { 0, 1500 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
58 static const struct channel_spec agilent_n5763a_ch[] = {
59 { "1", { 0, 12.5, 0.0015, 3, 4 }, { 0, 120, 0.0144, 3, 4 }, { 0, 1500 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
63 * TODO: OVER_CURRENT_PROTECTION_ACTIVE status can be determined by the OC bit
64 * in STAT:QUES:EVEN?, but this is not implemented.
66 static const struct scpi_command agilent_n5700a_cmd[] = {
67 { SCPI_CMD_REMOTE, "SYST:COMM:RLST REM" },
68 { SCPI_CMD_LOCAL, "SYST:COMM:RLST LOC" },
69 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
70 { SCPI_CMD_GET_MEAS_CURRENT, "MEAS:CURR?" },
71 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
72 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
73 { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
74 { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
75 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP:STAT?" },
76 { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" },
77 { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" },
78 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT?" },
79 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT %.6f" },
80 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":CURR:PROT:STAT?" },
81 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":CURR:PROT:STAT ON?"},
82 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":CURR:PROT:STAT OFF?"},
83 /* Current limit (CC mode) and OCP are set using the same command. */
84 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":SOUR:CURR?" },
85 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":SOUR:CURR %.6f" },
89 /* BK Precision 9130 series */
90 static const uint32_t bk_9130_devopts[] = {
92 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
93 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
96 static const uint32_t bk_9130_devopts_cg[] = {
97 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
98 SR_CONF_VOLTAGE | SR_CONF_GET,
99 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
100 SR_CONF_CURRENT | SR_CONF_GET,
101 SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
102 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
105 static const struct channel_spec bk_9130_ch[] = {
106 { "1", { 0, 30, 0.001, 3, 3 }, { 0, 3, 0.001, 3, 3 }, { 0, 90, 0, 3, 3 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
107 { "2", { 0, 30, 0.001, 3, 3 }, { 0, 3, 0.001, 3, 3 }, { 0, 90, 0, 3, 3 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
108 { "3", { 0, 5, 0.001, 3, 3 }, { 0, 3, 0.001, 3, 3 }, { 0, 15, 0, 3, 3 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
111 static const struct channel_group_spec bk_9130_cg[] = {
112 { "1", CH_IDX(0), PPS_OVP, SR_MQFLAG_DC },
113 { "2", CH_IDX(1), PPS_OVP, SR_MQFLAG_DC },
114 { "3", CH_IDX(2), PPS_OVP, SR_MQFLAG_DC },
117 static const struct scpi_command bk_9130_cmd[] = {
118 { SCPI_CMD_REMOTE, "SYST:REMOTE" },
119 { SCPI_CMD_LOCAL, "SYST:LOCAL" },
120 { SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" },
121 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
122 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
123 { SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWER?" },
124 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
125 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
126 { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
127 { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
128 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" },
129 { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP 1" },
130 { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP 0" },
131 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT?" },
132 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT %.6f" },
136 /* Chroma 61600 series AC source */
137 static const uint32_t chroma_61604_devopts[] = {
139 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
140 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
143 static const uint32_t chroma_61604_devopts_cg[] = {
144 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
145 SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
146 SR_CONF_VOLTAGE | SR_CONF_GET,
147 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
148 SR_CONF_OUTPUT_FREQUENCY | SR_CONF_GET,
149 SR_CONF_OUTPUT_FREQUENCY_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
150 SR_CONF_CURRENT | SR_CONF_GET,
151 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
154 static const struct channel_spec chroma_61604_ch[] = {
155 { "1", { 0, 300, 0.1, 1, 1 }, { 0, 16, 0.1, 2, 2 }, { 0, 2000, 0, 1, 1 }, { 1.0, 1000.0, 0.01 }, NO_OVP_LIMITS, NO_OCP_LIMITS },
158 static const struct channel_group_spec chroma_61604_cg[] = {
159 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_AC },
162 static const struct scpi_command chroma_61604_cmd[] = {
163 { SCPI_CMD_REMOTE, "SYST:REM" },
164 { SCPI_CMD_LOCAL, "SYST:LOC" },
165 { SCPI_CMD_GET_MEAS_VOLTAGE, ":FETC:VOLT:ACDC?" },
166 { SCPI_CMD_GET_MEAS_FREQUENCY, ":FETC:FREQ?" },
167 { SCPI_CMD_GET_MEAS_CURRENT, ":FETC:CURR:AC?" },
168 { SCPI_CMD_GET_MEAS_POWER, ":FETC:POW:AC?" },
169 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT:AC?" },
170 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT:AC %.1f" },
171 { SCPI_CMD_GET_FREQUENCY_TARGET, ":SOUR:FREQ?" },
172 { SCPI_CMD_SET_FREQUENCY_TARGET, ":SOUR:FREQ %.2f" },
173 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" },
174 { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" },
175 { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" },
176 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:LIM:AC?" },
177 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:LIM:AC %.1f" },
178 /* This is not a current limit mode. It is overcurrent protection. */
179 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":SOUR:CURR:LIM?" },
180 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":SOUR:CURR:LIM %.2f" },
184 /* Chroma 62000 series DC source */
185 static const uint32_t chroma_62000_devopts[] = {
187 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
188 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
191 static const uint32_t chroma_62000_devopts_cg[] = {
192 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
193 SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
194 SR_CONF_VOLTAGE | SR_CONF_GET,
195 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
196 SR_CONF_CURRENT | SR_CONF_GET,
197 SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
198 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
201 static const struct channel_group_spec chroma_62000_cg[] = {
202 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
205 static const struct scpi_command chroma_62000_cmd[] = {
206 { SCPI_CMD_REMOTE, ":CONF:REM ON" },
207 { SCPI_CMD_LOCAL, ":CONF:REM OFF" },
208 { SCPI_CMD_BEEPER, ":CONF:BEEP?" },
209 { SCPI_CMD_BEEPER_ENABLE, ":CONF:BEEP ON" },
210 { SCPI_CMD_BEEPER_DISABLE, ":CONF:BEEP OFF" },
211 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
212 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
213 { SCPI_CMD_GET_MEAS_POWER, ":MEAS:POW?" },
214 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
215 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.2f" },
216 { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
217 { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
218 { SCPI_CMD_GET_OUTPUT_ENABLED, ":CONF:OUTP?" },
219 { SCPI_CMD_SET_OUTPUT_ENABLE, ":CONF:OUTP ON" },
220 { SCPI_CMD_SET_OUTPUT_DISABLE, ":CONF:OUTP OFF" },
221 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT:HIGH?" },
222 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT:HIGH %.6f" },
223 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":SOUR:CURR:PROT:HIGH?" },
224 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":SOUR:CURR:PROT:HIGH %.6f" },
228 static int chroma_62000p_probe_channels(struct sr_dev_inst *sdi,
229 struct sr_scpi_hw_info *hw_info,
230 struct channel_spec **channels, unsigned int *num_channels,
231 struct channel_group_spec **channel_groups,
232 unsigned int *num_channel_groups)
234 unsigned int volts, amps, watts;
235 struct channel_spec *channel;
239 sscanf(hw_info->model, "620%uP-%u-%u", &watts, &volts, &s);
241 sr_dbg("Found device rated for %d V, %d A and %d W", volts, amps, watts);
244 sr_err("Probed max voltage of %u V is out of spec.", volts);
249 sr_err("Probed max current of %u A is out of spec.", amps);
254 sr_err("Probed max power of %u W is out of spec.", watts);
258 channel = g_malloc0(sizeof(struct channel_spec));
260 channel->voltage[0] = channel->current[0] = channel->power[0] = 0.0;
261 channel->voltage[1] = volts;
262 channel->current[1] = amps;
263 channel->power[1] = watts;
264 channel->voltage[2] = channel->current[2] = 0.01;
265 channel->voltage[3] = channel->voltage[4] = 3;
266 channel->current[3] = channel->current[4] = 4;
270 *channel_groups = g_malloc(sizeof(struct channel_group_spec));
271 **channel_groups = chroma_62000_cg[0];
272 *num_channel_groups = 1;
277 /* Rigol DP700 series */
278 static const uint32_t rigol_dp700_devopts[] = {
280 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
281 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
284 static const uint32_t rigol_dp700_devopts_cg[] = {
285 SR_CONF_REGULATION | SR_CONF_GET,
286 SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
287 SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET,
288 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
289 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
290 SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE | SR_CONF_GET,
291 SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
292 SR_CONF_VOLTAGE | SR_CONF_GET,
293 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
294 SR_CONF_CURRENT | SR_CONF_GET,
295 SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
296 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
299 static const struct channel_spec rigol_dp711_ch[] = {
300 { "1", { 0, 30, 0.01, 3, 3 }, { 0, 5, 0.01, 3, 3 }, { 0, 150, 0, 3, 3 }, FREQ_DC_ONLY, { 0.01, 33, 0.01}, { 0.01, 5.5, 0.01 } },
303 static const struct channel_spec rigol_dp712_ch[] = {
304 { "1", { 0, 50, 0.01, 3, 3 }, { 0, 3, 0.01, 3, 3 }, { 0, 150, 0, 3, 3 }, FREQ_DC_ONLY, { 0.01, 55, 0.01}, { 0.01, 3.3, 0.01 } },
307 static const struct channel_group_spec rigol_dp700_cg[] = {
308 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
311 /* Same as the DP800 series, except for the missing :SYST:OTP* commands. */
312 static const struct scpi_command rigol_dp700_cmd[] = {
313 { SCPI_CMD_REMOTE, "SYST:REMOTE" },
314 { SCPI_CMD_LOCAL, "SYST:LOCAL" },
315 { SCPI_CMD_BEEPER, "SYST:BEEP:STAT?" },
316 { SCPI_CMD_BEEPER_ENABLE, "SYST:BEEP:STAT ON" },
317 { SCPI_CMD_BEEPER_DISABLE, "SYST:BEEP:STAT OFF" },
318 { SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" },
319 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
320 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
321 { SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWE?" },
322 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
323 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
324 { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
325 { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
326 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" },
327 { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" },
328 { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" },
329 { SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE?" },
330 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP?" },
331 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE, ":OUTP:OVP ON" },
332 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE, ":OUTP:OVP OFF" },
333 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES?" },
334 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL?" },
335 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL %.6f" },
336 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP?" },
337 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":OUTP:OCP:STAT ON" },
338 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":OUTP:OCP:STAT OFF" },
339 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES?" },
340 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL?" },
341 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL %.6f" },
345 /* Rigol DP800 series */
346 static const uint32_t rigol_dp800_devopts[] = {
348 SR_CONF_OVER_TEMPERATURE_PROTECTION | SR_CONF_GET | SR_CONF_SET,
349 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
350 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
353 static const uint32_t rigol_dp800_devopts_cg[] = {
354 SR_CONF_REGULATION | SR_CONF_GET,
355 SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
356 SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET,
357 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
358 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
359 SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE | SR_CONF_GET,
360 SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
361 SR_CONF_VOLTAGE | SR_CONF_GET,
362 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
363 SR_CONF_CURRENT | SR_CONF_GET,
364 SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
365 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
368 static const struct channel_spec rigol_dp821a_ch[] = {
369 { "1", { 0, 60, 0.001, 3, 3 }, { 0, 1, 0.0001, 4, 4 }, { 0, 60, 0, 3, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
370 { "2", { 0, 8, 0.001, 3, 3 }, { 0, 10, 0.001, 3, 3 }, { 0, 80, 0, 3, 3 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
373 static const struct channel_spec rigol_dp831_ch[] = {
374 { "1", { 0, 8, 0.001, 3, 4 }, { 0, 5, 0.0003, 3, 4 }, { 0, 40, 0, 3, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
375 { "2", { 0, 30, 0.001, 3, 4 }, { 0, 2, 0.0001, 3, 4 }, { 0, 60, 0, 3, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
376 { "3", { 0, -30, 0.001, 3, 4 }, { 0, 2, 0.0001, 3, 4 }, { 0, 60, 0, 3, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
379 static const struct channel_spec rigol_dp832_ch[] = {
380 { "1", { 0, 30, 0.001, 3, 4 }, { 0, 3, 0.001, 3, 4 }, { 0, 90, 0, 3, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
381 { "2", { 0, 30, 0.001, 3, 4 }, { 0, 3, 0.001, 3, 4 }, { 0, 90, 0, 3, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
382 { "3", { 0, 5, 0.001, 3, 4 }, { 0, 3, 0.001, 3, 4 }, { 0, 90, 0, 3, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
385 static const struct channel_group_spec rigol_dp820_cg[] = {
386 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
387 { "2", CH_IDX(1), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
390 static const struct channel_group_spec rigol_dp830_cg[] = {
391 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
392 { "2", CH_IDX(1), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
393 { "3", CH_IDX(2), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
396 static const struct scpi_command rigol_dp800_cmd[] = {
397 { SCPI_CMD_REMOTE, "SYST:REMOTE" },
398 { SCPI_CMD_LOCAL, "SYST:LOCAL" },
399 { SCPI_CMD_BEEPER, "SYST:BEEP:STAT?" },
400 { SCPI_CMD_BEEPER_ENABLE, "SYST:BEEP:STAT ON" },
401 { SCPI_CMD_BEEPER_DISABLE, "SYST:BEEP:STAT OFF" },
402 { SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" },
403 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
404 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
405 { SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWE?" },
406 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
407 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
408 { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
409 { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
410 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" },
411 { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" },
412 { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" },
413 { SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE?" },
414 { SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP?" },
415 { SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE, ":SYST:OTP ON" },
416 { SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE, ":SYST:OTP OFF" },
417 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP?" },
418 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE, ":OUTP:OVP ON" },
419 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE, ":OUTP:OVP OFF" },
420 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES?" },
421 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL?" },
422 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL %.6f" },
423 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP?" },
424 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":OUTP:OCP:STAT ON" },
425 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":OUTP:OCP:STAT OFF" },
426 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES?" },
427 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL?" },
428 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL %.6f" },
432 /* HP 663xA series */
433 static const uint32_t hp_6630a_devopts[] = {
435 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
436 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
439 static const uint32_t hp_6630a_devopts_cg[] = {
440 SR_CONF_ENABLED | SR_CONF_SET,
441 SR_CONF_VOLTAGE | SR_CONF_GET,
442 SR_CONF_CURRENT | SR_CONF_GET,
443 SR_CONF_VOLTAGE_TARGET | SR_CONF_SET | SR_CONF_LIST,
444 SR_CONF_CURRENT_LIMIT | SR_CONF_SET | SR_CONF_LIST,
445 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_SET | SR_CONF_LIST,
446 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_SET,
447 SR_CONF_REGULATION | SR_CONF_GET,
450 static const struct channel_spec hp_6633a_ch[] = {
451 { "1", { 0, 51.188, 0.0125, 3, 4 }, { 0, 2.0475, 0.0005, 4, 5 }, { 0, 104.80743 }, FREQ_DC_ONLY, { 0, 55, 0.25 }, NO_OCP_LIMITS },
454 static const struct channel_group_spec hp_6630a_cg[] = {
455 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
458 static const struct scpi_command hp_6630a_cmd[] = {
459 { SCPI_CMD_SET_OUTPUT_ENABLE, "OUT 1" },
460 { SCPI_CMD_SET_OUTPUT_DISABLE, "OUT 0" },
461 { SCPI_CMD_GET_MEAS_VOLTAGE, "VOUT?" },
462 { SCPI_CMD_GET_MEAS_CURRENT, "IOUT?" },
463 { SCPI_CMD_SET_VOLTAGE_TARGET, "VSET %.4f" },
464 { SCPI_CMD_SET_CURRENT_LIMIT, "ISET %.4f" },
465 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, "OCP 1" },
466 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, "OCP 0" },
467 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, "OVSET %.4f" },
468 { SCPI_CMD_GET_OUTPUT_REGULATION, "STS?" },
472 /* HP 663xB series */
473 static const uint32_t hp_6630b_devopts[] = {
475 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
476 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
479 static const uint32_t hp_6630b_devopts_cg[] = {
480 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
481 SR_CONF_VOLTAGE | SR_CONF_GET,
482 SR_CONF_CURRENT | SR_CONF_GET,
483 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
484 SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
485 SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET,
486 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
487 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
488 SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE | SR_CONF_GET,
489 SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE | SR_CONF_GET,
490 SR_CONF_REGULATION | SR_CONF_GET,
493 static const struct channel_spec hp_6631b_ch[] = {
494 { "1", { 0, 8.19, 0.002, 3, 4 }, { 0, 10.237, 0.00263, 4, 5 }, { 0, 83.84103 }, FREQ_DC_ONLY, { 0, 12, 0.06 }, NO_OCP_LIMITS },
497 static const struct channel_spec hp_6632b_ch[] = {
498 { "1", { 0, 20.475, 0.005, 3, 4 }, { 0, 5.1188, 0.00132, 4, 5 }, { 0, 104.80743 }, FREQ_DC_ONLY, { 0, 22, 0.1 }, NO_OCP_LIMITS },
501 static const struct channel_spec hp_66332a_ch[] = {
502 { "1", { 0, 20.475, 0.005, 3, 4 }, { 0, 5.1188, 0.00132, 4, 5 }, { 0, 104.80743 }, FREQ_DC_ONLY, { 0, 22, 0.1 }, NO_OCP_LIMITS },
505 static const struct channel_spec hp_6633b_ch[] = {
506 { "1", { 0, 51.188, 0.0125, 3, 4 }, { 0, 2.0475, 0.000526, 4, 5 }, { 0, 104.80743 }, FREQ_DC_ONLY, { 0, 55, 0.25 }, NO_OCP_LIMITS },
509 static const struct channel_spec hp_6634b_ch[] = {
510 { "1", { 0, 102.38, 0.025, 3, 4 }, { 0, 1.0238, 0.000263, 4, 5 }, { 0, 104.81664 }, FREQ_DC_ONLY, { 0, 110, 0.5 }, NO_OCP_LIMITS },
513 static const struct channel_group_spec hp_6630b_cg[] = {
514 { "1", CH_IDX(0), PPS_OVP | PPS_OCP, SR_MQFLAG_DC },
517 static const struct scpi_command hp_6630b_cmd[] = {
518 { SCPI_CMD_REMOTE, "SYST:REM" },
519 { SCPI_CMD_LOCAL, "SYST:LOC" },
520 { SCPI_CMD_GET_OUTPUT_ENABLED, "OUTP:STAT?" },
521 { SCPI_CMD_SET_OUTPUT_ENABLE, "OUTP:STAT ON" },
522 { SCPI_CMD_SET_OUTPUT_DISABLE, "OUTP:STAT OFF" },
523 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
524 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
525 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
526 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
527 { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
528 { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
529 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":CURR:PROT:STAT?" },
530 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":CURR:PROT:STAT 1" },
531 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":CURR:PROT:STAT 0" },
532 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, "STAT:QUES:COND?" },
533 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, "STAT:QUES:COND?" },
534 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT?" },
535 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":VOLT:PROT %.6f" },
536 { SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION_ACTIVE, "STAT:QUES:COND?" },
537 { SCPI_CMD_GET_OUTPUT_REGULATION, "STAT:OPER:COND?" },
541 static int hp_6630b_init_aquisition(const struct sr_dev_inst *sdi)
543 struct sr_scpi_dev_inst *scpi;
549 * Monitor CV (256), CC+ (1024) and CC- (2048) bits of the
550 * Operational Status Register.
551 * Use both positive and negative transitions of the status bits.
553 ret = sr_scpi_send(scpi, "STAT:OPER:PTR 3328;NTR 3328;ENAB 3328");
558 * Monitor OVP (1), OCP (2), OTP (16) and Unreg (1024) bits of the
559 * Questionable Status Register.
560 * Use both positive and negative transitions of the status bits.
562 ret = sr_scpi_send(scpi, "STAT:QUES:PTR 1043;NTR 1043;ENAB 1043");
567 * Service Request Enable Register set for Operational Status Register
568 * bits (128) and Questionable Status Register bits (8).
569 * This masks the Status Register generating a SRQ/RQS. Not implemented yet!
572 ret = sr_scpi_send(scpi, "*SRE 136");
580 static int hp_6630b_update_status(const struct sr_dev_inst *sdi)
582 struct sr_scpi_dev_inst *scpi;
585 int ques_even, ques_cond;
586 int oper_even, oper_cond;
587 gboolean output_enabled;
588 gboolean unreg, cv, cc_pos, cc_neg;
589 gboolean regulation_changed;
598 regulation_changed = FALSE;
601 * Use SPoll when SCPI uses GPIB as transport layer.
602 * SPoll is approx. twice as fast as a normal GPIB write + read would be!
607 if (scpi->transport == SCPI_TRANSPORT_LIBGPIB) {
608 ret = sr_scpi_gpib_spoll(scpi, &spoll_buf);
611 stb = (uint8_t)spoll_buf;
615 ret = sr_scpi_get_int(scpi, "*STB?", &stb);
622 /* Questionable status summary bit */
623 if (stb & (1 << 3)) {
624 /* Read the event register to clear it! */
625 ret = sr_scpi_get_int(scpi, "STAT:QUES:EVEN?", &ques_even);
628 /* Now get the values. */
629 ret = sr_scpi_get_int(scpi, "STAT:QUES:COND?", &ques_cond);
634 if (ques_even & (1 << 0))
635 sr_session_send_meta(sdi, SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE,
636 g_variant_new_boolean(ques_cond & (1 << 0)));
639 if (ques_even & (1 << 1))
640 sr_session_send_meta(sdi, SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE,
641 g_variant_new_boolean(ques_cond & (1 << 1)));
644 if (ques_even & (1 << 4))
645 sr_session_send_meta(sdi, SR_CONF_OVER_TEMPERATURE_PROTECTION_ACTIVE,
646 g_variant_new_boolean(ques_cond & (1 << 4)));
649 unreg = (ques_cond & (1 << 10));
650 regulation_changed = (ques_even & (1 << 10)) | regulation_changed;
653 * Check if output state has changed, due to one of the
654 * questionable states changed.
655 * NOTE: The output state is send even if it hasn't changed, but that
656 * only happends rarely.
658 ret = sr_scpi_get_bool(scpi, "OUTP:STAT?", &output_enabled);
661 sr_session_send_meta(sdi, SR_CONF_ENABLED,
662 g_variant_new_boolean(output_enabled));
665 /* Operation status summary bit */
666 if (stb & (1 << 7)) {
667 /* Read the event register to clear it! */
668 ret = sr_scpi_get_int(scpi, "STAT:OPER:EVEN?", &oper_even);
671 /* Now get the values. */
672 ret = sr_scpi_get_int(scpi, "STAT:OPER:COND?", &oper_cond);
677 cv = (oper_cond & (1 << 8));
678 regulation_changed = (oper_even & (1 << 8)) | regulation_changed;
680 cc_pos = (oper_cond & (1 << 10));
681 regulation_changed = (oper_even & (1 << 10)) | regulation_changed;
683 cc_neg = (oper_cond & (1 << 11));
684 regulation_changed = (oper_even & (1 << 11)) | regulation_changed;
687 if (regulation_changed) {
688 if (cv && !cc_pos && !cc_neg &&!unreg)
690 else if (cc_pos && !cv && !cc_neg && !unreg)
692 else if (cc_neg && !cv && !cc_pos && !unreg)
694 else if (unreg && !cv && !cc_pos && !cc_neg)
696 else if (!cv && !cc_pos && !cc_neg &&!unreg)
697 /* This happends in case of OCP active */
700 /* This happends from time to time (CV and CC+ active). */
701 sr_dbg("Undefined regulation for HP 66xxB "
702 "(CV=%i, CC+=%i, CC-=%i, UR=%i).",
703 cv, cc_pos, cc_neg, unreg);
706 sr_session_send_meta(sdi, SR_CONF_REGULATION,
707 g_variant_new_string(regulation));
713 /* Philips/Fluke PM2800 series */
714 static const uint32_t philips_pm2800_devopts[] = {
716 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
717 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
720 static const uint32_t philips_pm2800_devopts_cg[] = {
721 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
722 SR_CONF_VOLTAGE | SR_CONF_GET,
723 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
724 SR_CONF_CURRENT | SR_CONF_GET,
725 SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
726 SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET,
727 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
728 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
729 SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE | SR_CONF_GET,
730 SR_CONF_REGULATION | SR_CONF_GET,
733 enum philips_pm2800_modules {
734 PM2800_MOD_30V_10A = 1,
742 static const struct philips_pm2800_module_spec {
743 /* Min, max, programming resolution. */
747 } philips_pm2800_module_specs[] = {
748 /* Autoranging modules. */
749 [PM2800_MOD_30V_10A] = { { 0, 30, 0.0075, 2, 4 }, { 0, 10, 0.0025, 2, 4 }, { 0, 60 } },
750 [PM2800_MOD_60V_5A] = { { 0, 60, 0.015, 2, 3 }, { 0, 5, 0.00125, 2, 5 }, { 0, 60 } },
751 [PM2800_MOD_60V_10A] = { { 0, 60, 0.015, 2, 3 }, { 0, 10, 0.0025, 2, 5 }, { 0, 120 } },
752 /* Linear modules. */
753 [PM2800_MOD_8V_15A] = { { 0, 8, 0.002, 3, 3 }, { -15, 15, 0.00375, 3, 5 }, { 0, 120 } },
754 [PM2800_MOD_60V_2A] = { { 0, 60, 0.015, 2, 3 }, { -2, 2, 0.0005, 3, 4 }, { 0, 120 } },
755 [PM2800_MOD_120V_1A] = { { 0, 120, 0.030, 2, 2 }, { -1, 1, 0.00025, 3, 5 }, { 0, 120 } },
758 static const struct philips_pm2800_model {
759 unsigned int chassis;
760 unsigned int num_modules;
762 unsigned int modules[3];
763 } philips_pm2800_matrix[] = {
764 /* Autoranging chassis. */
765 { 1, 1, 0, { PM2800_MOD_30V_10A, 0, 0 } },
766 { 1, 1, 1, { PM2800_MOD_60V_5A, 0, 0 } },
767 { 1, 2, 0, { PM2800_MOD_30V_10A, PM2800_MOD_30V_10A, 0 } },
768 { 1, 2, 1, { PM2800_MOD_60V_5A, PM2800_MOD_60V_5A, 0 } },
769 { 1, 2, 2, { PM2800_MOD_30V_10A, PM2800_MOD_60V_5A, 0 } },
770 { 1, 2, 3, { PM2800_MOD_30V_10A, PM2800_MOD_60V_10A, 0 } },
771 { 1, 2, 4, { PM2800_MOD_60V_5A, PM2800_MOD_60V_10A, 0 } },
772 { 1, 3, 0, { PM2800_MOD_30V_10A, PM2800_MOD_30V_10A, PM2800_MOD_30V_10A } },
773 { 1, 3, 1, { PM2800_MOD_60V_5A, PM2800_MOD_60V_5A, PM2800_MOD_60V_5A } },
774 { 1, 3, 2, { PM2800_MOD_30V_10A, PM2800_MOD_30V_10A, PM2800_MOD_60V_5A } },
775 { 1, 3, 3, { PM2800_MOD_30V_10A, PM2800_MOD_60V_5A, PM2800_MOD_60V_5A } },
776 /* Linear chassis. */
777 { 3, 1, 0, { PM2800_MOD_60V_2A, 0, 0 } },
778 { 3, 1, 1, { PM2800_MOD_120V_1A, 0, 0 } },
779 { 3, 1, 2, { PM2800_MOD_8V_15A, 0, 0 } },
780 { 3, 2, 0, { PM2800_MOD_60V_2A, 0, 0 } },
781 { 3, 2, 1, { PM2800_MOD_120V_1A, 0, 0 } },
782 { 3, 2, 2, { PM2800_MOD_60V_2A, PM2800_MOD_120V_1A, 0 } },
783 { 3, 2, 3, { PM2800_MOD_8V_15A, PM2800_MOD_8V_15A, 0 } },
786 static const char *philips_pm2800_names[] = { "1", "2", "3" };
788 static int philips_pm2800_probe_channels(struct sr_dev_inst *sdi,
789 struct sr_scpi_hw_info *hw_info,
790 struct channel_spec **channels, unsigned int *num_channels,
791 struct channel_group_spec **channel_groups, unsigned int *num_channel_groups)
793 const struct philips_pm2800_model *model;
794 const struct philips_pm2800_module_spec *spec;
795 unsigned int chassis, num_modules, set, module, m, i;
800 * The model number as reported by *IDN? looks like e.g. PM2813/11,
801 * Where "PM28" is fixed, followed by the chassis code (1 = autoranging,
802 * 3 = linear series) and the number of modules: 1-3 for autoranging,
804 * After the slash, the first digit denotes the module set. The
805 * digit after that denotes front (5) or rear (1) binding posts.
807 chassis = hw_info->model[4] - 0x30;
808 num_modules = hw_info->model[5] - 0x30;
809 set = hw_info->model[7] - 0x30;
810 for (m = 0; m < ARRAY_SIZE(philips_pm2800_matrix); m++) {
811 model = &philips_pm2800_matrix[m];
812 if (model->chassis == chassis && model->num_modules == num_modules
813 && model->set == set)
816 if (m == ARRAY_SIZE(philips_pm2800_matrix)) {
817 sr_dbg("Model %s not found in matrix.", hw_info->model);
821 sr_dbg("Found %d output channel%s:", num_modules, num_modules > 1 ? "s" : "");
822 *channels = g_malloc0(sizeof(struct channel_spec) * num_modules);
823 *channel_groups = g_malloc0(sizeof(struct channel_group_spec) * num_modules);
824 for (i = 0; i < num_modules; i++) {
825 module = model->modules[i];
826 spec = &philips_pm2800_module_specs[module];
827 sr_dbg("output %d: %.0f - %.0fV, %.0f - %.0fA, %.0f - %.0fW", i + 1,
828 spec->voltage[0], spec->voltage[1],
829 spec->current[0], spec->current[1],
830 spec->power[0], spec->power[1]);
831 (*channels)[i].name = (char *)philips_pm2800_names[i];
832 memcpy(&((*channels)[i].voltage), spec, sizeof(double) * 15);
833 (*channel_groups)[i].name = (char *)philips_pm2800_names[i];
834 (*channel_groups)[i].channel_index_mask = 1 << i;
835 (*channel_groups)[i].features = PPS_OTP | PPS_OVP | PPS_OCP;
836 (*channel_groups)[i].mqflags = SR_MQFLAG_DC;
838 *num_channels = *num_channel_groups = num_modules;
843 static const struct scpi_command philips_pm2800_cmd[] = {
844 { SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" },
845 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
846 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
847 { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
848 { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
849 { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
850 { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
851 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" },
852 { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" },
853 { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" },
854 { SCPI_CMD_GET_OUTPUT_REGULATION, ":SOUR:FUNC:MODE?" },
855 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":SOUR:VOLT:PROT:TRIP?" },
856 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT:LEV?" },
857 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT:LEV %.6f" },
858 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":SOUR:CURR:PROT:STAT?" },
859 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":SOUR:CURR:PROT:STAT ON" },
860 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":SOUR:CURR:PROT:STAT OFF" },
861 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":SOUR:CURR:PROT:TRIP?" },
865 static const uint32_t rs_hmc8043_devopts[] = {
867 SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
868 SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
871 static const uint32_t rs_hmc8043_devopts_cg[] = {
872 SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
873 SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET,
874 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
875 SR_CONF_VOLTAGE | SR_CONF_GET,
876 SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
877 SR_CONF_CURRENT | SR_CONF_GET,
878 SR_CONF_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
879 SR_CONF_ENABLED | SR_CONF_GET | SR_CONF_SET,
882 static const struct channel_spec rs_hmc8043_ch[] = {
883 { "1", { 0, 32.050, 0.001, 3, 4 }, { 0.001, 3, 0.001, 3, 4 }, { 0, 0, 0, 0, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
884 { "2", { 0, 32.050, 0.001, 3, 4 }, { 0.001, 3, 0.001, 3, 4 }, { 0, 0, 0, 0, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
885 { "3", { 0, 32.050, 0.001, 3, 4 }, { 0.001, 3, 0.001, 3, 4 }, { 0, 0, 0, 0, 4 }, FREQ_DC_ONLY, NO_OVP_LIMITS, NO_OCP_LIMITS },
888 static const struct channel_group_spec rs_hmc8043_cg[] = {
889 { "1", CH_IDX(0), PPS_OVP, SR_MQFLAG_DC },
890 { "2", CH_IDX(1), PPS_OVP, SR_MQFLAG_DC },
891 { "3", CH_IDX(2), PPS_OVP, SR_MQFLAG_DC },
894 static const struct scpi_command rs_hmc8043_cmd[] = {
895 { SCPI_CMD_SELECT_CHANNEL, "INST:NSEL %s" },
896 { SCPI_CMD_GET_MEAS_VOLTAGE, "MEAS:VOLT?" },
897 { SCPI_CMD_GET_MEAS_CURRENT, "MEAS:CURR?" },
898 { SCPI_CMD_GET_VOLTAGE_TARGET, "VOLT?" },
899 { SCPI_CMD_SET_VOLTAGE_TARGET, "VOLT %.6f" },
900 { SCPI_CMD_GET_CURRENT_LIMIT, "CURR?" },
901 { SCPI_CMD_SET_CURRENT_LIMIT, "CURR %.6f" },
902 { SCPI_CMD_GET_OUTPUT_ENABLED, "OUTP?" },
903 { SCPI_CMD_SET_OUTPUT_ENABLE, "OUTP ON" },
904 { SCPI_CMD_SET_OUTPUT_DISABLE, "OUTP OFF" },
905 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, "VOLT:PROT:TRIP?" },
906 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, "VOLT:PROT:LEV?" },
907 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, "VOLT:PROT:LEV %.6f" },
908 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, "VOLT:PROT:STAT?" },
909 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE, "VOLT:PROT:STAT ON" },
910 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE, "VOLT:PROT:STAT OFF" },
914 SR_PRIV const struct scpi_pps pps_profiles[] = {
916 { "Agilent", "N5763A", SCPI_DIALECT_UNKNOWN, 0,
917 ARRAY_AND_SIZE(agilent_n5700a_devopts),
918 ARRAY_AND_SIZE(agilent_n5700a_devopts_cg),
919 ARRAY_AND_SIZE(agilent_n5763a_ch),
920 ARRAY_AND_SIZE(agilent_n5700a_cg),
922 .probe_channels = NULL,
923 .init_aquisition = NULL,
924 .update_status = NULL,
928 { "Agilent", "N5767A", SCPI_DIALECT_UNKNOWN, 0,
929 ARRAY_AND_SIZE(agilent_n5700a_devopts),
930 ARRAY_AND_SIZE(agilent_n5700a_devopts_cg),
931 ARRAY_AND_SIZE(agilent_n5767a_ch),
932 ARRAY_AND_SIZE(agilent_n5700a_cg),
934 .probe_channels = NULL,
935 .init_aquisition = NULL,
936 .update_status = NULL,
939 /* BK Precision 9310 */
940 { "BK", "^9130$", SCPI_DIALECT_UNKNOWN, 0,
941 ARRAY_AND_SIZE(bk_9130_devopts),
942 ARRAY_AND_SIZE(bk_9130_devopts_cg),
943 ARRAY_AND_SIZE(bk_9130_ch),
944 ARRAY_AND_SIZE(bk_9130_cg),
946 .probe_channels = NULL,
947 .init_aquisition = NULL,
948 .update_status = NULL,
952 { "Chroma", "61604", SCPI_DIALECT_UNKNOWN, 0,
953 ARRAY_AND_SIZE(chroma_61604_devopts),
954 ARRAY_AND_SIZE(chroma_61604_devopts_cg),
955 ARRAY_AND_SIZE(chroma_61604_ch),
956 ARRAY_AND_SIZE(chroma_61604_cg),
958 .probe_channels = NULL,
959 .init_aquisition = NULL,
960 .update_status = NULL,
963 /* Chroma 62000 series */
964 { "Chroma", "620[0-9]{2}P-[0-9]{2,3}-[0-9]{1,3}", SCPI_DIALECT_UNKNOWN, 0,
965 ARRAY_AND_SIZE(chroma_62000_devopts),
966 ARRAY_AND_SIZE(chroma_62000_devopts_cg),
970 .probe_channels = chroma_62000p_probe_channels,
971 .init_aquisition = NULL,
972 .update_status = NULL,
976 { "HP", "6633A", SCPI_DIALECT_HP_COMP, 0,
977 ARRAY_AND_SIZE(hp_6630a_devopts),
978 ARRAY_AND_SIZE(hp_6630a_devopts_cg),
979 ARRAY_AND_SIZE(hp_6633a_ch),
980 ARRAY_AND_SIZE(hp_6630a_cg),
982 .probe_channels = NULL,
983 .init_aquisition = NULL,
984 .update_status = NULL,
988 { "HP", "6631B", SCPI_DIALECT_HP_66XXB, PPS_OTP,
989 ARRAY_AND_SIZE(hp_6630b_devopts),
990 ARRAY_AND_SIZE(hp_6630b_devopts_cg),
991 ARRAY_AND_SIZE(hp_6631b_ch),
992 ARRAY_AND_SIZE(hp_6630b_cg),
994 .probe_channels = NULL,
995 hp_6630b_init_aquisition,
996 hp_6630b_update_status,
1000 { "HP", "6632B", SCPI_DIALECT_HP_66XXB, PPS_OTP,
1001 ARRAY_AND_SIZE(hp_6630b_devopts),
1002 ARRAY_AND_SIZE(hp_6630b_devopts_cg),
1003 ARRAY_AND_SIZE(hp_6632b_ch),
1004 ARRAY_AND_SIZE(hp_6630b_cg),
1006 .probe_channels = NULL,
1007 hp_6630b_init_aquisition,
1008 hp_6630b_update_status,
1012 { "HP", "66332A", SCPI_DIALECT_HP_66XXB, PPS_OTP,
1013 ARRAY_AND_SIZE(hp_6630b_devopts),
1014 ARRAY_AND_SIZE(hp_6630b_devopts_cg),
1015 ARRAY_AND_SIZE(hp_66332a_ch),
1016 ARRAY_AND_SIZE(hp_6630b_cg),
1018 .probe_channels = NULL,
1019 hp_6630b_init_aquisition,
1020 hp_6630b_update_status,
1024 { "HP", "6633B", SCPI_DIALECT_HP_66XXB, PPS_OTP,
1025 ARRAY_AND_SIZE(hp_6630b_devopts),
1026 ARRAY_AND_SIZE(hp_6630b_devopts_cg),
1027 ARRAY_AND_SIZE(hp_6633b_ch),
1028 ARRAY_AND_SIZE(hp_6630b_cg),
1030 .probe_channels = NULL,
1031 hp_6630b_init_aquisition,
1032 hp_6630b_update_status,
1036 { "HP", "6634B", SCPI_DIALECT_HP_66XXB, PPS_OTP,
1037 ARRAY_AND_SIZE(hp_6630b_devopts),
1038 ARRAY_AND_SIZE(hp_6630b_devopts_cg),
1039 ARRAY_AND_SIZE(hp_6634b_ch),
1040 ARRAY_AND_SIZE(hp_6630b_cg),
1042 .probe_channels = NULL,
1043 hp_6630b_init_aquisition,
1044 hp_6630b_update_status,
1047 /* Rigol DP700 series */
1048 { "Rigol", "^DP711$", SCPI_DIALECT_UNKNOWN, 0,
1049 ARRAY_AND_SIZE(rigol_dp700_devopts),
1050 ARRAY_AND_SIZE(rigol_dp700_devopts_cg),
1051 ARRAY_AND_SIZE(rigol_dp711_ch),
1052 ARRAY_AND_SIZE(rigol_dp700_cg),
1054 .probe_channels = NULL,
1055 .init_aquisition = NULL,
1056 .update_status = NULL,
1058 { "Rigol", "^DP712$", SCPI_DIALECT_UNKNOWN, 0,
1059 ARRAY_AND_SIZE(rigol_dp700_devopts),
1060 ARRAY_AND_SIZE(rigol_dp700_devopts_cg),
1061 ARRAY_AND_SIZE(rigol_dp712_ch),
1062 ARRAY_AND_SIZE(rigol_dp700_cg),
1064 .probe_channels = NULL,
1065 .init_aquisition = NULL,
1066 .update_status = NULL,
1069 /* Rigol DP800 series */
1070 { "Rigol", "^DP821A$", SCPI_DIALECT_UNKNOWN, PPS_OTP,
1071 ARRAY_AND_SIZE(rigol_dp800_devopts),
1072 ARRAY_AND_SIZE(rigol_dp800_devopts_cg),
1073 ARRAY_AND_SIZE(rigol_dp821a_ch),
1074 ARRAY_AND_SIZE(rigol_dp820_cg),
1076 .probe_channels = NULL,
1077 .init_aquisition = NULL,
1078 .update_status = NULL,
1080 { "Rigol", "^DP831A$", SCPI_DIALECT_UNKNOWN, PPS_OTP,
1081 ARRAY_AND_SIZE(rigol_dp800_devopts),
1082 ARRAY_AND_SIZE(rigol_dp800_devopts_cg),
1083 ARRAY_AND_SIZE(rigol_dp831_ch),
1084 ARRAY_AND_SIZE(rigol_dp830_cg),
1086 .probe_channels = NULL,
1087 .init_aquisition = NULL,
1088 .update_status = NULL,
1090 { "Rigol", "^(DP832|DP832A)$", SCPI_DIALECT_UNKNOWN, PPS_OTP,
1091 ARRAY_AND_SIZE(rigol_dp800_devopts),
1092 ARRAY_AND_SIZE(rigol_dp800_devopts_cg),
1093 ARRAY_AND_SIZE(rigol_dp832_ch),
1094 ARRAY_AND_SIZE(rigol_dp830_cg),
1096 .probe_channels = NULL,
1097 .init_aquisition = NULL,
1098 .update_status = NULL,
1101 /* Philips/Fluke PM2800 series */
1102 { "Philips", "^PM28[13][123]/[01234]{1,2}$", SCPI_DIALECT_PHILIPS, 0,
1103 ARRAY_AND_SIZE(philips_pm2800_devopts),
1104 ARRAY_AND_SIZE(philips_pm2800_devopts_cg),
1108 philips_pm2800_probe_channels,
1109 .init_aquisition = NULL,
1110 .update_status = NULL,
1113 /* Rohde & Schwarz HMC8043 */
1114 { "Rohde&Schwarz", "HMC8043", SCPI_DIALECT_UNKNOWN, 0,
1115 ARRAY_AND_SIZE(rs_hmc8043_devopts),
1116 ARRAY_AND_SIZE(rs_hmc8043_devopts_cg),
1117 ARRAY_AND_SIZE(rs_hmc8043_ch),
1118 ARRAY_AND_SIZE(rs_hmc8043_cg),
1120 .probe_channels = NULL,
1121 .init_aquisition = NULL,
1122 .update_status = NULL,
1126 SR_PRIV unsigned int num_pps_profiles = ARRAY_SIZE(pps_profiles);