Skip to content

Commit

Permalink
#49
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Aug 28, 2020
1 parent 90a5502 commit b6832ae
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
33 changes: 29 additions & 4 deletions src/eez/modules/psu/channel_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,8 @@ bool testOutputEnable(Channel &channel, bool enable, bool &callTriggerAbort, int
callTriggerAbort = true;
}
} else {
if (isTripped(channel)) {
int channelIndex;
if (isTripped(channel, channelIndex)) {
if (err) {
*err = SCPI_ERROR_CANNOT_EXECUTE_BEFORE_CLEARING_PROTECTION;
}
Expand Down Expand Up @@ -1322,19 +1323,43 @@ void remoteSensingEnable(Channel &channel, bool enable) {
}
}

bool isTripped(Channel &channel) {
bool isTripped(Channel &channel, int &channelIndex) {
if (channel.channelIndex < 2 && (g_couplingType == COUPLING_TYPE_SERIES || g_couplingType == COUPLING_TYPE_PARALLEL)) {
return Channel::get(0).isTripped() || Channel::get(1).isTripped();
if (Channel::get(0).isTripped()) {
channelIndex = 0;
return true;
}
channelIndex = 1;
return Channel::get(1).isTripped();
} else if (channel.flags.trackingEnabled) {
for (int i = 0; i < CH_NUM; ++i) {
Channel &trackingChannel = Channel::get(i);
if (trackingChannel.flags.trackingEnabled && trackingChannel.isTripped()) {
channelIndex = i;
return true;
}
}
return false;
} else {
return channel.isTripped();
if (channel.isTripped()) {
channelIndex = channel.channelIndex;
return true;
}

bool triggerModeEnabled = getVoltageTriggerMode(channel) != TRIGGER_MODE_FIXED || getCurrentTriggerMode(channel) != TRIGGER_MODE_FIXED;
if (triggerModeEnabled) {
for (int i = 0; i < CH_NUM; ++i) {
if (i != channel.channelIndex) {
Channel &otherChannel = Channel::get(i);
bool triggerModeEnabled = getVoltageTriggerMode(otherChannel) != TRIGGER_MODE_FIXED || getCurrentTriggerMode(otherChannel) != TRIGGER_MODE_FIXED;
if (triggerModeEnabled && otherChannel.isTripped()) {
channelIndex = i;
return true;
}
}
}
}
return false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/eez/modules/psu/channel_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void disableOutputForAllTrackingChannels();

void remoteSensingEnable(Channel &channel, bool enable);

bool isTripped(Channel &channel);
bool isTripped(Channel &channel, int &channelIndex);
void clearProtection(Channel &channel);
void disableProtection(Channel &channel);

Expand Down
7 changes: 4 additions & 3 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,11 +1901,12 @@ void channelCalibrationsNo() {
void channelToggleOutput() {
selectChannelByCursor();
Channel &channel = *g_channel;
if (channel_dispatcher::isTripped(channel)) {
int channelIndex;
if (channel_dispatcher::isTripped(channel, channelIndex)) {
if (temperature::sensors[temp_sensor::AUX].isTripped()) {
errorMessageWithAction("AUX temp. sensor is tripped!", clearTrip, "Clear", channel.channelIndex);
errorMessageWithAction("AUX temp. sensor is tripped!", clearTrip, "Clear", channelIndex);
} else {
errorMessageWithAction("Channel is tripped!", clearTrip, "Clear", channel.channelIndex);
errorMessageWithAction("Channel is tripped!", clearTrip, "Clear", channelIndex);
}
} else {
if (!channel.isOutputEnabled() && !channel.isCalibrationExists()) {
Expand Down
3 changes: 2 additions & 1 deletion src/eez/modules/psu/list_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ void tick(uint32_t tick_usec) {
for (int i = 0; i < CH_NUM; ++i) {
Channel &channel = Channel::get(i);
if (g_execution[i].counter >= 0) {
if (channel_dispatcher::isTripped(channel)) {
int channelIndex;
if (channel_dispatcher::isTripped(channel, channelIndex)) {
setActive(false);
trigger::abort();
return;
Expand Down

0 comments on commit b6832ae

Please sign in to comment.