PCIe-WDG-CSMA concept document Low-profile half-length PCI Express card that performs advanced Watchdog and Computer Status Monitoring functions. External Inputs - Dig In 0 - Dig In 1 - ISO In 0 - ISO In 1 - ISO In 2 - ISO In 3 Outputs - Relay - FET 0 - FET 1 - TTL 0 - TTL 1 - WDG RESET - BUZZER - RGB LED Input features: - inputs can be individually put in "debounced" or "raw" mode; all subsequent operations described act on the raw or debounced data - debounced mode has programmable time-constant per input - inputs can be read "live" or latched [high|low|both|triggered], counted edges [rising|falling|both] - inputs can trigger Actions when selected condition(s) are met: rising|falling edges, high|low level, count threshold exceeded Concept: - A list of "Events"; each can trigger "Actions" Events: - cold boot - warm boot caused by WDG - expected warm boot not caused by WDG - unexpected warm boot not caused by WDG - card warm reset - First Pet while not barking - Subsequent Pets - Growl [insufficient Pet frequency "warning"] - Bark [insufficient Pet frequency "alarm"] - First Pet after barking - input level high | low | rising | falling [for all input Causes, see note about 'debounce'] - counter overflow | underflow - counter high speed warning/alarm threshold exceeded - counter low speed warning/alarm threshold not met [missing pulse detector] - onboard 12V, 3.3V, ambient light, temperature, humidty: high/low warning/alarm thresholds and transitions - external temp warning/alarm transitions - 1 second tick Actions: - warm reset card - enable event counter(s) - reset event counter(s) - trigger input latches - assert output state - Output states[each output]: pulse [high|low][duration active][duration inactive][repeat count], level, inverted level, chirp, siren, .wav playback [_low_ max hz & short duration to reduce file-size] - increment counter[n] - decrement counter[n] - reload counter[n] - reset counter[n] Action Lists, Action Groups, or Action Scripts: - Actions can be grouped into "Action Lists" or "Action groups" or "scripts" which can be invoked as if they were themselves Actions. - Several Factory Preset Action Lists, and several "user defined" Action Lists are stored in EEPROM. [8 total? xxx bytes total?] - Factory Preset scripts cannot be modified by user - One Factory Preset script is "PCI-WDG-CSM mode" -------------------------------------------------------------- handle cold boot/warmboot/warmreset stuff message processing loop read all inputs read digital inputs and outputs into "raw" storage read analog into "live" storage debounce ["non-debounced" just has a debounce counter reload value of "1", so it always copies as soon as it notices a difference] if raw != live decrement debounce counter; if counter == 0, copy raw into live; reload debounce counter; determine which subset of events have occurred from list of non-null event handler pointers [determining if an event has occurred when no Action is pending wastes cpu time] determine set of Actions to fire as union of events-that-occurreds' handlers if more than one event that occurred has the same Action assigned, that action only occurs once Actions update "next_DO_data_raw" temporary state variables, not live hardware pins process PWM step update outputs to new values as calculated by Actions[in parallel, simultaneously, basically] loop PWM: A single "PWM timer" increments from 0 to 100%. Every PWM output with non-zero "number of pulses left to be generated" compares the counter to its "active duration" parameter, and if the PWM timer is less, the bit is set active; if the PWM timer is equal, the bit is set inactive and, if the pulse count isn't configured "forever" the pulse-count is decremented. struct { outputindex: byte; activeduration: word; n: word; // number of pulses left to be generated } PWM Counter: A set of 16-bit up/down counters each with optional auto-reload.