You are on page 1of 25

C O N T E N T S

1 . 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 2 . 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13 2.14 3 . 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11

U S I N G

C a M e D

Getting Started Hardware Set-Up Software Set-Up Using the Software Saving Messages/Symbols Saving Messages/Symbols Example CaMeD Operation Keyboard Brightness of Display Reset Button Piezo Buzzer Status LEDs H A R D W A R E Controller Board Oscillator Status LEDs Voltage Supervisor Analog Keyboard EEPROM Memory LED Controller LED Line Decoders and Drivers RS232 Interface Piezo Buzzer Controller Board Prototype LED Matrix Display Line Frequency Column Frequency Data to the Display S O F T W A R E Firmware Program Main Routine General Routines Keyboard Routines Delay Routines EEPROM Routines Display Routines Visual-Basic Routines Visual-Basic Interface Program General Routines RS232 Communication Routines LED Routines

Chapter U S I N G C a M e D

1 . 0

G e t t i n g

S t a r t e d

In order to evaluate and use CaMeD, the following items are required: * * * * * * CaMeD Prototype Controller Board CaMeD Prototype LED Matrix Display PC Computer with Win95 CaMeD.exe & rsapi.dll A mouse (COM1) & RS232 cable (COM2) 9V 500mA power supply unit

1 . 1

H a r d w a r e

S e t - u p

Connect the hardware in the sequence, as shown below:* * * * connect the line and column cables. connect the 9v power supply. connect the RS232 cable to the prototype board and PC COM2 port. turn the DIMMER control spindle fully right.

After connecting all the cables and power supply, the message CaMeD should appear on the display for approximately ten seconds, then disappear. The display will now remain blank until one of the keys are pressed.
1 . 2 S o f t w a r e S e t - u p

After successful configuration of the hardware, the software can now be installed. The disk contains two files: CaMeD.exe and rsapi.dll. These two files should be copied onto the main hard drive C. Copy rsapi.dll into the Windows\System32\ directory. Before executing the program, check the serial port configuration of the computer system. COM2 port is required for communication (the baud rate, bits, etc. are not important). The program may now be executed by clicking twice on the CaMeD.exe file. A window should now open, as shown below.

1 . 3

U s i n g

t h e

S o f t w a r e

The graphic interface consists of five parts: * * * * * the virtual LED matrix display. the clear display button. the exit program button. the user-definable symbols 1-4 options. the save symbol button.

The virtual LED display allows the user to switch each of the 1024 LEDs on or off, simply by placing the mouse cursor over the appropriate LED and clicking the left mouse button. The LED will turn on (red) or turn off (grey) depending upon the previous state (toggle action). The clear display button allows the user to clear the whole display (turn all 1024 LEDs off). The exit button allows the user to close and exit the program. The user-definable symbols options (1-4) allows the user to select in which memory location the current display should be saved on the controller board (symbol 1 corresponds to the user1 key on the controller board). The save symbol button allows the user to save (download) the current message/symbol shown on the virtual LED display onto the controller board.

1 . 4

S a v i n g

M e s s a g e s / S y m b o l s

The controller board allows the user to design and save up to four messages/symbols. After powering-up the controller board, the message CaMeD should appear on the display, for approximately ten seconds. It is during this time, that the user is able to save their messages/symbols onto the controller board, by pressing one of the keyboard keys (on the controller board!). If the user wants to save their messages/symbols at some other time, then the reset button, on the controller board, may be pressed and then one of the keys should be pressed during the CaMeD message.

1 . 5

E x a m p l e

The following procedure describes a typical method of designing and saving a user-definable message/symbol. Before saving a message/symbol, the controller board must be put into a wait mode. This mode can be made active in two ways: * * pressing a key on the controller board during the CaMeD message. pressing the reset button and then immediately pressing any key.

After entering the wait mode, the display will appear blank. The controller board will wait in this mode until a message/symbol has been saved (downloaded). The visual-basic interface program may now be started, as described above in section 1.2. Assuming the hardware is correctly connected, and the controller is waiting for a symbol to be downloaded, and the visual-basic interface program has been started, then the user may design their own message/symbol, as shown below:-

