Campbell Manufacturing SDM-SW8A Switch User Manual


 
Appendix A. Program Example
The Edlog program is an example only and is not meant to be used verbatim.
In application, the concepts illustrated here are likely to be only fragments of a
larger program.
The example program reads all 8 ports of an SW8A which is set to address 00.
It is read three times per scan, once each for State, Duty Cycle, and Count
information. The scan rate is fixed at 1 second, with a 5 minute output of
State, average Duty Cycle, and average Count.
To prevent erroneous values from being included in Output Processing
routines, the datalogger's Intermediate Processing Disable Flag (Flag 9) is set
under the following two conditions.
1. When the SW8A is not responding - If the processor is not responding, a
value of -99999 is detected in the first Location containing SW8A data, and
Flag 9 is set high. The SW8A is accessed a second time to increment the
watchdog counter to greater than 64 and force a watchdog reset (refer to
Section 7.3). A RESET COUNTER (input location 25, RESET CNT) is
incremented and output with time to create a record of when and how many
times the SW8A has been reset since the last datalogger compilation.
2. When the current scan is the first scan after compiling the datalogger
program - If the datalogger program is compiled in the *0 Mode, all Flags are
set low following compilation. To detect the first scan after the datalogger is
compiled, the state of user Flag 1 is checked. If Flag 1 is low the Intermediate
Disable Flag (Flag 9) is set high to prevent the first readings from being
included in subsequent Output Processing Instructions. Flag 1 is set high at the
end of the first scan.
A flow chart of the example program is presented in Figure A-1.
A-1