Skip to content

Commit 8583eef

Browse files
committed
1 parent da71ef1 commit 8583eef

File tree

10 files changed

+87
-4
lines changed

10 files changed

+87
-4
lines changed

src/eez/modules/dib-dcm220/dib-dcm220.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ struct DcmChannel : public Channel {
8888
float iSet;
8989
#endif
9090

91+
uint16_t uMonAdc = 0;
92+
uint16_t iMonAdc = 0;
93+
9194
float temperature = 25.0f;
9295

9396
float I_MAX_FOR_REMAP;
@@ -362,6 +365,22 @@ struct DcmChannel : public Channel {
362365
return NAN;
363366
#endif
364367
}
368+
369+
void dumpDebugVariables(scpi_t *context) override {
370+
char buffer[100];
371+
372+
snprintf(buffer, sizeof(buffer), "CH%d U_DAC = %d", channelIndex + 1, (int)uSet);
373+
SCPI_ResultText(context, buffer);
374+
375+
snprintf(buffer, sizeof(buffer), "CH%d U_MON = %d", channelIndex + 1, (int)uMonAdc);
376+
SCPI_ResultText(context, buffer);
377+
378+
snprintf(buffer, sizeof(buffer), "CH%d I_DAC = %d", channelIndex + 1, (int)iSet);
379+
SCPI_ResultText(context, buffer);
380+
381+
snprintf(buffer, sizeof(buffer), "CH%d I_MON = %d", channelIndex + 1, (int)iMonAdc);
382+
SCPI_ResultText(context, buffer);
383+
}
365384
};
366385

367386
struct DcmModule : public PsuModule {
@@ -546,10 +565,12 @@ struct DcmModule : public PsuModule {
546565
channel.ccMode = (input[0] & (subchannelIndex == 0 ? REG0_CC1_MASK : REG0_CC2_MASK)) != 0;
547566

548567
uint16_t uMonAdc = inputSetValues[offset];
568+
channel.uMonAdc = uMonAdc;
549569
float uMon = remap(uMonAdc, (float)ADC_MIN, 0, (float)ADC_MAX, channel.params.U_MAX);
550570
channel.onAdcData(ADC_DATA_TYPE_U_MON, uMon);
551571

552572
uint16_t iMonAdc = inputSetValues[offset + 1];
573+
channel.iMonAdc = iMonAdc;
553574
const float FULL_SCALE = 2.0F;
554575
const float U_REF = 2.5F;
555576
float iMon = remap(iMonAdc, (float)ADC_MIN, 0, FULL_SCALE * ADC_MAX / U_REF, /*params.I_MAX*/ channel.I_MAX_FOR_REMAP);

src/eez/modules/dib-dcm224/dib-dcm224.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ struct DcmChannel : public Channel {
119119
float iSet;
120120
#endif
121121

122+
uint16_t uMonAdc = 0;
123+
uint16_t iMonAdc = 0;
124+
122125
float temperature = 25.0f;
123126

124127
float I_MAX_FOR_REMAP;
@@ -447,6 +450,22 @@ struct DcmChannel : public Channel {
447450
}
448451
}
449452
}
453+
454+
void dumpDebugVariables(scpi_t *context) override {
455+
char buffer[100];
456+
457+
snprintf(buffer, sizeof(buffer), "CH%d U_DAC = %d", channelIndex + 1, (int)uSet);
458+
SCPI_ResultText(context, buffer);
459+
460+
snprintf(buffer, sizeof(buffer), "CH%d U_MON = %d", channelIndex + 1, (int)uMonAdc);
461+
SCPI_ResultText(context, buffer);
462+
463+
snprintf(buffer, sizeof(buffer), "CH%d I_DAC = %d", channelIndex + 1, (int)iSet);
464+
SCPI_ResultText(context, buffer);
465+
466+
snprintf(buffer, sizeof(buffer), "CH%d I_MON = %d", channelIndex + 1, (int)iMonAdc);
467+
SCPI_ResultText(context, buffer);
468+
}
450469
};
451470