After completing a message, the user-definable symbol number must now the chosen (i.e. symbol 3 - corresponding to the user3 key on the controller board). The save symbol button should now the clicked, to store (download) the message onto the controller board. A message/symbol takes approximately five seconds to be saved. After a successful download, the program will display the symbol stored in CaMeD message, otherwise a communication error will be shown, indicating that a problem has occurred (recheck cable connections, computer COM ports set-up, etc.). A user-defined message/symbol will remain on the controller board until it is re-written by another user-definable symbol with the same symbol number. The controller board will now re-boot, with the CaMeD message appearing on the display.

1 . 6

C a M e D

O p e r a t i o n

After the CaMeD message has disappeared from the display, the controller board will enter the normal mode of operation. This mode allows the user to operate CaMeD in the same way as it would be used when installed into an automobile. The controller board is shown below:-

1 . 7

K e y b o a r d

The keyboard may be divided up into three sections:* * * the system messages/symbols keys the user-definable messages/symbols keys the function keys

The system messages/symbols are fixed within the microcontrollers memory. They cannot be changed or edited. They represent to most common messages/symbols that may be needed. The table below describes them:Pressing keys 1-8 will cause the corresponding message/symbol to appear on the display for approximately six seconds. After this time, the display is cleared. This is the normal mode of operation if none of the function keys are active. Pressing the clear key (key 16) whilst a message is being showed will immediately clear the display. KEY 1 2 3 4 5 6 7 8 MESSAGE/SYMBOL thank you/danke sorry help/hilfe panne stau! hello J L USE to show your appreciation to apologise due to driving error requesting help to warn other road users to warn other road users to greet a friend to show your appreciation to show your discontent

Keys 9-12 are used to display a user-definable message/symbol. The keys correspond to the symbol number of the visual-basic program (i.e. symbol1 - user1, symbol2 - user2, etc). KEY 9 10 11 12 MESSAGE/SYMBOL user1 user2 user3 user4 USE general purpose general purpose general purpose general purpose

Keys 13-16 are function keys. They allow a message to be displayed differently. A function key should obviously be pressed before a message key (1-12). KEY 13 14 15 16 MESSAGE/SYMBOL flash inver const clear USE to cause the display to flash to inverse-video the display to constantly display the message to clear the display/functions

A function remains active until the clear key is pressed (when no message is being displayed).

1 . 8

B r i g h t n e s s

o f

D i s p l a y

The brightness of the display may be changed. A potentiometer, in conjunction with a jumpersetting, allows the user to manually adjust the brightness of the LEDs on the display. The jumper-setting position should not be altered (in the top position) if an even-brightness is required (all LEDs with the same brightness). Setting the jumper in the bottom position allows a super-brightness to be achieved, albeit with unequal LED intensities.

1 . 9

R e s e t

B u t t o n

The reset button allows the user to save a user-defined message/symbol. This button may be activated at any time. See section 1.5 for more details.

1 . 1 0

P i e z o

B u z z e r

The piezo buzzer is used as an audio indication. It is activated when any of the keys are pressed, and after a message has been shown on the display. This has been implemented as a feedback feature for the driver.

1 . 1 1

S t a t u s

L E D s

The three green LEDs are not fully used by CaMeD. They were implemented during the development of the assembly program. They would not be required for the final CaMeD board.

Chapter H A R D W A R E

2 . 0

C o n t r o l l e r

B o a r d

The ST72E251G2 microcontroller forms the heart of the controller board. Connection of external devices to the microcontroller was a relatively easy task due to the fact that it exhibits many hardware peripheral features. The hardware peripherals implemented include the I2C bus (for the external EEPROM memory), the SPI bus (for the LED controller device), the ADC (for the analog keyboard), the Timer PWM (for the piezo buzzer) and the normal input/output ports (for the RS232 interface, LED line decoders, status LEDs). The diagram below, see figure 1, shows how all the devices are connected to the microcontroller.

Figure 1 - Overview of Controller Board.

2 . 1

O s c i l l a t o r

A 16MHz oscillator module device was used for the prototype. The module internally generates the necessary clock signal, which is connected directly to the clock input of the microcontroller. The frequency is divided (by two) within the microcontroller to 8MHz, resulting in a 125ns clock cycle.
2 . 2 S t a t u s L E D s

