summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:36:06 +0900
committerroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:36:06 +0900
commita26a57876a1c33b426e7ec080a29ea962a6d7924 (patch)
tree4475f9d91a8544f29e8782b00218dcc6a9a4fe86
parent5cb33d9fe5a65b681d1dbe131c9b1c6c0a2156ce (diff)
turn output off when switching attenuator ranges
-rw-r--r--device-functions.c25
-rw-r--r--globals.h2
2 files changed, 21 insertions, 6 deletions
diff --git a/device-functions.c b/device-functions.c
index f79017c..ac4a9b4 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -316,22 +316,37 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w
}
// Are attenuators used?
+ int atten_ctl = 0;
+
if (attenuator_count(channel) == 1) {
// deal with attenuator range - haven't done for CH2 yet
if (atten_range == 0) {
- set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, BIT_HIGH);
+ atten_ctl = BIT_HIGH;
} else {
- set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, BIT_LOW);
+ atten_ctl = BIT_LOW;
}
+
+ set_shiftreg_bits(SR_2, XTR_POS + 1, ONE_BIT, atten_ctl);
+
} else if (attenuator_count(channel) > 1) {
// octal relay driver is inverted
if ((atten_range < 0) || (atten_range >= max_attens)) {
- I2C_Write(PCF8574+Octal_Relay_Driver,0xff);
+ atten_ctl = 0xff;
} else {
- int atten_ctl = ~((1 << (atten_range+1)) - 1);
- I2C_Write(PCF8574+Octal_Relay_Driver, atten_ctl);
+ atten_ctl = ~((1 << (atten_range+1)) - 1);
+ }
+
+ I2C_Write(PCF8574+Octal_Relay_Driver, atten_ctl);
+ }
+
+ if ( (globals.Registers.last_relay_driver_settings[3] != atten_ctl)) {
+
+ globals.Registers.last_relay_driver_settings[3] = atten_ctl;
+
+ if (globals.ChannelState[channel].output_state==output_on) {
+ globals.Flags.force_output_fully_off=YES;
}
}
diff --git a/globals.h b/globals.h
index ac73e5d..fd8bb06 100644
--- a/globals.h
+++ b/globals.h
@@ -281,7 +281,7 @@ unsigned long long ms_timer (void);
typedef struct {
int parallel_DAC_reg[8];
long shift_reg_out[num_out_SRs];
- long last_relay_driver_settings[3];
+ long last_relay_driver_settings[4];
int oper_enable_register; /* for stat:enable command */
int ques_enable_register; /* for stat:enable command */
int avrq_reg;