Skip to content

Commit

Permalink
#74
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 19, 2020
1 parent 2593f51 commit 4be53be
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/eez/modules/dib-dcp405/dib-dcp405.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,16 @@ struct DcpChannel : public Channel {
}
}

bool shouldDisableDP() {
// disable DP if low current range and current of 10 mA or less is set
return flags.currentCurrentRange == 1 && i.set <= 10E-3f;
}

void setDpEnable(bool enable) {
if (enable && shouldDisableDP()) {
return;
}

// DP bit is active low
ioexp.changeBit(IOExpander::IO_BIT_OUT_DP_ENABLE, !enable);

Expand Down Expand Up @@ -651,6 +660,18 @@ struct DcpChannel : public Channel {
}

void setDacCurrentFloat(float value) override {
if (isOk() && ioexp.testBit(IOExpander::IO_BIT_OUT_OUTPUT_ENABLE) && flags.dprogState == DPROG_STATE_ON) {
if (dpOn) {
if (shouldDisableDP()) {
setDpEnable(false);
}
} else {
if (!shouldDisableDP()) {
setDpEnable(true);
}
}
}

dac.setCurrent(value);
iBeforeBalancing = NAN;
restoreVoltageToValueBeforeBalancing(*this);
Expand Down

0 comments on commit 4be53be

Please sign in to comment.