The three status LEDs have been implemented for the prototype. They allowed the author to indicate various processes, during the debugging stage of assembly programming. They would not normally be used in the final design.
2 . 3 V o l t a g e S u p e r v i s o r

The voltage supervisor is used to generate a well-defined reset pulse during power on. It also guards against brown-out conditions should they inadvertently arise on the power supply bus, again by generating a controlled microcontroller reset. The prototype board incorporates a manual reset button, allowing a system reset to be executed. This reset button would not be normally implemented in the final design.

10

2 . 4

A n a l o g

K e y b o a r d

The microcontroller's ADC peripheral (AIN5) is used to implement the keyboard. The hardware consists of a chain of resistors and 16 push-switches, with each switch generating a particular analog voltage. Table 1 shows the function of each key, and the analog and digital values associated with it.

Key / Function 0 - no key press 1 - danke 2 - sorry 3 - hilfe 4 - panne 5 - stau 6 - hello 7 - J 8 - L 9 - user1 10 - user2 11 - user3 12 - user4 13 - flash 14 - inverse 15 - constant 16 - clear

Analog Voltage (volts) 0.08 0.28 0.56 0.83 1.09 1.35 1.61 1.86 2.13 2.39 2.66 2.93 3.22 3.51 3.82 4.14 4.48

Digital Value (dec.) 4 14 29 42 56 69 82 95 109 122 136 149 164 179 195 211 228

Tolerance Range (dec.) 0-8 10 - 18 25 - 33 38 - 46 52 - 60 65 - 73 78 - 86 91 - 99 105 - 113 118 - 126 132 - 140 145 - 153 160 - 168 175 - 183 191 - 199 207 - 215 224 - 232

Table 1 - Keyboard Assignment with corresponding Digital Values The function of each key is clearly given in the first column. The second column shows the analog voltage generated and taken to the ADC input, when a key is pressed. The third column shows the analog voltage converted in digital form (decimal). The fourth column shows the real-life expected values. The variations are due to component tolerances and the +5V power supply tolerance. A range of +/- 4 digital values has been implemented to compensate for any component/voltage variations. For more information concerning the microcontrollers ADC, consult the ST72251 data sheet.

11

2 . 5

E E P R O M

M e m o r y

The microcontroller's I2C bus peripheral is used to connect the EEPROM. A non-volatile memory has the advantage of retaining the data contents even when CaMeD is switched off. The memory is used to store the user-definable messages/symbols. For a complete display, each message/symbol requires a total of 1024 bits (128 bytes) of memory. Therefore a total of 4096 bits (512 bytes) of memory are required to store four user-definable messages/symbols.

2 . 6

L E D

C o n t r o l l e r

The microcontroller's SPI bus peripheral is used to connect the M5450 Controller. The IC controls the LED columns of the LED matrix display, turning the appropriate LEDs on or off. The device also incorporates a common constant-current generator, thereby allowing the brightness of the LEDs to be controlled. The M5450 is clocked at a maximum of 500kHz (0,5MHz). The brightness of the display may be adjusted by using the potentiometer. A jumper has been implemented to limit the brightness control. If an extra-bright display is required, then the jumper should be placed in the top position. The current limiting resistor is thereby bridged allowing maximum current to be supplied to the LEDs. This configuration may prove unsatisfactory, due to the unequal brightness intensity on each display line.

2 . 7

L E D

L i n e

D e c o d e r s

&

D r i v e r s

The LED line decoders are controlled by the normal outputs on port C (pc0-pc4) of the microcontroller. They control the lines of the LED matrix display. The five binary lines are decoded to 32 lines by using two 74HC154 decoders. A discrete transistor has been used, as an inverter, to help decode the binary signals. Each decoder output drives a pnp transistor switch. The pnp transistors provide the high current (approx. 80mA if all LEDs on one line are switched on) needed to illuminate the LEDs to full brightness.

2 . 8

R S 2 3 2

I n t e r f a c e

The interface allows the user to connect the controller board to a computer, in order to generate user-definable messages/symbols. The microcontroller's normal input/output pins on port A (pa0-pa2) are used. The standard RS232 protocol is not used. The three interface signals: DTR, RTS and CTS are simply used as data lines, switched on/off when required. The Visual Basic CaMeD Interface program uses the data lines as follows: DTR RTS CTS data (used by PC to send data to controller board) clock (used to synchronise the data from the PC) busy (used by the microcontroller to cause PC to wait)

