rem AnalogOutput.bas rem rem last revision 19 January 2004 rem rem analog output has to be calibrated for exact output rem (tuning D2A_AOP1_LOW/HIGH) rem rem when the data source of analog output 1 equals D2A_AOP1_ZERO rem then ANALOG_OUTPUT1 equals D2A_AOP1_LOW (e.g. 4mA) rem when the data source of analog output 1 equals D2A_AOP1_FULL_SCALE rem then ANALOG_OUTPUT1 equals D2A_AOP1_HIGH (e.g. 20mA) rem rem ANALOG_OUTPUT1/2 are read-only registers! Customer_ID_Macro: write " Analog Output " END // keep calibration consistent with macro CONST ZERO = 0 CONST FULL = 100 // for 100 % MEM &D2A_AOP1_ZERO = ZERO MEM &D2A_AOP1_FULL_SCALE = FULL MEM &D2A_AOP2_ZERO = ZERO MEM &D2A_AOP2_FULL_SCALE = FULL Reset_Macro: #pump1 = ZERO #pump2 = ZERO // set data source for analog outputs MEM &DATA_SOURCE_ANALOG1 = addr(#pump1) MEM &DATA_SOURCE_ANALOG2 = addr(#pump2) END Main_Macro: if &CH1 < FULL then // current input is standard, so only one pump is needed #pump1 = &CH1 #pump2 = ZERO else // current input is high, so we need pump1 and add pump2 accordingly #pump1 = FULL if &CH1 < 2 * FULL then #pump2 = &CH1 - FULL else // we can only give as much as we have #pump2 = FULL endif endif END