| edurant.com > MSOE > SEED > Final > Design Documentation: Control Blocks: Firmware |
The system firmware was written with version 3.10 of the Introl C cross-compiler (Appendix B: Acknowledgments for information about Introl). This greatly eased the use of the complicated data structures and procedure call chains required by this application.
The firmware was designed with extensibility in mind. Hooks have been implemented for several features that are not active in the prototype. Global variables, especially for the supply descriptors and data, were used to simplify variable passing in the upper routines, but most lower routines access this data through passed pointers, making them more generic.
The firmware functionality is broken into seven categories with minimal overlap. These are based on the tasks of the system.
Figure 11 shows the relations between all non-system functions. A brief discussion of each category and these functions then follows. Flowcharts of non-trivial functions are included in Appendix D: Firmware Flowcharts. A complete code listing is included in Appendix E: Firmware Code. Also, several of the Introl configuration files had to be modified to work with the 68F333 (see Appendix J: Microcontroller Specifications). These are included in Appendix F: Compiler Configuration.
Figure 11: Firmware Function Hierarchy

This routine sets the data direction registers, writes the keypad ISR vector, initializes the supply, display and alarm systems and goes into an endless loop. The endless loop toggles the COP, sets the master relay, updates the display, regulates the supplies and changes the system status to "off" when an error is detected.
The high level supply control functions maintain the supply data points and perform the regulation based on this data.
This function puts the supply control lines in a known state, links constant supply data to the main supply data structures and initializes all dynamic supply data (including set points, target point and voltage or current control selection).
This function steps through all supply modules, calling routines to update the set point, output the present set point, take and save voltage and current readings and check for errors.
This routine uses the system response parameters (threshold, inertia, and maximum dv/dt) to tune a supply.
This function returns the a voltage or current average for the requested supply and polarity of a supply.
This function initializes the history for the active control method (voltage or current) to indicate that the desired value has been reached. The history of the other parameter is initialized to 0. This makes the regulation routine believe that the supply has reached it's goal before it starts regulating and softens the response, mitigating glitches.
This routine inserts a new reading into the history data for a supply, discarding the oldest. This allows a moving average to be calculated.
This function asks the currently selected supply for the currently selected statistic (voltage or current).
This routine puts a 10-bit data word on the supply data output lines.
This function takes a supply and polarity and puts the appropriate address on the supply address lines.
This procedure goes through the startup procedure specified by the LCD display manufacturer. It also outputs the names of the supplies (which do not change) and the initial status line.
This routine prints the voltage and current values for all relevant polarities of all supplies on the display. It also updates the status line which shows:
This function outputs a string to the specified display location.
This routine outputs a string centered on the specified display line.
This clears the display.
This function strobes the specified display enable pin, affecting the corresponding display page. If a non-existent page is specified, both enable pins are strobbed.
This procedure fetches the keystroke when the keypad system generates an interrupt. If the key is a number or a decimal point, it is appended to the input buffer if there is room. It also updates the buffer if the "clear" or "backspace" key is pressed. Additionally, system state bits are toggled by the appropriate keys. If "enter" is pressed, the validate keypad entry routine is called.
This routine takes the keypad input (number and voltage or current selection) and updates the supply data accordingly.
This function will not be entered under normal operation. Its purpose is to handle special or unexpected keypad input.
Any function which needs to signal the computer operating properly system must call this routine. This function does nothing in the prototype.
This procedure sends the requested signal (on or off) to the master control relay.
This routine examines the data for the specified supply and modifies the system error object if necessary.
This routine zeros the output to the supply causing the error and prompts the user per the interface specification. Once the error is acknowledged, the set point is set to 0 and all history data is reinitialized to allow a "soft start up." Also, the display is re-initialized.
This function describes the error to the user based on the contents of the system error object.
This function returns the sign of its input.
This procedure delays for at least the given number of microseconds.
This routine takes a floating point value and generates the corresponding 10-bit target word based on the supply characteristics.