12

2 . 9

P i e z o

B u z z e r

The piezo buzzer is used to generate an audio tone, indicating that CaMeD has acknowledged a command. After pressing a key and after displaying a message/symbol a tone will be generated. This gives the automobile driver an audio 'feedback' indication.

2 . 1 0

C o n t r o l l e r

B o a r d

P r o t o t y p e

The controller board (prototype) consists of all the individual circuits, as previously described, to control the LED matrix display. A +5V 1A voltage regulator has also been included on the board.

Figure 9 - The CaMeD Mainboard & Display 13

2 . 1 1

L E D

M a t r i x

D i s p l a y

The display consists of 1024 low-current high-brightness 5mm LEDs. They are arranged in a matrix of 32 x 32. For practical reasons, the display is multiplexed. This means that in order to show a complete display, the LEDs must be constantly up-dated with the required message/symbol. The time required to constantly up-date the display depends upon the scan frequency. The scan frequency consists of the line frequency (Y-axis) and the column frequency (X-axis).

2 . 1 2

L i n e

F r e q u e n c y

The line frequency is the rate at which each line is addressed and displayed (i.e. the lsb of the decoder outputs, pin 23 of the decoder ICs). The line frequency must be high enough to avoid display flickering. For a system message/symbol (i.e. keys 1-8), the line frequency is approx. 4.7kHz (0.21 msec). For a user message/symbol (i.e. keys 9-12), the line frequency is approx. 0.7kHz (1.30 msec). The difference in frequency is due to the column frequency, as explained below:

2 . 1 3

C o l u m n

F r e q u e n c y

The column frequency is the rate at which every LED in each column, of a line, is updated (i.e. the clock signal at pin 21 of the LED controller M5450). The column frequency also depends upon the time required for the microcontroller to fetch data from the internal ROM memory (symbols 1-8) or external EEPROM memory (symbols 9-12), and send that data to the M5450. To fetch data from it's internal ROM, a time of approx. 17 sec is required. To fetch data from the external EEPROM, a time of approx. 560 sec. is required. To send the data to the M5450 takes approx. 82 sec. The difference in column and line times (frequencies), does not upset the multiplexing of the display to any great extent, but a small change (i.e. slight flickering) of the display is noticeable between a system message/symbol and user-definable message/symbol.

14

2 . 1 4

D a t a

t o

t h e

D i s p l a y

Due to the display being multiplexed, only one line is switched on at any instant. Therefore, in order to send a message/symbol to the display, only 4 bytes (32-bits) of data are required per line. The display is divided-up as follows:

Column : LEDs 1 - 8 LEDs 9 - 16 LEDs 17 - 24 LEDs 25 - 32 Data : Byte 1 Byte 2 Byte 3 Byte 4 Weight : msb lsb msb lsb msb lsb msb lsb i.e. Byte1: LED 1 represents column 1, bit 7 of byte 1; LED 2 represents column 2, bit 6 of byte 1 LED 7 represents column 7, bit 1 of byte 1; LED 8 represents column 8, bit 0 of byte 1

15

Chapter S O F T W A R E

3 . 0

F i r m w a r e

The firmware is the program which controls the ST7 microcontroller. Figure 11 shows the flow diagram of the program.

Figure 11 - Flowchart of the CaMeD firmware program. 16

3 . 1

M a i n

R o u t i n e

