Using RS-232 and Printing to LCD

From Mech
(Difference between revisions)
Jump to: navigation, search
(Getting Started)

Revision as of 19:04, 28 May 2006

Contents

Getting Started

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 an integer 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 integer and display the corresponding message. Note: the default time step of BPI_216_Send is 0.01 seconds. BPI_216_Send’s time step need to be an integer multiple of your main system’s time step.

Figure 1 shows how to hook up the system:
File:RS232 LCD fig1
Figure 1

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
Figure 2

5. 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. 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.

6. Test your system. It should now display your messages on the LCD screen.

Personal tools