452471
static const float DEFAULT_COUNTERPHASE_FREQUENCY = 500000.0f;
@@ -1066,10 +1085,12 @@ void DcmModule::tick(uint8_t slotIndex) {
10661085
channel.ccMode = (input[0] & (subchannelIndex == 0 ? REG0_CC1_MASK : REG0_CC2_MASK)) != 0;
10671086

10681087
uint16_t uMonAdc = inputSetValues[offset];
1088+
channel.uMonAdc = uMonAdc;
10691089
float uMon = remap(uMonAdc, (float)ADC_MIN, 0, (float)ADC_MAX, channel.params.U_MAX);
10701090
channel.onAdcData(ADC_DATA_TYPE_U_MON, uMon);
10711091

10721092
uint16_t iMonAdc = inputSetValues[offset + 1];
1093+
channel.iMonAdc = iMonAdc;
10731094
const float FULL_SCALE = 2.0F;
10741095
const float U_REF = 2.5F;
10751096
float iMon = remap(iMonAdc, (float)ADC_MIN, 0, FULL_SCALE * ADC_MAX / U_REF, /*params.I_MAX*/ channel.I_MAX_FOR_REMAP);

src/eez/modules/dib-dcp405/adc.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,10 @@ float AnalogDigitalConverter::read() {
342342
channel.i.mon_adc = value;
343343
} else if (adcDataType == ADC_DATA_TYPE_U_MON_DAC) {
344344
value = remapAdcDataToVoltage(channel, adcDataType, adcValue);
345+
m_uLastMonDac = adcValue;
345346
} else {
346347
value = remapAdcDataToCurrent(channel, adcDataType, adcValue);
348+
m_iLastMonDac = adcValue;
347349
}
348350

349351
return value;

src/eez/modules/dib-dcp405/adc.h

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class AnalogDigitalConverter {
3737

3838
AdcDataType adcDataType;
3939

40+
int16_t m_uLastMonDac;
41+
int16_t m_iLastMonDac;
42+
4043
void init();
4144
bool test();
4245

src/eez/modules/dib-dcp405/dac.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ void DigitalAnalogConverter::set(uint8_t buffer, uint16_t value, RampOption ramp
244244
if (rampOption != FROM_RAMP) {
245245
m_uIsRampActive = false;
246246
}
247+
248+
m_uLastValue = value;
247249
}
248250
else {
249251
if (
@@ -262,6 +264,8 @@ void DigitalAnalogConverter::set(uint8_t buffer, uint16_t value, RampOption ramp
262264
if (rampOption != FROM_RAMP) {
263265
m_iIsRampActive = false;
264266
}
267+
268+
m_iLastValue = value;
265269
}
266270

267271
uint8_t data[3];

src/eez/modules/dib-dcp405/dac.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class DigitalAnalogConverter {
3434
uint8_t channelIndex;
3535
TestResult testResult;
3636

37+
uint16_t m_uLastValue;
38+
uint16_t m_iLastValue;
39+
3740
void init();
3841
bool test(IOExpander &ioexp, AnalogDigitalConverter &adc);
3942

src/eez/modules/dib-dcp405/dib-dcp405.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <new>
2020
#include <assert.h>
21+
#include <string.h>
22+
#include <stdio.h>
2123

2224
#include <eez/modules/dib-dcp405/dib-dcp405.h>
2325
#include <eez/modules/dib-dcp405/adc.h>
@@ -970,6 +972,28 @@ struct DcpChannel : public Channel {
970972
int getAdvancedOptionsPageId() override {
971973
return eez::gui::PAGE_ID_CH_SETTINGS_ADV_OPTIONS;
972974
}
975+
976+
void dumpDebugVariables(scpi_t *context) override {
977+
char buffer[100];
978+
979+
snprintf(buffer, sizeof(buffer), "CH%d U_DAC = %d", channelIndex + 1, (int)dac.m_uLastValue);
980+
SCPI_ResultText(context, buffer);
981+
982+
snprintf(buffer, sizeof(buffer), "CH%d U_MON = %d", channelIndex + 1, (int)u.mon_adc);
983+
SCPI_ResultText(context, buffer);
984+
985+
snprintf(buffer, sizeof(buffer), "CH%d U_MON_DAC = %d", channelIndex + 1, (int)adc.m_uLastMonDac);
986+
SCPI_ResultText(context, buffer);
987+
988+
snprintf(buffer, sizeof(buffer), "CH%d I_DAC = %d", channelIndex + 1, (int)dac.m_iLastValue);
989+
SCPI_ResultText(context, buffer);
990+
991+
snprintf(buffer, sizeof(buffer), "CH%d I_MON = %d", channelIndex + 1, (int)i.mon_adc);
992+
SCPI_ResultText(context, buffer);
993+
994+
snprintf(buffer, sizeof(buffer), "CH%d I_MON_DAC = %d", channelIndex + 1, (int)adc.m_iLastMonDac);
995+
SCPI_ResultText(context, buffer);
996+
}
973997
};
974998

975999
struct DcpModule : public PsuModule {

src/eez/modules/psu/calibration.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void Value::setDacValue(float value) {
114114
channel_dispatcher::setVoltage(*channel, channel->params.I_CAL_U_SET);
115115
} else {
116116
// prevent false power fault detection (#275)
117-
channel_dispatcher::setCurrent(*channel, 0.015);
117+
channel_dispatcher::setCurrent(*channel, 0.015f);
118118
channel_dispatcher::setVoltage(*channel, channel->params.I_LOW_RANGE_CAL_U_SET);
119119
osDelay(3);
120120
channel_dispatcher::setCurrent(*channel, value);

src/eez/modules/psu/channel.h

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <eez/modules/psu/persist_conf.h>
2525
#include <eez/modules/psu/temp_sensor.h>
2626

27+
#include <scpi/types.h>
28+
2729
#define IS_OVP_VALUE(channel, cpv) (&cpv == &channel->ovp)
2830
#define IS_OCP_VALUE(channel, cpv) (&cpv == &channel->ocp)
2931
#define IS_OPP_VALUE(channel, cpv) (&cpv == &channel->opp)
@@ -706,6 +708,8 @@ struct Channel {
706708
const char *getDefaultLabel();
707709
const char *getLabelOrDefault() { return *label ? label : getDefaultLabel(); }
708710

711+
virtual void dumpDebugVariables(scpi_t *context) = 0;
712+
709713
//
710714
//
711715
//

src/eez/modules/psu/scpi/debug.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ scpi_result_t scpi_cmd_debugQ(scpi_t *context) {
188188
}
189189
}
190190

191-
static char buffer[2048];
192-
193191
#ifndef __EMSCRIPTEN__
194192
for (int i = 0; i < CH_NUM; i++) {
195193
if (!measureAllAdcValuesOnChannel(i)) {
@@ -199,7 +197,10 @@ scpi_result_t scpi_cmd_debugQ(scpi_t *context) {
199197
}
200198
#endif
201199

202-
SCPI_ResultCharacters(context, buffer, strlen(buffer));
200+
for (int i = 0; i < CH_NUM; i++) {
201+
Channel &channel = Channel::get(i);
202+
channel.dumpDebugVariables(context);
203+
}
203204

204205
return SCPI_RES_OK;
205206
#else

0 commit comments

Comments
 (0)