The firmware consists one main routine, several subroutines and two external files (ST7s register/memory mapping file and CaMeDs system displays file). The microcontroller starts operation after power-on or a system reset (according to the reset vector). The microcontroller initializes all the three ports, according to the systems requirements. All three status LEDs are turned off and the slave address for the EEPROM memory is also set. The microcontroller continues execution by calling the introductory screen display. Here, the message CaMeD is shown on the LED matrix display. The display remains on for approximately ten seconds, During this time, the keyboard is scanned. If a key should be pressed within this time, the microcontroller will execute the Visba routine. This routine allows the user to send user-definable messages/symbols from the visual-basic interface program to the controller board. If no keys have been pressed within this designated time, the program continues with the normal execution mode(at this instant, it is not possible for the visual-basic program to communicate to the controller board - a system reset would have to be carried out if the user intends to store a user-definable message/symbol). In normal mode (from label START), the display is normally blank. The microcontroller remains in this condition until one of the sixteen keys is pressed. The keyboard is continually scanned in this condition. If a key is pressed, then program execution continues (from label PRESS). The microcontroller now debounces the key by introducing a small delay and scanning the keyboard one more time. If the same key is being pressed, after the second scan, then program execution continues (otherwise execution returns to the beginning of the program from label START). At this point the microcontroller calls the KEYNR subroutine. This routine ascertains which one of the keys has been pressed. If keys 1-8 (system message/symbol keys) have been pressed, then the microcontollers X and Y index registers are loaded with the start address (within the microcontrollers ROM area) of the corresponding display. If keys 9-12 (user-definable message/symbol keys) have been pressed, then the slave address of the EEPROM memory is loaded with the start address of the corresponding display. If keys 13-16 (display function keys) have been pressed, then the corresponding bit is set (or reset) in the KEYFUN register. Execution continues by displaying the corresponding display (if key 1-12 was pressed). Execution then continues by scanning the keyboard. If the user is still pressing the same key as before, then program execution halts until the key is de-pressed! Otherwise, program execution returns to the beginning (from label START).

17

3 . 2

G e n e r a l

R o u t i n e s

INIT - Initialisation of System This routine initialises the whole system at power-on or system reset. The slave address of the EEPROM is initialised as well as the ports. The ports are initialised as: PORT A
bit: direction: function: bit7 out status led bit6 in i2c bus bit5 out status led bit4 in i2c bus bit3 out status led bit2 out rs232 bit1 in rs232 bit0 in rs232

PORT B
bit: direction: function: bit7 in spi bus bit6 out spi bus bit5 out not used bit4 out spi bus bit3 out spi bus bit2 out not used bit1 out piezo bit0 out not used

PORT C
bit: direction: function: bit7 bit6 bit5 in keyboard bit4 out line dec. bit3 out line dec. bit2 out line dec. bit1 out line dec. bit0 out line dec.

INTRO - Introductory screen This routine displays the CaMeD message for approximately ten seconds. During this time, the user has the possibility of sending user-defined messages/symbols to the controller board. BEEP - Audio Indication for Piezo Buzzer This routine generates an audio tone, for driving the piezo buzzer. Timer A is configured as a pulse-width modulator.

18

3 . 3

K e y b o a r d

R o u t i n e s

KEYPR - Key Press This routine is used to ascertain whether a key has been pressed or not. The ADC converter, channel 5, has been implemented to carry out this task. After calling this routine, the ADCs data register must been read in order to ascertain the sample. KEYNR - Key Number This routine is used to ascertain exactly which key has been pressed. Table 2 shows the sequence of events according to each key press:

Key 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Function of Key sm/s 1 - danke sm/s 2 - sorry sm/s 3 - hilfe sm/s 4 - panne sm/s 5 - stau sm/s 6 - hello sm/s 7 - J sm/s 8 - L um/s 1 um/s 2 um/s 3 um/s 4 function: flash function: inverse-video function: constant function: clear

Action undertaken by program start address 61568 loaded into X & Y index registers start address 61696 loaded into X & Y index registers start address 61824 loaded into X & Y index register start address 61952 loaded into X & Y index register start address 62080 loaded into X & Y index register start address 62208 loaded into X & Y index register start address 62336 loaded into X & Y index register start address 62464 loaded into X & Y index register base slave address of EEPROM = 0 ; bit2=0,bit1=0 base slave address of EEPROM = 1 ; bit2=0,bit1=1 base slave address of EEPROM = 2 ; bit2=1,bit1=0 base slave address of EEPROM = 3 ; bit2=1,bit1=1 flash bit in KEYFUN register set ; bit 0 =1 inverse bit in KEYFUN register set ; bit 1=1 constant bit in KEYFUN register set ; bit 2=1 all bits in KEYFUN register reset ; all bits =0

sm/s = system message/symbol um/s = user-definable message/symbol Table 2 - Firmware Execution according to Key Number.

19

3 . 4

D e l a y

R o u t i n e s

