diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2023-11-10 15:35:52 -0500 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2023-11-10 15:35:52 -0500 |
commit | 0a35518a74e55a03481fa20050ec20865bc35aea (patch) | |
tree | e25463c3f226d5b21c5708e22b582a1f95174fe7 /device-functions.c | |
parent | f6c4baf7a1d013ac7e72b8488be05611a6d0fb1b (diff) |
add an amplitude settling time for SN 14256 repair and future units
Diffstat (limited to 'device-functions.c')
-rw-r--r-- | device-functions.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/device-functions.c b/device-functions.c index 86cffec..9c79d5e 100644 --- a/device-functions.c +++ b/device-functions.c @@ -451,8 +451,11 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w debug_new_parameter (channel, parameter, requested_ampl); - globals.Changes.update_amp=YES; - globals.ChannelState[channel].amplitude=new_ampl; + globals.Changes.update_amp = YES; + if (globals.ChannelState[channel].amplitude != new_ampl) { + globals.ChannelState[channel].amplitude = new_ampl; + globals.Flags.need_ampl_settling_time = YES; + } Set_Update_Chans(); if (pwl_struct[parameter][channel].range!=old_range) { @@ -1551,7 +1554,8 @@ int Set_EA(int channel,int mode) if (globals.ChannelState[channel].amp_mode!=mode) { - globals.Changes.update_amp=YES; + globals.Changes.update_amp = YES; + globals.Flags.need_ampl_settling_time = YES; } globals.ChannelState[channel].amp_mode=mode; @@ -4755,13 +4759,27 @@ void Main_update_shift_registers() I2C_Write(PCF8574+Extra_DACs_Addr_Port, addr + 8); // latch into AD7839 } + + long sleep_us = 0; + /* keep trigger suppressed for a time (normally 0.5s) after a relay update */ if ( globals.Registers.last_relay_driver_settings[0]!=globals.Registers.shift_reg_out[2] || globals.Registers.last_relay_driver_settings[1]!=globals.Registers.shift_reg_out[3] || globals.Flags.force_output_fully_off==YES) { - g_usleep (1e3 * globals.Timers.Relay_Switching_Delay_in_Milliseconds); + sleep_us = 1e3 * globals.Timers.Relay_Switching_Delay_in_Milliseconds; + } + + /* amplitude settling time after a change */ + if (globals.Flags.need_ampl_settling_time = YES) { + sleep_us = MAX(sleep_us, 1e6 * globals.Flash.amplitude_settling_time); + } + + if ((sleep_us < 0) || (sleep_us > 10e6)) { + sleep_us = 0; } + /* relay change and/or ampl settling time */ + g_usleep (sleep_us); /* restore output if required */ if (globals.Flags.force_output_fully_off==YES) @@ -4783,6 +4801,7 @@ void Main_update_shift_registers() // reset update sensors globals.Changes.update_os = 0; globals.Changes.update_amp = 0; + globals.Flags.need_ampl_settling_time = 0; globals.Changes.update_zout = 0; globals.Changes.update_load = 0; |