X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fscpi-pps%2Fprofiles.c;h=bd23cb94b66cabbf685caf10941f39d7b0d947b6;hb=a258204e00715c44b0d013ee3141ce890c8ea71c;hp=eea5666c555c1442693911daae6c09be3eadf9bd;hpb=ee2860ee110367d137559e0aaf91b2859e045968;p=libsigrok.git diff --git a/src/hardware/scpi-pps/profiles.c b/src/hardware/scpi-pps/profiles.c index eea5666c..bd23cb94 100644 --- a/src/hardware/scpi-pps/profiles.c +++ b/src/hardware/scpi-pps/profiles.c @@ -25,6 +25,7 @@ const char *pps_vendors[][2] = { { "RIGOL TECHNOLOGIES", "Rigol" }, { "HEWLETT-PACKARD", "HP" }, + { "PHILIPS", "Philips" }, }; const char *get_vendor(const char *raw_vendor) @@ -43,8 +44,6 @@ static const uint32_t devopts_none[] = { }; /* Rigol DP800 series */ static const uint32_t rigol_dp800_devopts[] = { - SR_CONF_POWER_SUPPLY, - SR_CONF_CONTINUOUS, SR_CONF_OVER_TEMPERATURE_PROTECTION | SR_CONF_GET | SR_CONF_SET, }; @@ -118,8 +117,6 @@ struct scpi_command rigol_dp800_cmd[] = { /* HP 663xx series */ static const uint32_t hp_6632b_devopts[] = { - SR_CONF_POWER_SUPPLY, - SR_CONF_CONTINUOUS, SR_CONF_OUTPUT_ENABLED | SR_CONF_GET | SR_CONF_SET, SR_CONF_OUTPUT_VOLTAGE | SR_CONF_GET, SR_CONF_OUTPUT_CURRENT | SR_CONF_GET, @@ -147,6 +144,148 @@ struct scpi_command hp_6632b_cmd[] = { { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" }, }; +/* Philips/Fluke PM2800 series */ +static const uint32_t philips_pm2800_devopts_cg[] = { + SR_CONF_OUTPUT_ENABLED | SR_CONF_GET | SR_CONF_SET, + SR_CONF_OUTPUT_VOLTAGE | SR_CONF_GET, + SR_CONF_OUTPUT_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_OUTPUT_CURRENT | SR_CONF_GET, + SR_CONF_OUTPUT_CURRENT_LIMIT | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE | SR_CONF_GET, + SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD | SR_CONF_GET | SR_CONF_SET, + SR_CONF_OVER_CURRENT_PROTECTION_ENABLED | SR_CONF_GET | SR_CONF_SET, + SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE | SR_CONF_GET, + SR_CONF_OUTPUT_REGULATION | SR_CONF_GET, +}; + +enum philips_pm2800_modules { + PM2800_MOD_30V_10A = 1, + PM2800_MOD_60V_5A, + PM2800_MOD_60V_10A, + PM2800_MOD_8V_15A, + PM2800_MOD_60V_2A, + PM2800_MOD_120V_1A, +}; + +static struct philips_pm2800_module_spec { + /* Min, max, programming resolution. */ + float voltage[3]; + float current[3]; +} philips_pm2800_module_specs[] = { + /* Autoranging modules. */ + [PM2800_MOD_30V_10A] = { { 0, 30, 0.0075 }, { 0, 10, 0.0025 } }, + [PM2800_MOD_60V_5A] = { { 0, 60, 0.015 }, { 0, 5, 0.00125 } }, + [PM2800_MOD_60V_10A] = { { 0, 60, 0.015 }, { 0, 10, 0.0025 } }, + /* Linear modules. */ + [PM2800_MOD_8V_15A] = { { 0, 8, 0.002 }, { -15, 15, 0.00375 } }, + [PM2800_MOD_60V_2A] = { { 0, 60, 0.015 }, { -2, 2, 0.0005 } }, + [PM2800_MOD_120V_1A] = { { 0, 120, 0.030 }, { -1, 1, 0.00025 } }, +}; + +static struct philips_pm2800_model { + unsigned int chassis; + unsigned int num_modules; + unsigned int set; + unsigned int modules[3]; +} philips_pm2800_matrix[] = { + /* Autoranging chassis. */ + { 1, 1, 0, { PM2800_MOD_30V_10A, 0, 0 } }, + { 1, 1, 1, { PM2800_MOD_60V_5A, 0, 0 } }, + { 1, 2, 0, { PM2800_MOD_30V_10A, PM2800_MOD_30V_10A, 0 } }, + { 1, 2, 1, { PM2800_MOD_60V_5A, PM2800_MOD_60V_5A, 0 } }, + { 1, 2, 2, { PM2800_MOD_30V_10A, PM2800_MOD_60V_5A, 0 } }, + { 1, 2, 3, { PM2800_MOD_30V_10A, PM2800_MOD_60V_10A, 0 } }, + { 1, 2, 4, { PM2800_MOD_60V_5A, PM2800_MOD_60V_10A, 0 } }, + { 1, 3, 0, { PM2800_MOD_30V_10A, PM2800_MOD_30V_10A, PM2800_MOD_30V_10A } }, + { 1, 3, 1, { PM2800_MOD_60V_5A, PM2800_MOD_60V_5A, PM2800_MOD_60V_5A } }, + { 1, 3, 2, { PM2800_MOD_30V_10A, PM2800_MOD_30V_10A, PM2800_MOD_60V_5A } }, + { 1, 3, 3, { PM2800_MOD_30V_10A, PM2800_MOD_60V_5A, PM2800_MOD_60V_5A } }, + /* Linear chassis. */ + { 3, 1, 0, { PM2800_MOD_60V_2A, 0, 0 } }, + { 3, 1, 1, { PM2800_MOD_120V_1A, 0, 0 } }, + { 3, 1, 2, { PM2800_MOD_8V_15A, 0, 0 } }, + { 3, 2, 0, { PM2800_MOD_60V_2A, 0, 0 } }, + { 3, 2, 1, { PM2800_MOD_120V_1A, 0, 0 } }, + { 3, 2, 2, { PM2800_MOD_60V_2A, PM2800_MOD_120V_1A, 0 } }, + { 3, 2, 3, { PM2800_MOD_8V_15A, PM2800_MOD_8V_15A, 0 } }, +}; + +static char *philips_pm2800_names[] = { "1", "2", "3" }; + +static int philips_pm2800_probe_channels(struct sr_dev_inst *sdi, + struct sr_scpi_hw_info *hw_info, + struct channel_spec **channels, unsigned int *num_channels, + struct channel_group_spec **channel_groups, unsigned int *num_channel_groups) +{ + struct philips_pm2800_model *model; + struct philips_pm2800_module_spec *spec; + unsigned int chassis, num_modules, set, module, m, i; + + (void)sdi; + + /* + * The model number as reported by *IDN? looks like e.g. PM2813/11, + * Where "PM28" is fixed, followed by the chassis code (1 = autoranging, + * 3 = linear series) and the number of modules: 1-3 for autoranging, + * 1-2 for linear. + * After the slash, the first digit denotes the module set. The + * digit after that denotes front (5) or rear (1) binding posts. + */ + chassis = hw_info->model[4] - 0x30; + num_modules = hw_info->model[5] - 0x30; + set = hw_info->model[7] - 0x30; + for (m = 0; m < ARRAY_SIZE(philips_pm2800_matrix); m++) { + model = &philips_pm2800_matrix[m]; + if (model->chassis == chassis && model->num_modules == num_modules + && model->set == set) + break; + } + if (m == ARRAY_SIZE(philips_pm2800_matrix)) { + sr_dbg("Model %s not found in matrix.", hw_info->model); + return SR_ERR; + } + + sr_dbg("Found %d output channel%s:", num_modules, num_modules > 1 ? "s" : ""); + *channels = g_malloc0(sizeof(struct channel_spec) * num_modules); + *channel_groups = g_malloc0(sizeof(struct channel_group_spec) * num_modules); + for (i = 0; i < num_modules; i++) { + module = model->modules[i]; + spec = &philips_pm2800_module_specs[module]; + sr_dbg("output %d: %.0f - %.0fV, %.0f - %.0fA", i + 1, + spec->voltage[0], spec->voltage[1], + spec->current[0], spec->current[1]); + (*channels)[i].name = philips_pm2800_names[i]; + memcpy(&((*channels)[i].voltage), spec, sizeof(float) * 6); + (*channel_groups)[i].name = philips_pm2800_names[i]; + (*channel_groups)[i].channel_index_mask = 1 << i; + (*channel_groups)[i].features = PPS_OTP | PPS_OVP | PPS_OCP; + } + *num_channels = *num_channel_groups = num_modules; + + return SR_OK; +} + +struct scpi_command philips_pm2800_cmd[] = { + { SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" }, + { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" }, + { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" }, + { SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" }, + { SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" }, + { SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" }, + { SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" }, + { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" }, + { SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" }, + { SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" }, + { SCPI_CMD_GET_OUTPUT_REGULATION, ":SOUR:FUNC:MODE?" }, + { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":SOUR:VOLT:PROT:TRIP?" }, + { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT:LEV?" }, + { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":SOUR:VOLT:PROT:LEV %.6f" }, + { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":SOUR:CURR:PROT:STAT?" }, + { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":SOUR:CURR:PROT:STAT ON" }, + { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":SOUR:CURR:PROT:STAT OFF" }, + { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":SOUR:CURR:PROT:TRIP?" }, +}; + SR_PRIV const struct scpi_pps pps_profiles[] = { /* HP 6632B */ @@ -156,6 +295,7 @@ SR_PRIV const struct scpi_pps pps_profiles[] = { ARRAY_AND_SIZE(hp_6632b_ch), ARRAY_AND_SIZE(hp_6632b_cg), ARRAY_AND_SIZE(hp_6632b_cmd), + .probe_channels = NULL, }, /* Rigol DP800 series */ @@ -165,6 +305,7 @@ SR_PRIV const struct scpi_pps pps_profiles[] = { ARRAY_AND_SIZE(rigol_dp831_ch), ARRAY_AND_SIZE(rigol_dp800_cg), ARRAY_AND_SIZE(rigol_dp800_cmd), + .probe_channels = NULL, }, { "Rigol", "^(DP832|DP832A)$", PPS_OTP, ARRAY_AND_SIZE(rigol_dp800_devopts), @@ -172,6 +313,17 @@ SR_PRIV const struct scpi_pps pps_profiles[] = { ARRAY_AND_SIZE(rigol_dp832_ch), ARRAY_AND_SIZE(rigol_dp800_cg), ARRAY_AND_SIZE(rigol_dp800_cmd), + .probe_channels = NULL, + }, + + /* Philips/Fluke PM2800 series */ + { "Philips", "^PM28[13][123]/[01234]{1,2}$", 0, + ARRAY_AND_SIZE(devopts_none), + ARRAY_AND_SIZE(philips_pm2800_devopts_cg), + NULL, 0, + NULL, 0, + ARRAY_AND_SIZE(philips_pm2800_cmd), + philips_pm2800_probe_channels, }, }; SR_PRIV unsigned int num_pps_profiles = ARRAY_SIZE(pps_profiles);