DELAY This routine generates a small delay. The actual timing is not too critical. The routine is used throughout the program by the display and beep routines. DELSM This routine generates a small delay. The actual timing is not too critical. The routine is used to debounce the key presses from the keyboard. DEL5 This routine generates a small delay. The timing is critical. A delay of 5 msec is generated. The routine is used for the EEPROM memory device, after writing data to it.

3 . 5

E E P R O M

R o u t i n e s

EEINT - Initialisation of EEPROM This routine initialises the hardware I2C bus peripheral for connection to the EEPROM memory device. The I2C bus is configured in fast mode (444kHz clock) and activated. The speed of the clock (444kHz) is more than the maximum speed of the device (400kHz). This has been done in order to reduce the amount of flickering on the display, when user-definable symbols are being displayed. The device appears to work, but problems may arise if EEPROMs from other vendors are used.

EEREAD - Read 1 byte of data from EEPROM This routine allows the microcontroller to read the contents of the EEPROM in order to display a user-definable message/symbol. The EEPROM device data is read 1 byte at a time. The data is then stored in the DATR memory location. This routine is executed four times within the DISEE routine, in order to display 1 line (i.e. 32-bits) on the LED display. The routine sends the data to the EEPROM as follows:
start bit -> slave address(w=0) -> word address -> start bit -> slave address(r=1) -> read data -> stop bit

20

EEWRITE - Write 1 byte of data to EEPROM This routine allows the microcontroller to write data to the EEPROM, 1 byte at a time. The visual-basic interface program sends data to the controller boards in order to store the userdefinable messages/symbols. The VISBA routine uses this routine to store the incoming data into the EEPROM. Again, this routine is called four times, in order to store 1 line (i.e. 32-bits). The routine sends the data to the EEPROM as follows: start bit -> slave address(w=0) -> word address -> data to be written -> stop bit

3 . 6

D i s p l a y

R o u t i n e s

CLRSCR - Clear LED Display This routine clears the entire LED display, by sending zero data to all LEDs (i.e. turning them all off).

STABIT - Send Start Bit to LED Controller This routine sends the start-bit required by the LED controller device. The SPI bus cannot be used to generated this bit, so port B is configured to outputs (push-pull) during this routine.

DATDIS - Data to LED Controller This routine sends the required data to the LED controller device. The SPI bus is implemented. The SPI bus is configured in master mode, without interrupt generation, and with a baud rate of 0.5MHz (Fcpu/16). 32-bits of data are send representing 1 full-line of the LED display. The data stored in memory locations DATA1,DATA2,DATA3 and DATA4 are sent to the LED display. The SPI bus peripheral disabled at the end of the routine

DATDUM - Dummy Data to LED Controller This routine sends three dummy data values to the LED controller device. The SPI is not implemented, so port B is configured to outputs (push-pull) during this routine.

SYSDIS - System Message/Symbol Display This routine carries out a whole range of functions. It sets-up the start address of the message to be displayed by storing the address in memory location SCRN (16-bits). This information is needed by the DISSCR routine (which carries out the actual displaying of the message/symbol) which is executed within this routine. The routine checks the KEYFUN variable. If the flash-bit or constant-bit are set, the appropriate action is taken to perform these functions. 21

The clear key is scanned during the execution of this routine. If the clear key is pressed, the display will return to normal mode (i.e. go blank and return to beginning of program)

DISSCR - Display Message/Symbol on LED Display This routine fetches the appropriate display screen data from ROM memory, using the long indirect indexed addressing mode (using the SCRN memory location as a pointer). The data for one line of the LED display are stored in locations DATA1, DATA2, DATA3 and DATA4. These data are then sent to the LED controller device using the STABIT, DATDIS and DATDUM routines. The routine also checks the KEYFUN variable. If the inverse-video-bit is set, the data is then complemented to perform this function, before being sent to the LED controller.

