]> sigrok.org Git - libsigrok.git/blob - src/hardware/scpi-pps/profiles.c
scpi-pps: Disable beeper during session.
[libsigrok.git] / src / hardware / scpi-pps / profiles.c
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
20 #include <string.h>
21 #include "protocol.h"
22
23 #define CH_IDX(x) (1 << x)
24
25 const char *pps_vendors[][2] = {
26         { "RIGOL TECHNOLOGIES", "Rigol" },
27         { "HEWLETT-PACKARD", "HP" },
28 };
29
30 const 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
42 static const uint32_t devopts_none[] = { };
43
44 /* Rigol DP800 series */
45 static const uint32_t rigol_dp800_devopts[] = {
46         SR_CONF_POWER_SUPPLY,
47         SR_CONF_CONTINUOUS,
48         SR_CONF_OVER_TEMPERATURE_PROTECTION | SR_CONF_GET | SR_CONF_SET,
49 };
50
51 static const uint32_t rigol_dp800_devopts_cg[] = {
52         SR_CONF_OUTPUT_REGULATION | SR_CONF_GET,
53         SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
54         SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET,
55         SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
56         SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET,
57         SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE | SR_CONF_GET,
58         SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET,
59         SR_CONF_OUTPUT_VOLTAGE | SR_CONF_GET,
60         SR_CONF_OUTPUT_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
61         SR_CONF_OUTPUT_CURRENT | SR_CONF_GET,
62         SR_CONF_OUTPUT_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
63         SR_CONF_OUTPUT_ENABLED | SR_CONF_GET | SR_CONF_SET,
64 };
65
66 struct 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 } },
70 };
71
72 struct 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
78 struct channel_group_spec rigol_dp800_cg[] = {
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
84 struct scpi_command rigol_dp800_cmd[] = {
85         { SCPI_CMD_REMOTE, "SYST:REMOTE" },
86         { SCPI_CMD_LOCAL, "SYST:LOCAL" },
87         { SCPI_CMD_BEEPER, "SYST:BEEP:STAT?" },
88         { SCPI_CMD_BEEPER_ENABLE, "SYST:BEEP:STAT ON" },
89         { SCPI_CMD_BEEPER_DISABLE, "SYST:BEEP:STAT OFF" },
90         { SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" },
91         { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
92         { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
93         { SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWE?" },
94         { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
95         { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
96         { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
97         { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
98         { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" },
99         { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" },
100         { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" },
101         { SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE?" },
102         { SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP?" },
103         { SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE, ":SYST:OTP ON" },
104         { SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE, ":SYST:OTP OFF" },
105         { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP?" },
106         { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE, ":OUTP:OVP ON" },
107         { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE, ":OUTP:OVP OFF" },
108         { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES?" },
109         { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL?" },
110         { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL %.6f" },
111         { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP?" },
112         { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":OUTP:OCP:STAT ON" },
113         { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":OUTP:OCP:STAT OFF" },
114         { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES?" },
115         { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL?" },
116         { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL %.6f" },
117 };
118
119 /* HP 663xx series */
120 static const uint32_t hp_6632b_devopts[] = {
121         SR_CONF_POWER_SUPPLY,
122         SR_CONF_CONTINUOUS,
123         SR_CONF_OUTPUT_ENABLED | SR_CONF_GET | SR_CONF_SET,
124         SR_CONF_OUTPUT_VOLTAGE | SR_CONF_GET,
125         SR_CONF_OUTPUT_CURRENT | SR_CONF_GET,
126         SR_CONF_OUTPUT_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
127         SR_CONF_OUTPUT_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
128 };
129
130 struct channel_spec hp_6632b_ch[] = {
131         { "1", { 0, 20.475, 0.005 }, { 0, 5.1188, 0.00132 } },
132 };
133
134 struct channel_group_spec hp_6632b_cg[] = {
135         { "1", CH_IDX(0), 0 },
136 };
137
138 struct scpi_command hp_6632b_cmd[] = {
139         { SCPI_CMD_GET_OUTPUT_ENABLED, "OUTP:STAT?" },
140         { SCPI_CMD_SET_OUTPUT_ENABLE, "OUTP:STAT ON" },
141         { SCPI_CMD_SET_OUTPUT_DISABLE, "OUTP:STAT OFF" },
142         { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
143         { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
144         { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
145         { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
146         { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
147         { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
148 };
149
150
151 SR_PRIV const struct scpi_pps pps_profiles[] = {
152         /* HP 6632B */
153         { "HP", "6632B", 0,
154                 ARRAY_AND_SIZE(hp_6632b_devopts),
155                 ARRAY_AND_SIZE(devopts_none),
156                 ARRAY_AND_SIZE(hp_6632b_ch),
157                 ARRAY_AND_SIZE(hp_6632b_cg),
158                 ARRAY_AND_SIZE(hp_6632b_cmd),
159         },
160
161         /* Rigol DP800 series */
162         { "Rigol", "^DP831A$", PPS_OTP,
163                 ARRAY_AND_SIZE(rigol_dp800_devopts),
164                 ARRAY_AND_SIZE(rigol_dp800_devopts_cg),
165                 ARRAY_AND_SIZE(rigol_dp831_ch),
166                 ARRAY_AND_SIZE(rigol_dp800_cg),
167                 ARRAY_AND_SIZE(rigol_dp800_cmd),
168         },
169         { "Rigol", "^(DP832|DP832A)$", PPS_OTP,
170                 ARRAY_AND_SIZE(rigol_dp800_devopts),
171                 ARRAY_AND_SIZE(rigol_dp800_devopts_cg),
172                 ARRAY_AND_SIZE(rigol_dp832_ch),
173                 ARRAY_AND_SIZE(rigol_dp800_cg),
174                 ARRAY_AND_SIZE(rigol_dp800_cmd),
175         },
176 };
177 SR_PRIV unsigned int num_pps_profiles = ARRAY_SIZE(pps_profiles);
178