diff options
-rw-r--r-- | bus.h | 6 | ||||
-rw-r--r-- | device-functions.c | 88 | ||||
-rw-r--r-- | device-functions.h | 2 | ||||
-rw-r--r-- | dummy_functions.c | 1 | ||||
-rw-r--r-- | dummy_functions.h | 1 |
5 files changed, 96 insertions, 2 deletions
@@ -17,6 +17,12 @@ #define OUTPUT_RELAY 4 /* output enable/disable relay */ #define PW_ENABLE 5 /* TTL enable/disable output */ +// A5, A6 used to select chips +#define Octal_DACportCS_low 0x00 +#define Octal_DACportCS_high 0x20 +#define TNT_Port 0x40 + + #define GPIOPIN0BASE 0 #define GPIOPIN1BASE 0 #define GPIOPIN2BASE 0 diff --git a/device-functions.c b/device-functions.c index 1b2a888..6a54241 100644 --- a/device-functions.c +++ b/device-functions.c @@ -4534,3 +4534,91 @@ void Set_Sav(int setting_num) return; } + + +void Main_update_shift_registers() +{ + /* send MSB first, LSB last */ + /* send highest # SR first */ + + int store_trigger_mode[max_channels]; + int i,j,n; /* counters */ + char data_out; + int temp_output_state[max_channels]; + + /* suppress triggering during relay switching */ + 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]) { + start_gate_override (); + } + + + /* physically turn off output for amplitude range changes */ + /* i.e., short output in 155's */ + if (globals.Flags.force_output_fully_off==YES) + for (i=0; i<(globals.Flash.ChanKey_frequency?globals.Flash.channels:1); ++i) { + temp_output_state[i]=globals.ChannelState[i].output_state; + Set_Output_State(i,output_off); + g_usleep (1e3 * globals.Timers.normal_relay_bounce_time_in_milliseconds); + } + + bus_setpin(out_CLOCK_LINE, 1); + bus_setpin(out_STROBE_LINE, 0); + + for (i=(num_out_SRs-1); i>=0; --i) { + switch (i) { + case 0: + case 1: + n=8; + break; + case 2: + case 3: + n=20; /* 20 bit shift registers - UCN5812s */ + break; + } + + for (j=n-1; j>=0; --j) { /* send MSB first, LSB last */ + bus_setpin(out_CLOCK_LINE, 0); + data_out = (char) (1 & (globals.Registers.shift_reg_out[i]>>j)); + bus_setpin(out_DATA_LINE, data_out); + bus_setpin(out_CLOCK_LINE, 1); + } + } + + bus_setpin(out_STROBE_LINE, 1); // latch the data + bus_setpin(out_STROBE_LINE, 0); // release latch + + for (i=0; i<8; ++i) { + /* load the upper-nibble latch */ + bus_writebyte ((uint8_t) (Octal_DACportCS_high), (uint8_t) (globals.Registers.parallel_DAC_reg[i] >> 8)); + + /* write lower byte (with address data), and force transfer of latched nibble */ + bus_writebyte ((uint8_t) (Octal_DACportCS_low + i), (uint8_t) (globals.Registers.parallel_DAC_reg[i] & 255)); + } + + /* keep trigger suppressed for a time (normally 5ms) 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); + } + + + /* restore output if required */ + if (globals.Flags.force_output_fully_off==YES) + for (i=0; i<(globals.Flash.ChanKey_frequency?globals.Flash.channels:1); ++i) { + Set_Output_State(i,temp_output_state[i]); + g_usleep (1e3 * globals.Timers.normal_relay_bounce_time_in_milliseconds); + globals.Flags.force_output_fully_off=NO; + } + + stop_gate_override (); + + globals.Timers.Relay_Switching_Delay_in_Milliseconds=globals.Timers.normal_relay_bounce_time_in_milliseconds; + /* restore default delay */ + + /* save relay data for comparision next time */ + 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]; +} + diff --git a/device-functions.h b/device-functions.h index cdc040c..27671e5 100644 --- a/device-functions.h +++ b/device-functions.h @@ -69,4 +69,6 @@ int I2C_Self_Cal(int channel, int meas_mode, float *meas, float target_time); void Set_Rcl(int setting_num); void Set_Sav(int setting_num); +void Main_update_shift_registers(); + #endif diff --git a/dummy_functions.c b/dummy_functions.c index 4760c0a..d7c46f4 100644 --- a/dummy_functions.c +++ b/dummy_functions.c @@ -32,6 +32,5 @@ void GPIB_set_ESE (unsigned int byte,int operation) {} void GPIB_clear_events () {} void GPIB_change_address(int new_address) {} -void Main_update_shift_registers() { } void Main_return_to_local() {} diff --git a/dummy_functions.h b/dummy_functions.h index 38e5542..0e9d300 100644 --- a/dummy_functions.h +++ b/dummy_functions.h @@ -19,7 +19,6 @@ void GPIB_set_ESE (unsigned int byte,int operation); void GPIB_clear_events (); void GPIB_change_address(int new_address); -void Main_update_shift_registers(); void Main_return_to_local(); #endif |