QScreen C User Guide
Table of Contents
PART 1 GETTING STARTED
PART 3 COMMUNICATIONS, MEASUREMENT, AND CONTROL
PART 4: PUTTING IT ALL TOGETHER
PART 5: REFERENCE DATA
Your First Program
This Chapter will get you started using the Control-C language to program your QScreen Controller. It will guide you through the installation of the Mosaic IDE, an integrated editor, compiler, and terminal, and you'll start up and talk with your controller. You'll also:
Compile and download your first program using an example multitasking program that performs calculations using floating point math, stores data in arrays in the QScreen Controller's extended memory space, and prints the results to the terminal;
Selectively execute any program function using the QScreen Controller's on-board debugging environment (QED-Forth);
Use the QScreen Controller's built-in operating system to access extended memory;
Use the terminal to interact with a running multitasking application; and,
See how easy it is to set up a multitasking application.
The Mosaic IDE, which includes the Control-C Compiler, a full-featured editor and communications terminal, is provided on an installation CD-ROM. To install it onto your PC, first insert the Installation CD-ROM into your CD Drive. If the installer does not launch automatically, browse to your computer's CD drive using the 'My Computer' icon and double click on 'Setup.exe' to Manually launch the installer.
We recommend that you use the default installation directory ("C:\Mosaic\") and choose 'Typical Setup' when asked. If you wish to install into a different directory, you may type in any pathname provided that it does not contain any spaces. The 'Custom' setup option can be used if another version of either TextPad (the editor used within the Mosaic IDE), the Mosaic Terminal (previously called QED-Term), or an earlier version of the Mosaic IDE has already been installed. However, the Mosaic IDE requires all of its components to work properly. Please contact us if you have any questions.
When the installation is complete, you will need to restart your computer unless you are installing onto a Windows 2000 machine. Be sure to choose 'Yes' when asked to restart — if you don't, the installation may not complete properly. If you choose 'No' and restart later we recommend that to assure a full restart you fully shutdown your computer and restart it; lesser restarts don't always restart fully.
You are now ready to talk with your QScreen Controller!
Familiarize yourself with the locations of the power and serial connectors as shown in Chapter 1. After finding them, follow these steps to turn on your system and establish communications with it:
1. Connect the female end of the 9-Pin serial communications cable to your computer terminal's serial communications port and the male end to the primary serial port on the QScreen. You can use any of your PC's COM ports. COM2 is usually available, but some PCs only have COM1 available. If your computer does not have an RS-232 serial port, low cost USB-to-RS-232 serial cables are available; contact Mosaic Industries for details.
2. Power up your PC computer or terminal.
1. On your PC go to the device manager dialog box by double clicking "System" in the "Control Panel", clicking the "Hardware" ta, and clicking the "Device Manager" button.
2. In the list of devices open up the list of "Ports" and double click on "Communications Port (COM2)". (If COM2 is tied up with another service, such as a fax/modem, you may want to use COM1 instead.)
3. You'll now have a dialog box called "Communications Port (COM2) Properties". Click the general tab and make sure you have these settings:
4. We recommend that you use Mosaic Terminal, the terminal program that comes with the Mosaic IDE. You can start the terminal by double clicking the Mosaic IDE executable (the primary application of the Mosaic IDE) and choosing the terminal toolbar button which looks like this:
(The appearance of this and other toolbar icons may change in subsequent versions of the Mosaic IDE.) You can also start the terminal by double clicking the application "MosaicTerminal.exe".
The terminal starts using COM2 by default at a speed of 19200 baud, no parity, and 1 stop bit. Xon/Xoff flow control is enabled, and the file transfer options are set so that the terminal waits for a linefeed (^J) character before sending each line (this is very important). You can use any other terminal program, but it must be configured with these same settings. If you use another terminal program, you must specify that it use the linefeed character as its prompt character. It might be denoted as LF, ^J, ascii decimal 10, or ascii hex A.
If your PC is set up to use a COM port other than COM2 Mosaic Terminal will respond with a warning box saying "Invalid port number". If so, just go to the Mosaic Terminal menu item "Settings→Comm→Port" and choose the COM port you chose when configuring Windows in step 3. above.
5. Verify the baud rate of the Mosaic Terminal by going to "Settings→Comm→Baud Rate" and making sure that 19200 is selected. This is the baud rate used to communicate with the QScreen Controller. If the baud rate is incorrect, garbled characters may appear in the terminal when you try to communicate with the QScreen.
6. Plug the QScreen Controller's power supply into a 110 VAC outlet. European users will need a power transformer for changing European 220 VAC to 110 VAC. Insert the power supply output plug into the power jack on the QScreen and turn the power switch ON by depressing the side of the switch towards the power jack. After a short pause you should see the demonstration program on the screen.
The demo program indicates that your QScreen Controller is now working!
The working software demo that is included in each QScreen Controller automatically starts when power is first applied and the power switch is turned ON. The demo shows a couple of screens besides the main screen, accessible by touching the Set Flow or Set Title buttons. The main screen shows a typical control screen, the Set Flow or Power button provides an example of a numeric keypad entry screen, and the Set Title button shows an alpha numeric keypad.
You can play with the demo to see how it works. Observing this demo program run is a good way to verify that all of the hardware is functioning properly and also demonstrates some basic capabilities of the menu control software.
If Something Doesn't Work
If your demo is not running, check that power is being properly applied to the controller. The demo should always run on a new QScreen Controller when power is initially applied. If you see only a blank screen, there's something wrong, so:
1. Verify that power is being properly applied to the controller.
2. Verify that the serial cable is properly connected.
3. Check the terminal configurations of the Mosaic Terminal (using the menu item "Settings → Comm"), and recheck the communications properties of the Windows communications port.
4. Email or call us if you are still having trouble.
Disabling the Demo Program
When you tire of the demo you can disable it, but don't do that too quickly because once the demo is disabled you can't restart it without sending special commands to the controller. So, feel free to play with the demo for awhile, to see how it uses buttons and menus.
Eventually, you will want to disable the demo. You can disable it by doing a special cleanup that places the QScreen Controller in a pristine state with no application program running.
After you do disable the demo your display should be blank. You can verify that serial communications are working properly by hitting the enter key while your insertion point is in the terminal window.
Whenever you hit the 'Enter' key, as represented by the symbol in the line above, you should see an 'ok' prompt.
Now, whenever the QScreen Controller is powered up with your terminal communicating with it, this message,
where "V4.4x" represents the current software version number of your QScreen Controller, should appear, and the 'ok' prompt should repeat each time you press the carriage return. This message indicates that the onboard operating system is ready to receive commands.
Although the demo now no longer automatically starts when the QScreen Controller is turned on, it still resides in Flash memory. The special cleanup has merely erased an autostart vector — a special location that tells the controller the starting address of the program to run when it starts up. You can still start the demo program by typing the following into your terminal window,
in which the symbol represents hitting the 'Enter' key on your keyboard. The demo program should now be running. The first command you typed, RESTORE, restored pointers to the operating system's list of names of programs. The pointers had been saved in EEPROM by a SAVE command. The second line is the name of the program. When you type the name of a program the operating system responds by executing that program.
The GUI demo (main) program will continue operating until the board is reset or the power turned off. If you'd like to restore the demo so that it automatically starts whenever the controller is turned on, simply type the following two lines:
CFA.FOR main PRIORITY.AUTOSTART
Note that you must type the lines with the spaces between the words just as in the lines above. The case of the characters isn't important as well as the dots that separate the words priority and autostart. The operating system treats the dots like any other character.
These commands store the starting address of the main routine in the autostart vector. The two words, CFA.FOR main, find the code field address of the routine main and send it to the routine PRIORITY.AUTOSTART which stores it in the autostart vector. Now, the demo should automatically start up whenever the controller is turned on.
If you download other programs to the QScreen Controller you will overwrite the demo program, which is stored in Flash memory. Also, any execution of the SAVE command will overwrite the saved pointers. In either case, to revive the demo you will need to reload it. That is done by using the Mosaic Terminal to reload the compiled demo file to the controller's Flash memory. For instructions for doing that please see the comments in the file "C:\Mosaic\Demos_and_Drivers\GUI_Toolkit_QScreen\C\gui_demo.c".
Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2006 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation