diff --git a/modular-psu-firmware.eez-project b/modular-psu-firmware.eez-project index 93b6809bd..ccb5f3bd0 100644 --- a/modular-psu-firmware.eez-project +++ b/modular-psu-firmware.eez-project @@ -32481,7 +32481,7 @@ }, { "type": "Container", - "left": 171, + "left": 173, "top": 2, "width": 134, "height": 33, @@ -72737,14 +72737,14 @@ } }, { - "name": "SENSe:CURRent[:DC]:NPLCycles", + "name": "SENSe:NPLCycles", "helpLink": "", "parameters": [ { "name": "cycles", "type": [ { - "type": "nr1" + "type": "nr3" } ], "isOptional": false @@ -72769,30 +72769,7 @@ } }, { - "name": "SENSe:CURRent[:DC]:NPLCycles?", - "helpLink": "", - "parameters": [ - { - "name": "channel", - "type": [ - { - "type": "discrete", - "enumeration": "Channel" - } - ], - "isOptional": true - } - ], - "response": { - "type": [ - { - "type": "numeric" - } - ] - } - }, - { - "name": "SENSe:CURRent[:DC]:APERture?", + "name": "SENSe:NPLCycles?", "helpLink": "", "parameters": [ { @@ -72809,53 +72786,20 @@ "response": { "type": [ { - "type": "numeric" - } - ] - } - }, - { - "name": "SENSe:VOLTage[:DC]:NPLCycles", - "helpLink": "", - "parameters": [ - { - "name": "cycles", - "type": [ - { - "type": "nr1" - } - ], - "isOptional": false - }, - { - "name": "channel", - "type": [ - { - "type": "discrete", - "enumeration": "Channel" - } - ], - "isOptional": true - } - ], - "response": { - "type": [ - { - "type": "numeric" + "type": "nr3" } ] } }, { - "name": "SENSe:VOLTage[:DC]:NPLCycles?", + "name": "SENSe:APERture", "helpLink": "", "parameters": [ { - "name": "channel", + "name": "aperture", "type": [ { - "type": "discrete", - "enumeration": "Channel" + "type": "nr3" } ], "isOptional": true @@ -72870,7 +72814,7 @@ } }, { - "name": "SENSe:VOLTage[:DC]:APERture?", + "name": "SENSe:APERture?", "helpLink": "", "parameters": [ { @@ -72887,7 +72831,7 @@ "response": { "type": [ { - "type": "numeric" + "type": "nr3" } ] } diff --git a/src/eez/gui/document_simulator.cpp b/src/eez/gui/document_simulator.cpp index 93a0e2ff3..2a4bd36c7 100644 --- a/src/eez/gui/document_simulator.cpp +++ b/src/eez/gui/document_simulator.cpp @@ -1343,7 +1343,7 @@ const uint8_t assets[626347] = { 0x03, 0x28, 0x00, 0x08, 0xA0, 0x00, 0x72, 0x48, 0x5D, 0x00, 0x00, 0x16, 0x00, 0xB5, 0x15, 0x00, 0x43, 0x00, 0xE0, 0x01, 0x76, 0x64, 0x05, 0x31, 0x04, 0x00, 0x75, 0x67, 0x05, 0x9F, 0x76, 0x00, 0xE0, 0x01, 0x78, 0x00, 0x01, 0x00, 0x54, 0x3C, 0x00, 0x00, 0x17, 0x5C, 0x14, 0x00, 0x04, 0x54, - 0x01, 0x17, 0x68, 0x14, 0x00, 0x04, 0x54, 0x01, 0x15, 0x74, 0x14, 0x00, 0xB5, 0xAB, 0x00, 0x02, + 0x01, 0x17, 0x68, 0x14, 0x00, 0x04, 0x54, 0x01, 0x15, 0x74, 0x14, 0x00, 0xB5, 0xAD, 0x00, 0x02, 0x00, 0x86, 0x00, 0x21, 0x00, 0xCC, 0x00, 0x80, 0x14, 0x00, 0x02, 0x3C, 0x00, 0x57, 0xEF, 0x00, 0x01, 0x00, 0x8C, 0x14, 0x00, 0x04, 0x3C, 0x00, 0x15, 0x98, 0x14, 0x00, 0x06, 0x28, 0x05, 0x15, 0xA4, 0x14, 0x00, 0x06, 0x28, 0x00, 0x71, 0xB0, 0x5D, 0x00, 0x00, 0x0F, 0x00, 0x9D, 0xB4, 0x00, diff --git a/src/eez/gui/document_stm32.cpp b/src/eez/gui/document_stm32.cpp index d866e32eb..1b41f0fa2 100644 --- a/src/eez/gui/document_stm32.cpp +++ b/src/eez/gui/document_stm32.cpp @@ -1320,7 +1320,7 @@ const uint8_t assets[387383] = { 0xD4, 0x59, 0x00, 0x00, 0x16, 0x00, 0xB5, 0x15, 0x00, 0x43, 0x00, 0xE0, 0x01, 0x76, 0x64, 0x05, 0x31, 0x04, 0x00, 0x75, 0x67, 0x05, 0x9F, 0x76, 0x00, 0xE0, 0x01, 0x78, 0x00, 0x01, 0x00, 0xE0, 0x3C, 0x00, 0x00, 0x17, 0xE8, 0x14, 0x00, 0x04, 0x54, 0x01, 0x17, 0xF4, 0x14, 0x00, 0x04, 0x54, - 0x01, 0x24, 0x00, 0x5A, 0xB8, 0x01, 0xB5, 0xAB, 0x00, 0x02, 0x00, 0x86, 0x00, 0x21, 0x00, 0xCC, + 0x01, 0x24, 0x00, 0x5A, 0xB8, 0x01, 0xB5, 0xAD, 0x00, 0x02, 0x00, 0x86, 0x00, 0x21, 0x00, 0xCC, 0x00, 0x0C, 0x14, 0x00, 0x02, 0x3C, 0x00, 0x57, 0xEF, 0x00, 0x01, 0x00, 0x18, 0x14, 0x00, 0x04, 0x3C, 0x00, 0x15, 0x24, 0x14, 0x00, 0x06, 0x28, 0x05, 0x15, 0x30, 0x14, 0x00, 0x06, 0x28, 0x00, 0x71, 0x3C, 0x5A, 0x00, 0x00, 0x0F, 0x00, 0x9D, 0xB4, 0x00, 0x04, 0xB4, 0x1A, 0x11, 0x48, 0x14, diff --git a/src/eez/index.cpp b/src/eez/index.cpp index b855c05db..e70e4ae6e 100644 --- a/src/eez/index.cpp +++ b/src/eez/index.cpp @@ -460,29 +460,29 @@ bool Module::setMeasureVoltageRange(int subchannelIndex, uint8_t range, int *err return false; } -bool Module::getMeasureCurrentNPLC(int subchannelIndex, float &nplc, int *err) { +bool Module::getMeasureNPLC(int subchannelIndex, float &nplc, int *err) { if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; } return false; } -bool Module::setMeasureCurrentNPLC(int subchannelIndex, float nplc, int *err) { +bool Module::setMeasureNPLC(int subchannelIndex, float nplc, int *err) { if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; } return false; } -bool Module::getMeasureVoltageNPLC(int subchannelIndex, float &nplc, int *err) { +bool Module::getMeasureAperture(int subchannelIndex, float &nplc, int *err) { if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; } return false; } -bool Module::setMeasureVoltageNPLC(int subchannelIndex, float nplc, int *err) { - if (err) { +bool Module::setMeasureAperture(int subchannelIndex, float nplc, int *err) { + if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; } return false; diff --git a/src/eez/index.h b/src/eez/index.h index 0fbbc0eb2..82d2e7f82 100644 --- a/src/eez/index.h +++ b/src/eez/index.h @@ -340,11 +340,10 @@ struct Module { virtual bool getMeasureVoltageRange(int subchannelIndex, uint8_t &range, int *err); virtual bool setMeasureVoltageRange(int subchannelIndex, uint8_t range, int *err); - virtual bool getMeasureCurrentNPLC(int subchannelIndex, float &nplc, int *err); - virtual bool setMeasureCurrentNPLC(int subchannelIndex, float nplc, int *err); - - virtual bool getMeasureVoltageNPLC(int subchannelIndex, float &nplc, int *err); - virtual bool setMeasureVoltageNPLC(int subchannelIndex, float nplc, int *err); + virtual bool getMeasureNPLC(int subchannelIndex, float &nplc, int *err); + virtual bool setMeasureNPLC(int subchannelIndex, float nplc, int *err); + virtual bool getMeasureAperture(int subchannelIndex, float &aperture, int *err); + virtual bool setMeasureAperture(int subchannelIndex, float aperture, int *err); virtual bool isRouteOpen(int subchannelIndex, bool &isRouteOpen, int *err); virtual bool routeOpen(ChannelList channelList, int *err); diff --git a/src/eez/modules/dib-dcm224/dib-dcm224.cpp b/src/eez/modules/dib-dcm224/dib-dcm224.cpp index bc68989bc..8815870f9 100644 --- a/src/eez/modules/dib-dcm224/dib-dcm224.cpp +++ b/src/eez/modules/dib-dcm224/dib-dcm224.cpp @@ -723,7 +723,7 @@ struct DcmModule : public PsuModule { return false; } - enabled = channel->pwmFrequency; + frequency = channel->pwmFrequency; return true; } @@ -758,7 +758,7 @@ struct DcmModule : public PsuModule { return false; } - enabled = channel->pwmDuty; + duty = channel->pwmDuty; return true; } diff --git a/src/eez/modules/dib-mio168/dib-mio168.cpp b/src/eez/modules/dib-mio168/dib-mio168.cpp index 33ceeac88..bd541a307 100644 --- a/src/eez/modules/dib-mio168/dib-mio168.cpp +++ b/src/eez/modules/dib-mio168/dib-mio168.cpp @@ -126,6 +126,8 @@ static const uint32_t REFRESH_TIME_MS = 249; static const uint32_t TIMEOUT_TIME_MS = 350; static const uint32_t TIMEOUT_UNTIL_OUT_OF_SYNC_MS = 10000; +static const float NPLC_PRECISION = 0.001f; + //////////////////////////////////////////////////////////////////////////////// enum Command { @@ -682,8 +684,7 @@ struct AinChannel { uint8_t m_voltageRange; public: - float m_currentNPLC = 1.0f; - float m_voltageNPLC = 1.0f; + float m_nplc = 1.0f; char m_label[CHANNEL_LABEL_MAX_LENGTH + 1]; @@ -772,8 +773,7 @@ struct AinChannel { uint8_t mode; uint8_t currentRange; uint8_t voltageRange; - float currentNPLC; - float voltageNPLC; + float nplc; char label[CHANNEL_LABEL_MAX_LENGTH + 1]; }; @@ -821,8 +821,7 @@ struct AinChannel { parameters.voltageRange = 0; } - parameters.currentNPLC = 5.0f; - parameters.voltageNPLC = 5.0f; + parameters.nplc = 5.0f; *parameters.label = 0; } @@ -830,8 +829,7 @@ struct AinChannel { parameters.mode = m_mode; parameters.currentRange = m_currentRange; parameters.voltageRange = m_voltageRange; - parameters.currentNPLC = m_currentNPLC; - parameters.voltageNPLC = m_voltageNPLC; + parameters.nplc = m_nplc; memcpy(parameters.label, m_label, sizeof(m_label)); } @@ -839,8 +837,7 @@ struct AinChannel { m_mode = parameters.mode; m_currentRange = parameters.currentRange; m_voltageRange = parameters.voltageRange; - m_currentNPLC = parameters.currentNPLC; - m_voltageNPLC = parameters.voltageNPLC; + m_nplc = parameters.nplc; memcpy(m_label, parameters.label, sizeof(m_label)); if (m_mode == MEASURE_MODE_VOLTAGE) { @@ -874,11 +871,8 @@ struct AinChannel { snprintf(propName, sizeof(propName), "ain_%d_voltageRange", i + 1); WRITE_PROPERTY(propName, parameters.voltageRange); - snprintf(propName, sizeof(propName), "ain_%d_currentNPLC", i + 1); - WRITE_PROPERTY(propName, parameters.currentNPLC); - - snprintf(propName, sizeof(propName), "ain_%d_voltageNPLC", i + 1); - WRITE_PROPERTY(propName, parameters.voltageNPLC); + snprintf(propName, sizeof(propName), "ain_%d_nplc", i + 1); + WRITE_PROPERTY(propName, parameters.nplc); snprintf(propName, sizeof(propName), "ain_%d_label", i+1); WRITE_PROPERTY(propName, parameters.label); @@ -898,11 +892,8 @@ struct AinChannel { snprintf(propName, sizeof(propName), "ain_%d_voltageRange", i + 1); READ_PROPERTY(propName, parameters.voltageRange); - snprintf(propName, sizeof(propName), "ain_%d_currentNPLC", i + 1); - READ_PROPERTY(propName, parameters.currentNPLC); - - snprintf(propName, sizeof(propName), "ain_%d_voltageNPLC", i + 1); - READ_PROPERTY(propName, parameters.voltageNPLC); + snprintf(propName, sizeof(propName), "ain_%d_nplc", i + 1); + READ_PROPERTY(propName, parameters.nplc); snprintf(propName, sizeof(propName), "ain_%d_label", i+1); READ_STRING_PROPERTY(propName, parameters.label, CHANNEL_LABEL_MAX_LENGTH); @@ -953,8 +944,7 @@ struct AinChannel { m_currentRange = 0; m_voltageRange = 0; } - m_currentNPLC = 5.0f; - m_voltageNPLC = 5.0f; + m_nplc = 5.0f; *m_label = 0; } @@ -2411,7 +2401,7 @@ struct Mio168Module : public Module { auto channel = &ainChannels[i]; params.ain[i].mode = channel->getMode(); params.ain[i].range = channel->getMode() == MEASURE_MODE_VOLTAGE ? channel->getVoltageRange() : channel->getCurrentRange(); - params.ain[i].nplc = channel->ongoingCal ? 25.0f : (channel->getMode() == MEASURE_MODE_VOLTAGE ? channel->m_voltageNPLC : channel->m_currentNPLC); + params.ain[i].nplc = channel->ongoingCal ? 25.0f : channel->m_nplc; int calConfIndex = channel->getCalConfIndex(0); for (int j = 0; j < 3; j++) { @@ -3976,18 +3966,18 @@ struct Mio168Module : public Module { return true; } - bool getMeasureCurrentNPLC(int subchannelIndex, float &nplc, int *err) override { + bool getMeasureNPLC(int subchannelIndex, float &nplc, int *err) override { if (subchannelIndex < AIN_1_SUBCHANNEL_INDEX || subchannelIndex > AIN_4_SUBCHANNEL_INDEX || isError(subchannelIndex - AIN_1_SUBCHANNEL_INDEX)) { if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; } return false; } - nplc = ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_currentNPLC; + nplc = ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_nplc; return true; } - bool setMeasureCurrentNPLC(int subchannelIndex, float nplc, int *err) override { + bool setMeasureNPLC(int subchannelIndex, float nplc, int *err) override { if (subchannelIndex < AIN_1_SUBCHANNEL_INDEX || subchannelIndex > AIN_4_SUBCHANNEL_INDEX || isError(subchannelIndex - AIN_1_SUBCHANNEL_INDEX)) { if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; @@ -4002,29 +3992,31 @@ struct Mio168Module : public Module { return false; } - ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_currentNPLC = nplc; + ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_nplc = roundPrec(nplc, NPLC_PRECISION); return true; } - bool getMeasureVoltageNPLC(int subchannelIndex, float &nplc, int *err) override { + bool getMeasureAperture(int subchannelIndex, float &aperture, int *err) override { if (subchannelIndex < AIN_1_SUBCHANNEL_INDEX || subchannelIndex > AIN_4_SUBCHANNEL_INDEX || isError(subchannelIndex - AIN_1_SUBCHANNEL_INDEX)) { if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; } return false; } - nplc = ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_voltageNPLC; + aperture = ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_nplc / persist_conf::getPowerLineFrequency(); return true; } - bool setMeasureVoltageNPLC(int subchannelIndex, float nplc, int *err) override { + bool setMeasureAperture(int subchannelIndex, float aperture, int *err) override { if (subchannelIndex < AIN_1_SUBCHANNEL_INDEX || subchannelIndex > AIN_4_SUBCHANNEL_INDEX || isError(subchannelIndex - AIN_1_SUBCHANNEL_INDEX)) { if (err) { *err = SCPI_ERROR_HARDWARE_MISSING; } return false; } + + float nplc = aperture * persist_conf::getPowerLineFrequency(); if (nplc < 0.0f || nplc > 25.0f) { if (err) { @@ -4033,7 +4025,7 @@ struct Mio168Module : public Module { return false; } - ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_voltageNPLC = nplc; + ainChannels[subchannelIndex - AIN_1_SUBCHANNEL_INDEX].m_nplc = roundPrec(nplc, NPLC_PRECISION); return true; } @@ -5171,6 +5163,54 @@ struct Mio168Module : public Module { return Module::getMaxTemperature(); } + + bool getSourcePwmFrequency(int subchannelIndex, float &frequency, int *err) override { + if (subchannelIndex >= PWM_1_SUBCHANNEL_INDEX && subchannelIndex <= PWM_2_SUBCHANNEL_INDEX) { + frequency = pwmChannels[subchannelIndex - PWM_1_SUBCHANNEL_INDEX].m_freq; + return true; + } + + return Module::getSourcePwmFrequency(subchannelIndex, frequency, err); + } + + bool setSourcePwmFrequency(int subchannelIndex, float frequency, int *err) override { + if (subchannelIndex >= PWM_1_SUBCHANNEL_INDEX && subchannelIndex <= PWM_2_SUBCHANNEL_INDEX) { + if (frequency < PWM_MIN_FREQUENCY || frequency > PWM_MAX_FREQUENCY) { + if (err) { + *err = SCPI_ERROR_ILLEGAL_PARAMETER_VALUE; + } + return false; + } + pwmChannels[subchannelIndex - PWM_1_SUBCHANNEL_INDEX].m_freq = frequency; + return true; + } + + return Module::setSourcePwmFrequency(subchannelIndex, frequency, err); + } + + bool getSourcePwmDuty(int subchannelIndex, float &duty, int *err) override { + if (subchannelIndex >= PWM_1_SUBCHANNEL_INDEX && subchannelIndex <= PWM_2_SUBCHANNEL_INDEX) { + duty = pwmChannels[subchannelIndex - PWM_1_SUBCHANNEL_INDEX].m_duty; + return true; + } + + return Module::getSourcePwmFrequency(subchannelIndex, duty, err); + } + + bool setSourcePwmDuty(int subchannelIndex, float duty, int *err) override { + if (subchannelIndex >= PWM_1_SUBCHANNEL_INDEX && subchannelIndex <= PWM_2_SUBCHANNEL_INDEX) { + if (duty < 0 || duty > 100.0f) { + if (err) { + *err = SCPI_ERROR_ILLEGAL_PARAMETER_VALUE; + } + return false; + } + pwmChannels[subchannelIndex - PWM_1_SUBCHANNEL_INDEX].m_duty = duty; + return true; + } + + return Module::setSourcePwmFrequency(subchannelIndex, duty, err); + } }; //////////////////////////////////////////////////////////////////////////////// @@ -5369,8 +5409,7 @@ class AinConfigurationPage : public SetPage { m_mode = m_modeOrig = channel.getMode(); m_currentRange = m_currentRangeOrig = channel.getCurrentRange(); m_voltageRange = m_voltageRangeOrig = channel.getVoltageRange(); - m_currentNPLC = m_currentNPLCOrig = channel.m_currentNPLC; - m_voltageNPLC = m_voltageNPLCOrig = channel.m_voltageNPLC; + m_nplc = m_nplcOrig = channel.m_nplc; } int getDirty() { @@ -5378,11 +5417,15 @@ class AinConfigurationPage : public SetPage { return true; } + if (m_nplc != m_nplcOrig) { + return true; + } + if (m_mode == MEASURE_MODE_VOLTAGE) { - return m_voltageRange != m_voltageRangeOrig || m_voltageNPLC != m_voltageNPLCOrig; + return m_voltageRange != m_voltageRangeOrig; } - return m_currentRange != m_currentRangeOrig || m_currentNPLC != m_currentNPLCOrig; + return m_currentRange != m_currentRangeOrig; } void set() { @@ -5502,8 +5545,7 @@ class AinConfigurationPage : public SetPage { uint8_t m_mode; uint8_t m_currentRange; uint8_t m_voltageRange; - float m_currentNPLC; - float m_voltageNPLC; + float m_nplc; static uint8_t getModeRange(int slotIndex, int subchannelIndex) { Mio168Module *module = (Mio168Module *)g_slots[slotIndex]; @@ -5616,8 +5658,7 @@ class AinConfigurationPage : public SetPage { uint8_t m_modeOrig; uint8_t m_currentRangeOrig; uint8_t m_voltageRangeOrig; - float m_currentNPLCOrig; - float m_voltageNPLCOrig; + float m_nplcOrig; }; int AinConfigurationPage::g_selectedChannelIndex; @@ -5823,11 +5864,10 @@ void Mio168Module::onHighPriorityThreadMessage(uint8_t type, uint32_t param) { channel.setMode((MeasureMode)g_ainConfigurationPage.m_mode); if (g_ainConfigurationPage.m_mode == MEASURE_MODE_VOLTAGE) { channel.setVoltageRange(g_ainConfigurationPage.m_voltageRange); - channel.m_voltageNPLC = g_ainConfigurationPage.m_voltageNPLC; } else { channel.setCurrentRange(g_ainConfigurationPage.m_currentRange); - channel.m_currentNPLC = g_ainConfigurationPage.m_currentNPLC; } + channel.m_nplc = g_ainConfigurationPage.m_nplc; } else if (type == PSU_MESSAGE_AOUT_DAC7760_CONFIGURE) { auto &channel = aoutDac7760Channels[AoutDac7760ConfigurationPage::g_selectedChannelIndex - AOUT_1_SUBCHANNEL_INDEX]; channel.m_outputEnabled = g_aoutDac7760ConfigurationPage.m_outputEnabled; @@ -6364,12 +6404,7 @@ void data_dib_mio168_ain_nplc(DataOperationEnum operation, Cursor cursor, Value } else if (focused && getActivePageId() == PAGE_ID_EDIT_MODE_KEYPAD && edit_mode_keypad::g_keypad->isEditing()) { data_keypad_text(operation, cursor, value); } else { - value = MakeValue( - g_ainConfigurationPage.m_mode == MEASURE_MODE_VOLTAGE ? - g_ainConfigurationPage.m_voltageNPLC : - g_ainConfigurationPage.m_currentNPLC, - UNIT_UNKNOWN - ); + value = MakeValue(g_ainConfigurationPage.m_nplc, UNIT_UNKNOWN); } } else if (operation == DATA_OPERATION_GET_MIN) { value = MakeValue(0.0f, UNIT_UNKNOWN); @@ -6396,22 +6431,13 @@ void data_dib_mio168_ain_nplc(DataOperationEnum operation, Cursor cursor, Value } else if (operation == DATA_OPERATION_SET_ENCODER_MODE) { edit_mode_step::g_mio168NplcEncoderMode = (EncoderMode)value.getInt(); } else if (operation == DATA_OPERATION_SET) { - if (g_ainConfigurationPage.m_mode == MEASURE_MODE_VOLTAGE) { - g_ainConfigurationPage.m_voltageNPLC = value.getFloat(); - } else { - g_ainConfigurationPage.m_currentNPLC = value.getFloat(); - } + g_ainConfigurationPage.m_nplc = roundPrec(value.getFloat(), NPLC_PRECISION); } } void data_dib_mio168_ain_aperture(DataOperationEnum operation, Cursor cursor, Value &value) { if (operation == DATA_OPERATION_GET) { - value = Value( - ( - g_ainConfigurationPage.m_mode == MEASURE_MODE_VOLTAGE ? - g_ainConfigurationPage.m_voltageNPLC : - g_ainConfigurationPage.m_currentNPLC - ) / persist_conf::getPowerLineFrequency(), UNIT_SECOND); + value = Value(g_ainConfigurationPage.m_nplc / persist_conf::getPowerLineFrequency(), UNIT_SECOND); } } diff --git a/src/eez/modules/psu/channel_dispatcher.cpp b/src/eez/modules/psu/channel_dispatcher.cpp index ac2cff67c..9b2c1c5c2 100644 --- a/src/eez/modules/psu/channel_dispatcher.cpp +++ b/src/eez/modules/psu/channel_dispatcher.cpp @@ -2381,20 +2381,20 @@ bool setMeasureVoltageRange(int slotIndex, int subchannelIndex, uint8_t range, i return g_slots[slotIndex]->setMeasureVoltageRange(subchannelIndex, range, err); } -bool getMeasureCurrentNPLC(int slotIndex, int subchannelIndex, float &nplc, int *err) { - return g_slots[slotIndex]->getMeasureCurrentNPLC(subchannelIndex, nplc, err); +bool getMeasureNPLC(int slotIndex, int subchannelIndex, float &nplc, int *err) { + return g_slots[slotIndex]->getMeasureNPLC(subchannelIndex, nplc, err); } -bool setMeasureCurrentNPLC(int slotIndex, int subchannelIndex, float nplc, int *err) { - return g_slots[slotIndex]->setMeasureCurrentNPLC(subchannelIndex, nplc, err); +bool setMeasureNPLC(int slotIndex, int subchannelIndex, float nplc, int *err) { + return g_slots[slotIndex]->setMeasureNPLC(subchannelIndex, nplc, err); } -bool getMeasureVoltageNPLC(int slotIndex, int subchannelIndex, float &nplc, int *err) { - return g_slots[slotIndex]->getMeasureVoltageNPLC(subchannelIndex, nplc, err); +bool getMeasureAperture(int slotIndex, int subchannelIndex, float &aperture, int *err) { + return g_slots[slotIndex]->getMeasureAperture(subchannelIndex, aperture, err); } -bool setMeasureVoltageNPLC(int slotIndex, int subchannelIndex, float nplc, int *err) { - return g_slots[slotIndex]->setMeasureVoltageNPLC(subchannelIndex, nplc, err); +bool setMeasureAperture(int slotIndex, int subchannelIndex, float aperture, int *err) { + return g_slots[slotIndex]->setMeasureAperture(subchannelIndex, aperture, err); } bool routeOpen(ChannelList channelList, int *err) { diff --git a/src/eez/modules/psu/channel_dispatcher.h b/src/eez/modules/psu/channel_dispatcher.h index 82d9af09b..978720241 100644 --- a/src/eez/modules/psu/channel_dispatcher.h +++ b/src/eez/modules/psu/channel_dispatcher.h @@ -225,11 +225,10 @@ bool setMeasureCurrentRange(int slotIndex, int subchannelIndex, uint8_t range, i bool getMeasureVoltageRange(int slotIndex, int subchannelIndex, uint8_t &range, int *err); bool setMeasureVoltageRange(int slotIndex, int subchannelIndex, uint8_t range, int *err); -bool getMeasureCurrentNPLC(int slotIndex, int subchannelIndex, float &nplc, int *err); -bool setMeasureCurrentNPLC(int slotIndex, int subchannelIndex, float nplc, int *err); - -bool getMeasureVoltageNPLC(int slotIndex, int subchannelIndex, float &nplc, int *err); -bool setMeasureVoltageNPLC(int slotIndex, int subchannelIndex, float nplc, int *err); +bool getMeasureNPLC(int slotIndex, int subchannelIndex, float &nplc, int *err); +bool setMeasureNPLC(int slotIndex, int subchannelIndex, float nplc, int *err); +bool getMeasureAperture(int slotIndex, int subchannelIndex, float &aperture, int *err); +bool setMeasureAperture(int slotIndex, int subchannelIndex, float aperture, int *err); bool isRouteOpen(int slotIndex, int subchannelIndex, int *err); bool routeOpen(ChannelList channelList, int *err); diff --git a/src/eez/modules/psu/scpi/sense.cpp b/src/eez/modules/psu/scpi/sense.cpp index 435264b47..42747f69b 100644 --- a/src/eez/modules/psu/scpi/sense.cpp +++ b/src/eez/modules/psu/scpi/sense.cpp @@ -224,7 +224,7 @@ scpi_result_t scpi_cmd_senseVoltageDcRangeQ(scpi_t *context) { return SCPI_RES_OK; } -scpi_result_t scpi_cmd_senseCurrentDcNplcycles(scpi_t *context) { +scpi_result_t scpi_cmd_senseNplcycles(scpi_t *context) { float nplc; if (!SCPI_ParamFloat(context, &nplc, true)) { return SCPI_RES_ERR; @@ -236,7 +236,7 @@ scpi_result_t scpi_cmd_senseCurrentDcNplcycles(scpi_t *context) { } int err; - if (!channel_dispatcher::setMeasureCurrentNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { + if (!channel_dispatcher::setMeasureNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { SCPI_ErrorPush(context, err); return SCPI_RES_ERR; } @@ -244,7 +244,7 @@ scpi_result_t scpi_cmd_senseCurrentDcNplcycles(scpi_t *context) { return SCPI_RES_OK; } -scpi_result_t scpi_cmd_senseCurrentDcNplcyclesQ(scpi_t *context) { +scpi_result_t scpi_cmd_senseNplcyclesQ(scpi_t *context) { SlotAndSubchannelIndex slotAndSubchannelIndex; if (!getChannelFromParam(context, slotAndSubchannelIndex)) { return SCPI_RES_ERR; @@ -252,7 +252,7 @@ scpi_result_t scpi_cmd_senseCurrentDcNplcyclesQ(scpi_t *context) { float nplc; int err; - if (!channel_dispatcher::getMeasureCurrentNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { + if (!channel_dispatcher::getMeasureNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { SCPI_ErrorPush(context, err); return SCPI_RES_ERR; } @@ -262,27 +262,9 @@ scpi_result_t scpi_cmd_senseCurrentDcNplcyclesQ(scpi_t *context) { return SCPI_RES_OK; } -scpi_result_t scpi_cmd_senseCurrentDcApertureQ(scpi_t *context) { - SlotAndSubchannelIndex slotAndSubchannelIndex; - if (!getChannelFromParam(context, slotAndSubchannelIndex)) { - return SCPI_RES_ERR; - } - - float nplc; - int err; - if (!channel_dispatcher::getMeasureCurrentNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { - SCPI_ErrorPush(context, err); - return SCPI_RES_ERR; - } - - SCPI_ResultFloat(context, nplc / persist_conf::getPowerLineFrequency()); - - return SCPI_RES_OK; -} - -scpi_result_t scpi_cmd_senseVoltageDcNplcycles(scpi_t *context) { - float nplc; - if (!SCPI_ParamFloat(context, &nplc, true)) { +scpi_result_t scpi_cmd_senseAperture(scpi_t *context) { + float aperture; + if (!SCPI_ParamFloat(context, &aperture, true)) { return SCPI_RES_ERR; } @@ -292,7 +274,7 @@ scpi_result_t scpi_cmd_senseVoltageDcNplcycles(scpi_t *context) { } int err; - if (!channel_dispatcher::setMeasureVoltageNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { + if (!channel_dispatcher::setMeasureAperture(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, aperture, &err)) { SCPI_ErrorPush(context, err); return SCPI_RES_ERR; } @@ -300,38 +282,20 @@ scpi_result_t scpi_cmd_senseVoltageDcNplcycles(scpi_t *context) { return SCPI_RES_OK; } -scpi_result_t scpi_cmd_senseVoltageDcNplcyclesQ(scpi_t *context) { +scpi_result_t scpi_cmd_senseApertureQ(scpi_t *context) { SlotAndSubchannelIndex slotAndSubchannelIndex; if (!getChannelFromParam(context, slotAndSubchannelIndex)) { return SCPI_RES_ERR; } - float nplc; - int err; - if (!channel_dispatcher::getMeasureVoltageNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { - SCPI_ErrorPush(context, err); - return SCPI_RES_ERR; - } - - SCPI_ResultUInt8(context, nplc); - - return SCPI_RES_OK; -} - -scpi_result_t scpi_cmd_senseVoltageDcApertureQ(scpi_t *context) { - SlotAndSubchannelIndex slotAndSubchannelIndex; - if (!getChannelFromParam(context, slotAndSubchannelIndex)) { - return SCPI_RES_ERR; - } - - float nplc; + float aperture; int err; - if (!channel_dispatcher::getMeasureVoltageNPLC(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, nplc, &err)) { + if (!channel_dispatcher::getMeasureAperture(slotAndSubchannelIndex.slotIndex, slotAndSubchannelIndex.subchannelIndex, aperture, &err)) { SCPI_ErrorPush(context, err); return SCPI_RES_ERR; } - SCPI_ResultFloat(context, nplc / persist_conf::getPowerLineFrequency()); + SCPI_ResultFloat(context, aperture); return SCPI_RES_OK; } diff --git a/src/eez/scpi/commands_simulator.h b/src/eez/scpi/commands_simulator.h index 4d56164b0..b6a003d13 100644 --- a/src/eez/scpi/commands_simulator.h +++ b/src/eez/scpi/commands_simulator.h @@ -150,12 +150,10 @@ SCPI_COMMAND("SENSe:CURRent[:DC]:RANGe?", scpi_cmd_senseCurrentDcRangeQ) \ SCPI_COMMAND("SENSe:VOLTage[:DC]:RANGe", scpi_cmd_senseVoltageDcRange) \ SCPI_COMMAND("SENSe:VOLTage[:DC]:RANGe?", scpi_cmd_senseVoltageDcRangeQ) \ - SCPI_COMMAND("SENSe:CURRent[:DC]:NPLCycles", scpi_cmd_senseCurrentDcNplcycles) \ - SCPI_COMMAND("SENSe:CURRent[:DC]:NPLCycles?", scpi_cmd_senseCurrentDcNplcyclesQ) \ - SCPI_COMMAND("SENSe:CURRent[:DC]:APERture?", scpi_cmd_senseCurrentDcApertureQ) \ - SCPI_COMMAND("SENSe:VOLTage[:DC]:NPLCycles", scpi_cmd_senseVoltageDcNplcycles) \ - SCPI_COMMAND("SENSe:VOLTage[:DC]:NPLCycles?", scpi_cmd_senseVoltageDcNplcyclesQ) \ - SCPI_COMMAND("SENSe:VOLTage[:DC]:APERture?", scpi_cmd_senseVoltageDcApertureQ) \ + SCPI_COMMAND("SENSe:NPLCycles", scpi_cmd_senseNplcycles) \ + SCPI_COMMAND("SENSe:NPLCycles?", scpi_cmd_senseNplcyclesQ) \ + SCPI_COMMAND("SENSe:APERture", scpi_cmd_senseAperture) \ + SCPI_COMMAND("SENSe:APERture?", scpi_cmd_senseApertureQ) \ SCPI_COMMAND("SENSe:DLOG:FUNCtion:CURRent", scpi_cmd_senseDlogFunctionCurrent) \ SCPI_COMMAND("SENSe:DLOG:FUNCtion:CURRent?", scpi_cmd_senseDlogFunctionCurrentQ) \ SCPI_COMMAND("SENSe:DLOG:FUNCtion:POWer", scpi_cmd_senseDlogFunctionPower) \ diff --git a/src/eez/scpi/commands_stm32.h b/src/eez/scpi/commands_stm32.h index 4d56164b0..b6a003d13 100644 --- a/src/eez/scpi/commands_stm32.h +++ b/src/eez/scpi/commands_stm32.h @@ -150,12 +150,10 @@ SCPI_COMMAND("SENSe:CURRent[:DC]:RANGe?", scpi_cmd_senseCurrentDcRangeQ) \ SCPI_COMMAND("SENSe:VOLTage[:DC]:RANGe", scpi_cmd_senseVoltageDcRange) \ SCPI_COMMAND("SENSe:VOLTage[:DC]:RANGe?", scpi_cmd_senseVoltageDcRangeQ) \ - SCPI_COMMAND("SENSe:CURRent[:DC]:NPLCycles", scpi_cmd_senseCurrentDcNplcycles) \ - SCPI_COMMAND("SENSe:CURRent[:DC]:NPLCycles?", scpi_cmd_senseCurrentDcNplcyclesQ) \ - SCPI_COMMAND("SENSe:CURRent[:DC]:APERture?", scpi_cmd_senseCurrentDcApertureQ) \ - SCPI_COMMAND("SENSe:VOLTage[:DC]:NPLCycles", scpi_cmd_senseVoltageDcNplcycles) \ - SCPI_COMMAND("SENSe:VOLTage[:DC]:NPLCycles?", scpi_cmd_senseVoltageDcNplcyclesQ) \ - SCPI_COMMAND("SENSe:VOLTage[:DC]:APERture?", scpi_cmd_senseVoltageDcApertureQ) \ + SCPI_COMMAND("SENSe:NPLCycles", scpi_cmd_senseNplcycles) \ + SCPI_COMMAND("SENSe:NPLCycles?", scpi_cmd_senseNplcyclesQ) \ + SCPI_COMMAND("SENSe:APERture", scpi_cmd_senseAperture) \ + SCPI_COMMAND("SENSe:APERture?", scpi_cmd_senseApertureQ) \ SCPI_COMMAND("SENSe:DLOG:FUNCtion:CURRent", scpi_cmd_senseDlogFunctionCurrent) \ SCPI_COMMAND("SENSe:DLOG:FUNCtion:CURRent?", scpi_cmd_senseDlogFunctionCurrentQ) \ SCPI_COMMAND("SENSe:DLOG:FUNCtion:POWer", scpi_cmd_senseDlogFunctionPower) \