Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jun 10, 2021
1 parent 305c717 commit 8ad9356
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
56 changes: 30 additions & 26 deletions src/eez/modules/dib-dcp405/dib-dcp405.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct DcpChannel : public Channel {
bool delayed_dp_off;
uint32_t delayed_dp_off_start;
bool dpOn;
uint32_t dpNegMonitoringTimeMs;
uint32_t dpNegMonitoringTimeMs = 0;

float uSet = 0;
#if CONF_SURVIVE_MODE
Expand Down Expand Up @@ -317,28 +317,35 @@ struct DcpChannel : public Channel {
/// and that condition lasts more then DP_NEG_DELAY seconds (default 5 s),
/// down-programmer circuit has to be switched off.
uint32_t tickCountMs = millis();
if (u.mon_last * i.mon_last >= DP_NEG_LEV || tickCountMs < dpNegMonitoringTimeMs) {
dpNegMonitoringTimeMs = tickCountMs;
if (u.mon_last * i.mon_last >= DP_NEG_LEV) {
dpNegMonitoringTimeMs = 0;
} else {
if (tickCountMs - dpNegMonitoringTimeMs > DP_NEG_DELAY * 1000UL) {
if (dpOn) {
// DebugTrace("CH%d, neg. P, DP off: %f", channelIndex + 1, u.mon_last * i.mon_last);
dpNegMonitoringTimeMs = tickCountMs;
generateChannelError(SCPI_ERROR_CH1_DOWN_PROGRAMMER_SWITCHED_OFF, channelIndex);
setDpEnable(false);
} else {
// DebugTrace("CH%d, neg. P, output off: %f", channelIndex + 1, u.mon_last * i.mon_last);
generateChannelError(SCPI_ERROR_CH1_OUTPUT_FAULT_DETECTED, channelIndex);
channel_dispatcher::outputEnable(*this, false);
if (dpNegMonitoringTimeMs == 0) {
dpNegMonitoringTimeMs = tickCountMs;
if (dpNegMonitoringTimeMs == 0) {
dpNegMonitoringTimeMs = 1;
}
} else if (tickCountMs - dpNegMonitoringTimeMs > 500UL) {
if (dpOn && channelIndex < 2) {
if (channel_dispatcher::getCouplingType() == channel_dispatcher::COUPLING_TYPE_SERIES) {
psu::Channel &otherChannel = psu::Channel::get(channelIndex == 0 ? 1 : 0);
voltageBalancing(otherChannel);
} else if (channel_dispatcher::getCouplingType() == channel_dispatcher::COUPLING_TYPE_PARALLEL) {
psu::Channel &otherChannel = psu::Channel::get(channelIndex == 0 ? 1 : 0);
currentBalancing(otherChannel);
} else {
if (tickCountMs - dpNegMonitoringTimeMs > DP_NEG_DELAY * 1000UL) {
if (dpOn) {
// DebugTrace("CH%d, neg. P, DP off: %f", channelIndex + 1, u.mon_last * i.mon_last);
dpNegMonitoringTimeMs = 0;
setDprogState(DPROG_STATE_OFF);
generateChannelError(SCPI_ERROR_CH1_DOWN_PROGRAMMER_SWITCHED_OFF, channelIndex);
} else {
// DebugTrace("CH%d, neg. P, output off: %f", channelIndex + 1, u.mon_last * i.mon_last);
generateChannelError(SCPI_ERROR_CH1_OUTPUT_FAULT_DETECTED, channelIndex);
channel_dispatcher::outputEnable(*this, false);
}
} else if (tickCountMs - dpNegMonitoringTimeMs > 500UL) {
if (dpOn && channelIndex < 2) {
if (channel_dispatcher::getCouplingType() == channel_dispatcher::COUPLING_TYPE_SERIES) {
psu::Channel &otherChannel = psu::Channel::get(channelIndex == 0 ? 1 : 0);
voltageBalancing(otherChannel);
} else if (channel_dispatcher::getCouplingType() == channel_dispatcher::COUPLING_TYPE_PARALLEL) {
psu::Channel &otherChannel = psu::Channel::get(channelIndex == 0 ? 1 : 0);
currentBalancing(otherChannel);
}
}
}
}
Expand Down Expand Up @@ -496,10 +503,6 @@ struct DcpChannel : public Channel {

setOperBits(OPER_ISUM_DP_OFF, !enable);
dpOn = enable;

if (enable) {
dpNegMonitoringTimeMs = millis();
}
}

void setOutputEnable(bool enable, uint16_t tasks) override {
Expand Down Expand Up @@ -538,7 +541,6 @@ struct DcpChannel : public Channel {
if (tasks & OUTPUT_ENABLE_TASK_DP) {
if (flags.dprogState == DPROG_STATE_ON) {
// enable DP
dpNegMonitoringTimeMs = millis();
delayed_dp_off = false;
setDpEnable(true);
}
Expand All @@ -547,6 +549,8 @@ struct DcpChannel : public Channel {
if (tasks & OUTPUT_ENABLE_TASK_ADC_START) {
adc.start(ADC_DATA_TYPE_U_MON);
}

dpNegMonitoringTimeMs = 0;
} else {
// OVP
if (tasks & OUTPUT_ENABLE_TASK_OVP) {
Expand Down
2 changes: 1 addition & 1 deletion src/third_party/stm32_cubeide/bb3.launch
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="no_reset"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value="066CFF485754727567022108"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value="066EFF535353897167061432"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="disable"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fLaunchAttribute&quot;:&quot;monitor reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset&quot;],&quot;fCmdOptions&quot;:[]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]}}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.swv.swv_wait_for_sync" value="true"/>
Expand Down

0 comments on commit 8ad9356

Please sign in to comment.