Software for the electronics is often 50% or more of
the design work. The programming that controls the microprocessors gives the
electronic product its features and characteristics.
The programming or coding for electronic products is
more detailed than the type of programming made for a personal computer,
because it is more tightly coupled to the electronic hardware on which it
runs, and because it usually has to respond more quickly - that is it has to
run in "real time".
The firmware may be developed by a separate team, and
it is at the prototype stage that the two projects come together. When the two
components are integrated and prototype testing is complete, the finished
project is handed over to the customer.
The major steps in Firmware design are:
Program Specification
Program Design
Writing code
Program Test
The specification for the Electronic Product being designed will usually also be the specification for the programming required. There is a lot of overlap between the hardware and software components, and it is often easier to specify the two together. In some instances a designer will trade off hardware against software, and so reduce the cost of the final product by implementing a function as code instead of in components.
The program specification will require the writer to go into substantial detail about how the product actually operates, and how it is used. To design a good user interface (if interaction with an operator is required by the product) requires a thorough knowledge of the products operation, and substantial experience with existing products, controls and menus.
A thorough program specification leads straight into flow charts and timing diagrams, which are components of Program Design.
The program design stage lays out the structure and algorithms of the firmware. There may be several ways to do the same job, but some will work far better than others. The structure and algorithms may be laid out as a flowchart, a timing diagram, a description of a protocol, a memory map, or an equation.
The work done in the program design may be
transient, depending on the job. It may well be that the material generated in
the program design stage becomes largely irrelevant to understanding and
maintaining the final code, if the final code is documented well enough.
If the program is well specified and the algorithm design stage has been thorough, the actual code writing stage can become almost mechanical. By defining the software at the outset, before code is written, a much more defined, integrated, set of code can be produced. Code that has been modified extensively, or added to repeatedly, often exhibits "ragged edges" in its structure which make it difficult to understand. If this causes problems, the solution is a thorough rewrite. New code can also suffer from the "ragged edge" symptoms if it is written without a proper Program Design stage.
Customers value well-commented software. The extra space occupied by comments costs nothing, and if the comments are well laid out there is no possibility that the customers/users can detract from understanding the code. The software itself is also a fine place to maintain the inevitable notes on revision levels, and interfacing to the hardware - it is the one item of documentation guaranteed to be passed to a new engineer on a job. Software commenting is just as important to the original engineer - it is difficult to remember the details of code 12-18 months after writing it.
Program test can be similar to Electronics testing.
"Divide and conquer"
By testing the code in a modular technique, it is easier to detect faults before they are compounded by other factors. Program testing requires some way to get diagnostic data for analysis. Often this is by way of emulation tools, or through the hardware itself, for instance a serial port.
The programming for control systems, Realtime programming, is quite different from the programming of a PC applications package. The programming of electronics systems is also different. The best results are achieved by staff with substantial experience in electronics design, or direct guidance by an electronics engineer. This cross-disciplinary skill is most important in the Program design stage, where the algorithms are actually set and divisions are made, for instance, between functions that will run under interrupt and functions that will run as a main-line task.