Using RS-232 and Printing to LCD
Revision as of 20:13, 28 May 2006
1.Plug the Seetron BPI-216 LCD display into the COM1 serial port of the target PC, and power the display (see the LCD display’s user’s guide for more information) If you wish to use COM2, see “Changing COM Ports” later in this article.
2.Copy the file RS232Async_Messages.m into your work folder. This file contains a struct that holds configuration parameters for the RS232_Send block within the BPI_216_Send subsystem. Open the BPI_216_Send.mdl file and copy the BPI_216_Send block into your own model. The other blocks in BPI_216_Send.mdl are just for demonstration purposes.
3.To output text to the BPI-216 LCD display using the BPI_216_Send block, the system that is deciding which message to output needs to output a number of data type “double” (see “double” in the MATLAB help files for more information on data types). The BPI_216_Send subsystem will read this number and display the corresponding message. (Note: the default time step of BPI_216_Send is 0.01 seconds. BPI_216_Send’s time step must be an integer multiple of your main system’s time step.)
Figure 1 shows how to hook up the system:
File:RS232 LCD fig1
4. Open BPI_216_Send, and then open Message Bank/Selector. Find the switch-case control structure in the embedded MATLAB function. This is where we will store the messages. See Figure 2:
File:RS232 LCD fig2
Displaying Text Messages
The number outputted by your main system will be read in as the variable msgID. The switch-case control structure will find the case that matches the value of msgID, and print out the message corresponding message, displaying the message under otherwise if no match if found. Replace message_1, message_2, and message_default with your own message, preserving the single quotes. You may add or remove as many cases as you need, but case "otherwise" must be defined. If your message is too long to display on a single screen, your message will be automatically split up into multiple screens, and displayed one at a time; after the last screen is displayed, it will loop back to the first screen and keep looping. Extra spaces on the last screen will be padded with black triangles; this will help you identify the last screen. The default time between screens is 3 seconds.