USEDIS - User-Definable Message/Symbol Display This routine carries out a whole range of functions. The EEINT routine is executed to initialise the I2C bus for the EEPROM. The DISEE routine (which carries out the actual displaying of the message/symbol) is executed within this routine. The routine checks the KEYFUN variable. If the flash-bit or constant-bit are set, then appropriate action is taken to perform these functions. The clear key is scanned during the execution of this routine. If the clear key is pressed, the display will return to normal mode (i.e. go blank and return to beginning of program) DISEE - Display Message/Symbol on LED Display This routine fetches the appropriate display screen data by executing the EEREAD routine. These data are then sent to the LED controller device using the STABIT, DATDIS and DATDUM routines. The routine also checks the KEYFUN variable. If the inverse-video-bit is set, the data is then complemented to perform this function, before being sent to the LED controller.

22

3 . 7

V i s u a l

B a s i c

R o u t i n e s

VISBA - Visual Basic This routine allows the visual-basic interface program to send user-definable messages/symbols and stored them in the EEPROM device. The EEINT routine is executed to initialise the I2C bus for the EEPROM. The STACOD routine is then executed. This routine waits, in an endless loop, until the visual-basic interface program sends the appropriate start code. Upon reception, the SYMNUM routine is executed. This routine decodes the incoming data to ascertain the user-definable message/symbol number (1-4). Upon decoding the symbol number, the LEDSTA routine is then executed. This routine decodes the next train of incoming data, which represents the LED status (i.e. on or off). This data is then stored in the EEPROM. The RS232 BUSY is sent (taken active) to the visual-basic interface program after receiving four bytes of information. This is necessary because of the EEPROM slow write-cycle (5 msec). The visualbasic interface program reacts by stopping the flow of data until BUSY is taken inactive. A complete display (1024-bits of LED status data) are sent in this manner. After storing a display, execution resumes from MAIN (re-booting the system).

STACOD - Start Code This routine waits for the reception of the start code from the visual-basic interface program. Program execution remains in this routine until the start code is received.

SYMNUM - Message/Symbol Number This routine ascertains the user-definable symbol number. The slave address variable, SLADD, used for the EEPROM, is changed according to the symbol number. LEDSTA - LED Status This routine ascertains the LED status (i.e. on or off) of all 1024 LEDs. This information is stored in a temporary data array DATST (4 bytes i.e. 1 line). The bits received are placed in the BYTE memory location, which is appropriately 'rotated right through carry'. After 7 rotates, the value is then stored in the DATST array.

23

3 . 8

V i s u a l

B a s i c

P r o g r a m

The visual basic interface program allows the user to design and send user-definable messages/symbols to the controller board. The program was written using visual basic 5. The program consists of two sections : the user graphic interface and the actual programming code. This chapter deals with the programming code, more information concerning the user graphic interface is given in chapter 1. The program code consists of several routines. These routines will now be described.

3 . 9

G e n e r a l

R o u t i n e s

PRIVATE SUB cmdEXIT_CLICK() This routine allows the user to exit the program.

3 . 1 0

C o m m u n i c a t i o n

R o u t i n e s

DECLARE OPTIONS ROUTINE This routine starts program execution by declaring the 'rsapi.dll' system library. The system library allows the visual basic program to communicate with the RS232 computer interface. The standard RS232 protocol has not been implemented. Three communication lines : CTS, DTR and RTS are used as individual data lines.

PRIVATE SUB_FORM() This routine opens the serial communication port. COM 2 port has been implemented. Although this routine sets the baud rate, parity, start and stops bits, these all not further used, due to the fact that the standard communication protocol has not been implemented.

3 . 1 1

L E D

R o u t i n e s

PRIVATE SUB cmdLEDOFF_CLICK() This routine allows the user to clear the display (i.e. turn all 1024 LEDs off).

PRIVATE SUB FORM_MOUSEDOWN () This routine allows the user to turn each of the 1024 LEDs on or off. This is achieved by placing the mouse on a LED symbol and clicking the left or right mouse button. The LED is toggled between on and off (i.e. clicking the LED symbol turns the LED on, clicking again turns the LED off). 24

PRIVATE SUB CMDSEND_CLICK() This routine sends the actual LED status data to the controller board. The program sends three packages of information. The first package concerns the start code address. The start code initiates the communication between the interface program and the controller board. The second package concerns the message/symbol number. The program ascertains this information according to the user's choice (OPTUSER1-4). The third package of information concerns the LED status. Here, one bit of data is sent indicating whether the LED is on or off. A total of 1024 LED status bits are sent for the complete LED display.

25

You might also like