Design Idea
Tricks improve on Excel LCD initialization
Edited by Bill Travis
Aubrey Kagan, Weidmüller Ltd, Markham, ON, Canada -- EDN, 4/11/2002
A previous Design Idea on using Excel for LCD initialization relies on the user for cutting and pasting from Excel into an editor (Reference 1). It appears that it would take a minimum of six keystrokes or mouse strokes from one character to a new character to perform this operation. This procedure does not allow for the addition of comments, which would be advantageous in the maintenance of the character set. Over a set of 64 characters, a user would take nearly 400 actions. The use of macros would allow for the reduction of these keystrokes or mouse strokes and would probably improve the previous idea. In using such macros, rather than copy the numbers associated with characters into the text editor, as the previous Design Idea suggests, you append each sequence of numbers to a text file. When the character set is complete, you can open the text file, massage it with find-and-replace techniques, and then paste it as a whole into a target file. An added benefit is that each sequence appears on a single line rather than having a line for every row of the display. You can maintain this original file for use in both high-level and assembly programs if the need for repeating the process ever arises. The macro in Listing 1 performs the following tasks: All the parameters represent data in the cells of the spreadsheet. The file name is in cell A1. (The macro appends the ".txt.") Cell B26 has the leader, B27 has the comment symbol, and B28 has the delimiter between the numbers in the file. You can use this data in assembler or C or some other language, so the listing generalizes. C would ignore the "/* db */," and you could universally replace it with "db" if you use an assembler. Similarly, you could globally modify the comment notation, " ;//" (with a space before the semicolon), in the text file as well. The trailing comma of the line of data is needed in C as part of a constant array but in assembler would generate an error. If you're using an assembler, the global search would look for the sequence " ;//" and replace it with a space and a semicolon. Because of the inconsistent way text editors deal with tabs, the listing avoids using the tab character. By modifying the cells, you can easily customize the format. You can implement other changes by modifying the macro, written in Visual Basic for Applications. The following is a sample line from a file: /* db */ 4 , 12 , 4 , 4 , 4 , 4 , 14 ,;//this is a "1" on a 5×7 matrix. A button on the spreadsheet allows you to run the macro with a single click (Figure 1), so you need not switch from the
mouse to the keyboard to run the macro. You can also run the macros from
Ctrl-key combinations. (In Excel, you should note that, to run a macro, you must
have completed data entry into a cell.) The matrix's 10×16-cell format is also
generalized. You can alter this format by entering the number of columns in B3
and the number of rows in B4 and clicking on the Shade Matrix button. This
action activates a second macro that shades out the cells not in use. Clicking
on the Update to File button triggers a pop-up window requesting a comment. You
need not enter the comment symbol, because the macro automatically enters it.
The macro then appends the line to the file. The unused rows do not appear in
the file. Click here for a zip file containing
an associated Excel spreadsheet. Is this the best Design Idea in this issue? Select at www.ednmag.com.
Reference
















