The C Programmer’s Guide to the QVGA Controller
Table of Contents
PART 1 GETTING STARTED
PART 2 PROGRAMMING THE QVGA CONTROLLER
PART 3 COMMUNICATIONS, MEASUREMENT, AND CONTROL
Chapter 10: Outputting Voltages with Digital to Analog Conversion
PART 4: PUTTING IT ALL TOGETHER PART 5: REFERENCE DATA
PART 4: PUTTING IT ALL TOGETHER
PART 5: REFERENCE DATA
Chapter 1: Getting to Know Your QVGA Controller
Congratulations on your choice of the QVGA Controller™. This Chapter introduces the various hardware and software features of the QVGA Controller: the graphical user interface (GUI), touchscreen, processor, memory, I/O, serial communications, RTOS and operating system functions.
In this chapter you’ll learn:
All about the operating system and software features of the QVGA Controller;
How to connect to your controller; and,
How to configure various options on your controller.
Introducing the QVGA Controller
To serve the needs of real-time control, modern embedded computers must have a set of complementary features including operating system software, device drivers, user interface, and I/O. You’ll find the QVGA Controller has a set of hardware and software that work together to simplify your product development cycle while bringing new capability to your products. The following subsections discuss the interdependent hardware and software aspects of your controller.
You wouldn’t want to have to load an operating system into your desktop computer each time you turn it on, and the same holds true for embedded computers. Importantly, all of Mosaic’s controllers incorporate a full-time, on-board operating system called QED-Forth. QED-Forth is an interactive programmable macro language encompassing a real-time operating system (RTOS), object oriented graphical user interface (GUI) toolkit, debugging environment,and a comprehensive set of pre-coded device drivers.
These built-in functions make it easy for you to get the most out of your board's computational and I/O capabilities. You can fully program the QVGA Controller using only the QED-Forth programming language, or you can program it using only the C language – all of the operating system’s functions are accessible using either language.
This manual describes how to program your QVGA
Controller using the Control-C programming language, and
how to use the built-in functions. Another manual if available if you
The RTOS in onboard Flash memory also manages all required hardware initializations and automatically initializes and starts your application code. It provides warning of power failures so you can implement an orderly shutdown, and provides the run-time security feature of a watchdog (COP - computer operating properly) timer.
Programming is a snap using the interactive debugger and multitasking executive. The multitasker allows conceptually different functions of your application run independently in different tasks while all accomplishing their duties in a timely fashion.
Choice of Programming Languages
You can program the QVGA Controller using either the ANSI-standard C language or Mosaic’s QED-Forth language. In either language, you can supplement your high-level code with assembly code. Using either language, you have full access to all firmware functions.
The Control-C Programming Environment
Our Control-C™ cross-compiler was written by Fabius Software Systems and customized by Mosaic Industries to facilitate programming the QVGA Controller in C. It is a full ANSI C compiler and macro pre-processor; it supports floating point math, structures and unions, and allows you to program in familiar C syntax. Extensive pre-coded library functions provide easy command of the controller’s digital I/O, A/D, D/A, keypad, display, high current drivers, serial ports, memory manager, multitasker, and much more.
Using the Windows™ environment on your PC, you can edit your C program in the supplied TextPad™ editor, and with a single mouse click you automatically compile, assemble and link your program, and generate an ASCII hex file ready for downloading. Clicking in the “Terminal” window and sending the download file to the controller completes the process: you can then type main from your terminal to execute your program. The interactive development environment also lets you examine and modify variables and array elements, and call individual functions in your program one at a time with arguments of your own choosing. This interactive environment greatly speeds the debugging process!
QED-Forth High Level Language
For those who prefer to program in FORTH, no external compiler is needed. You interact with the QED-Forth operating system (an RTOS, interpreter and compiler, all rolled into one) using your PC as a terminal. When programming in Forth you can use the TextPad text editor supplied as part of the Mosaic IDE (or you can use any other editor you prefer) to write your code and download the source code directly to the controller where it is compiled as it downloads. As we will see, even C programmers benefit greatly by the presence of the QED-Forth operating system, as the built-in Forth language provides a quick and easy way to interactively “talk to” your QED Board while debugging your C programs.
68HC11 Assembly Code
Both Control-C and QED-Forth include complete in-line assemblers that let you freely mix high level and assembly code. This is sometimes useful when creating specialized time-critical functions such as interrupt handlers.
The block diagram of Figure 1‑1 provides a cogent summary of the hardware capabilities of the QVGA Controller. Each of the hardware modules shown is described in the following sections.
Figure 1‑1 The QVGA Controller showing up to eight optional Wildcards installed.
The QVGA Controller includes a high-efficiency switching regulator and extensive power line filtering for EMI/RFI isolation. It may be powered by applying any unregulated DC input voltage between 8 and 26 Volts (15-26 V if an EL display is used). If you include the QVGA Controller in a system that already has its own supplies, you may power the QVGA Controller using regulated +5 and +12 V supplies.
If you power the board with an unregulated DC supply, the onboard circuitry is protected by a built-in surge protector and electromagnetic interference (EMI) suppression circuitry. This improves the reliability of the electronics in harsh industrial environments.
The central block in Figure 1‑1 represents the 68HC11F1 microcontroller. This chip integrates a central processing unit (CPU), communications, analog and digital I/O, timing capabilities, and memory. It provides the core capabilities of the QED Board. In this document we will refer to the microcontroller chip as the 68HC11F1, or the 68HC11, or simply the HC11.
The processor includes:
An 8 bit timer-controlled digital I/O port called PORTA. The timer functions include “input captures” that facilitate accurate measurement of pulse widths, “output compares” that make it easy to generate pulse trains and pulse-width modulated waveforms, and a pulse accumulator. These functions are backed up by interrupts that simplify real-time response to external events.
An 8 channel input port (called PORTE) on the processor that can be configured to read either analog or digital inputs. Analog inputs are converted to an 8 bit digital number by a built-in analog to digital (A/D) converter.
A built-in serial communications interface (SCI). The SCI is an asynchronous interface, meaning that there is no clock transmitted with the data. Using the SCI, the QVGA Controller can transmit and receive data at standard baud rates to 19200 baud, and at non-standard rates as high as 250 Kbaud.
A serial peripheral interface (SPI) capable of data transfer rates up to 2 megabits per second. Many useful devices communicate via such a synchronous (clocked) serial interface. Multiple peripheral devices can communicate on this interface as long as each device has a unique chip select signal. As we’ll see, two optional onboard analog devices exchange data with the 68HC11 via the SPI.
A watchdog timer that can be configured to reset the processor if the application program fails to execute properly.
A clock monitor available to reset the processor if the clock fails.
External interrupt request pins and a variety of interrupt functions for quick response to real-time events.
512 bytes of electrically erasable PROM (EEPROM). 192 bytes of this nonvolatile memory are used by the operating system and 320 bytes are available for your application. EEPROM provides a convenient way to store calibration constants and other information that must be periodically updated.
A 16 bit address bus and an 8 bit data bus. While the 68HC11’s native address space is 64 Kilobytes (equal to 65,536 bytes, and often written as 64K), the QVGA Controller expands the addressable memory space to 8 Megabytes by effectively adding 8 “page” bits to the address bus.
Learning More about the 68HC11
The QVGA Controller uses a new version of the 68HC11 microcontroller, called the 68HC11F1. Motorola’s M68HC11 Reference Manual and MC68HC11F1 Technical Data Manual are included with this documentation package as Adobe Acrobat Portable Document Format (*.pdf) files.
The M68HC11 Reference Manual thoroughly describes how to use microcontrollers of the 68HC11 variety, but it does not describe some of the enhanced features that appear in the F1 version. The MC68HC11F1 Technical Data Manual provides details of the operation of the F1 .
The QVGA Controller features a touchscreen controlled graphical user interface. Combining a high-contrast 5.7” diagonal ¼VGA display and high resolution analog touchscreen, it comes complete with object-oriented menuing software that makes it easy to control your application using buttons, menus, graphs, and bitmapped images.
You can display your own custom graphics on a bright white-on-blue cold-cathode fluorescent (CCFL) backlit LCD. Display screens and graphic objects are quickly developed with most Windows paint programs, such as PC Paintbrush, allowing you to create sophisticated displays including your company logo, system diagrams, and icon-based control panels. Real-time data plotting routines are precoded for you, so the user can see what your instrument is doing. Your application’s startup screen executes automatically on power-up.
You can use as many screens as you need, each with software configurable buttons and menus. A precoded menu manager simplifies menu-driven control, making it easy to define buttons, menus, icons, and their associated actions. With the touch or release of a button, the menu manager responds, sending an appropriate command to your application program. Onboard software draws the screen graphics and responds to button presses for you, so you can focus on your application rather than display maintenance.
384K Flash and 257K RAM are standard on the QVGA Controller. Of the QVGA Controller’s 384K of Flash memory, 224K is available for your application program and data storage. Of the 257K of RAM, 253K is available for application program use. Up to 128K of the RAM can be optionally battery backed. 320 bytes of on-chip nonvolatile EEPROM is also available.
Custom controllers with 768K Flash and 641K SRAM are also available. For those really extensive applications that require lots of memory or removable data storage, the QVGA Controller hosts compact flash cards from 64 Megabytes and up in size.
Like PROM, Flash memory is nonvolatile. Thus it retains its contents even when power is removed, and provides an excellent location for storing program code. Simple write cycles to the device do not modify the memory contents, so the program code is safe even if the processor “gets lost”. But Flash memory is also re-programmable, and the Flash programming functions are present right in the QVGA Controller’s onboard software library.
Of the Flash memory, 256K resides on the QED Board (see Figure 1‑4 ), in its first socket (S1). This 256K includes the 128K operating system, multitasking executive, and device driver routines. The middle socket on the QED Board accommodates a128K static RAM. A third socket accommodates an optional battery-backed real-time clock. The QVGA Controller’s remaining memory is mounted on the QVGA Board.
The QVGA Controller provides a total of 57 I/O channels, distributed among digital, analog and serial communications functions as shown in Table 1‑1.
Table 1‑1 I/O available on the QVGA Controller
You can control dozens of analog and digital I/O lines in real time. The 30 digital I/O lines are distributed among dedicated inputs and outputs, high-current outputs, and configurable lines, including timer-controlled lines. The analog I/O lines are distributed among 8-bit and 12-bit resolution A/Ds and an 8-bit resolution digital to analog converter (DAC) . The 8-channel (or 4-channel differential) A/D with 12 bits of resolution facilitates accurate measurement of analog inputs, and the 8-channel DAC allows the QVGA Controller to generate analog outputs, or to multiply an analog signal by a digitally specified gain factor (to implement volume control, for example). Both of these devices communicate with the processor via the high speed serial peripheral interface (SPI).
For each of these I/O lines, pre-coded I/O drivers make it easy to do data acquisition, pulse width modulation, motor control, frequency measurement, data analysis, analog control, PID control, and communications.
Two serial ports and a fast synchronous serial peripheral interface (SPI) provide plenty of communications capability. A hardware UART drives RS232 or RS485 protocols at up to 19.2 Kbaud, and a software UART provides RS232 at up to 4800 baud. Onboard serial interface chips generate the logic levels necessary to implement either the RS232 or RS485 protocol. Two serial ports allow you to program through one while your instrument can still communicate with a third party through the other. If you need greater speed or more ports, UART Wildcards plug directly into the QVGA’s Wildcard module bus, each providing two more full-duplex RS232/485 buffered serial communication ports at up to 56 Kbaud.
Need even more I/O? The QVGA Controller hosts Mosaic’s Wildcards™, small I/O modules for sophisticated and dedicated I/O. Up to eight Wildcards can be stacked on the controller for:
16- or 24-bit resolution programmable gain A/D;
Compact flash mass memory;
Optically isolated AC or DC solid state relays;
Configurable general-purpose digital I/O;
Fast, buffered RS232, RS422 or RS485 communications interfaces; or,
High-voltage, high-current DC inputs and outputs.
For operation in harsh environments an optional environmental gasket provides a tight, chemically resistant seal between your touchscreen and bezel, preventing the infiltration of dust or liquids. It allows expansion/contraction of the touchscreen surface with temperature variation, preventing touchscreen buckling yet maintains a tight seal.
The gasket uses a highly compressible, highly resilient, slow-rebound cellular urethane. It experiences only negligible compression set and it is specially designed to seal with very low closure force. The gasket retains its sealing properties at constant temperatures to 158F (70C) and can survive intermittent temperatures of up to 250F (121C). It resists most common chemicals and outgasses little.
We can provide environmental gaskets affixed to our bezels using a 3M pressure sensitive adhesive, or if you desire to seal to your own front panel we can adhesive the gasket to the touchscreen itself. When the controller is then mounted to your front panel it should be spaced so that gasket has a compressed thickness of 0.015”. In either case there is no charge for preinstalling the gasket.
An optional screen protector can extend the lifetime of your touchscreen indefinitely when used in tough or dirty environments where the screen is likely to be scratched. The screen protector is a tough, transparent, non-adhesive, slip-on plastic sheet that protects your touchscreen. While the touchscreen is quite tough itself, it can be scratched by sharp objects, or slowly haze from grit on a person’s fingertips. The screen protector is a sacrificial film that greatly prolongs the life of your touchscreen, and extends its use to extreme environments, from warehouses and shipping docks, to field and laboratory use. While protecting the touchscreen, it is highly transparent and provides a glare-free surface.
The screen protector is can be removed, cleaned and reinstalled to extend its lifetime. Under indoor conditions you can expect excellent screen protection over a year, after which you can simply replace the screen protector. Your touchscreen need never become scratched – protected, it should last indefinitely.
The screen protector is made of a super thin, durable plastic, manufactured using a patent-pending technology that provides extended protection against dust, scratches and gouges. It is also abrasion and chemical resistant and provides a high degree of clarity and a glare-free surface. There are no adhesives used to hold screen protector onto the screen. Instead, it is sized so that its edges are retained by the environmental gasket and fit snugly between the touchscreen and the front panel or bezel of your product. The film floats on the surface and provides excellent scratch and abrasion resistance without possibly damaging your screen with adhesive. While only 0.005” thick, it is stiff enough to stay flat on the screen without warping during use. You can easily remove, clean and reinstall it without any damage to the protective screen itself or to the touchscreen.
The screen protector is chemically resistant to alcohols, dilute acids, dilute alkalis, esters, hydrocarbon solvents, ketones and common household cleaning agents. You may safely clean it with an alcohol swab.
EMI-Shielded Touchscreens and Intrinsic Safety Barriers
An optional EMI-shielded touchscreen is available for those applications requiring a fully shielded instrument. The EMI shield is a transparent, grounded, fully conductive layer on the outside of the touchscreen. Instruments exposed to hazardous or potentially explosive atmospheres often require an intrinsic safety barrier (ISB) between the instrument’s internal electronics and components exposed to the external atmosphere. The ISB assures that in the event of a fault the external atmosphere can not be ignited. The QVGA Controller’s touchscreen is its sole component that is exposed to the external environment; consequently in some applications an ISB may be required. As not all OEMs will need it, the ISB circuitry is optional.
The combination of an EMI shield and intrinsic safety barrier provides three-fold protection – your instrument is protected from static discharge or power shorts directly to the touchscreen, EMI can not pass through the touchscreen, and a potentially hazardous external environment is protected from ignition resulting from a fault within your instrument.
Your QVGA Controller comprises a touchscreen controlled graphical display and two double sided surface mount boards that integrate the many hardware and software functions in a compact package.
Figure 1‑2 The QVGA Controller, display facing down.
Referring to Figure 1‑2 , which shows the QVGA Controller oriented with the display facing down, from top to bottom you can see the QVGA Controller has several layers:
A QED Board (Part No. QED-4-QVGA) sits on top. This double sided, surface mount board is the heart of the QVGA Controller, and uses Motorola’s 16 MHz 68HC11F11 microcontroller, reconfigured for an 8 MB address space. The 68HC11 supports 21 interrupts and includes several I/O subsystems including timer-controlled counters, input-capture and output-compare lines, a fast SPI and an 8-channel, 8-bit A/D. The QED Board hosts 128K SRAM (optionally battery-backed) and 256K Flash, and enhances the I/O by providing four high current digital drivers, two serial ports, 12-bit A/D and 8-bit D/A converters.
The QVGA Board hosts hardware controllers for graphical displays and a touchscreen, contains high efficiency switching regulators to provide regulated, filtered power to other components, and contains additional memory (128K expandable to 512K Flash, and 128K expandable to 512K SRAM).
The QVGA Board also provides module ports for accommodating up to 8 WildCard I/O expansion modules for just about any kind of I/O you might need. Two modules are shown on the diagram, but you can have any combination of:
16-bit or 24-bit resolution A/D;
Isolated AC or DC solid state relays;
Compact Flash Cards, 64 Mbyte and up;
Logic level, high voltage, and high current digital I/O; or,
Additional RS232, RS422 or RS485.
The ¼ VGA display may be either a bright, amber-on-black, high contrast, all-angle view TFEL electro-luminescent display or a high contrast CCFL white-on-blue monochrome LCD display with software controlled backlight and contrast. For either option the display is 5.7” on a diagonal (3.5” x 4.6 “) and shows 320 x 240 pixels.
A high resolution transparent analog touchscreen is mounted on the front surface of the display. A software controlled beeper on the QVGA Board provides audible feedback for finger touches.
An optional bezel simplifies mounting the QVGA Controller on instrument front panels.
QVGA Developer Package
If you purchased a QVGA Controller Developer Package, you should have received the following:
1. A QVGA Controller (Part No. QVGA-Mono or QVGA-EL);
2. A 9-pin PC Serial Cable (Part No. PCC9-232);
3. A 16-24 volt Power Supply (Part No. PS-QVGA);
4. A CD-ROM containing:
The Mosaic IDE including a TextPad source code editor and the Mosaic Terminal program;
The Control-C Compiler, integrated within the Mosaic IDE;
Program examples; and,
Motorola M68HC11 Reference Manual and MC68HC11F1 Technical Data Manual (Part No. MAN-HC11);
A users guide, “The C Programmer’s Guide to The QVGA Controller”, and associated glossaries and appendixes.
If you are missing any of these items, please contact us immediately.
Figure 1‑3 shows a photo of the back of the QVGA Controller, and Figure 1‑4 diagrams the positions of important connectors.
Figure 1‑3 The QVGA Controller showing the QED Board mounted on the QVGA Board.
Figure 1‑4 Connectors and Switches on the QVGA Controller. In addition to the memory shown on the QED Board, the QVGA Board contains 128 (expandable to 512K) Flash and 128 (expandable to 512K) RAM.
Power Jack and Power Switch
The power jack is located between the communications header and the power switch. The QVGA Controller can be powered by any power supply that can deliver 8 to 26 volts at 5 watts for the QVGA-Mono or 16 to 26 volts at 20 watts for the QVGA-EL. A switch, located between the power jack and the contrast potentiometer, controls power to the QVGA Controller. The switch is in the “off” position when it is depressed away from the power jack as shown in Figure 1‑3 and Figure 1‑4.
QED Board Sockets
The QED Board contains a 256K Flash in socket S1 and 128K of optionally battery-backed RAM in socket S2. An optional battery-backed Real-Time Clock (RTC, also known as the “smartwatch “) can be plugged into socket S3. The RTC is made by Dallas Semiconductor and contains a clock chip, crystal and battery.
Primary and Secondary Serial Ports, Communications Header
The primary serial port can be configured for RS-232 communication at standard rates up to 19,200 baud and nonstandard rates to 250,000 baud. Its 9-pin connector is located between the Flash Write Enable Jumper and the secondary serial port. The secondary serial port, which can be used for peripheral devices such as a printer or a barcode reader, has a maximum baud rate of 4800 baud. Its 9-pin connector is located between the primary serial port and the Communications Header. To enable the secondary serial port, turn dip switch 5 on the QED Board ON. Otherwise, dip switch 5 should be OFF so that it frees bit 3 of PORTA for use as general-purpose I/O.
Analog I/O Connector
Header H2 on the QED Board provides 24 analog I/O lines, including access to 8 channels of 8-bit A/D, 8 channels of 12-bit A/D, 8 channels of 8-bit D/A and their associated reference voltages.
Digital I/O Connector
Header H2 on the QVGA Board provides 26 uncommitted digital I/O lines: PORTA and PORTD from the 68HC11, and PPA and upper PPC from the PIA. It also brings out useful control signals including processor clocks, read/write control signals, reset and power-fail warning signals, and external interrupt request lines. Analog and digital power supplies and their respective grounds as well as an unregulated DC voltage are also available on this bus. This connector can interface directly to external digital I/O signals such as switches, control outputs, and isolated inputs and outputs.
Supplemental I/O Connector
This connector provides access to four MOSFET high current drivers named HC0-HC3 and their onboard snubber diodes, V+ raw power, and ground. The connector is located on the QED Board and also contains 5 digital outputs and 4 digital inputs.
A piezoelectric buzzer mounted on the QVGA Board allows audio feedback for software events such as button presses or alarms.
The contrast potentiometer (pot) adjusts the contrast of the monochrome LCD display and is located next to the power switch. The contrast of the display is properly set before each unit is shipped. If further adjustment is required, simply turn the pot with a small screwdriver. If the contrast pot needs to be mounted in a different location (on an external panel, for example) you can move it and connect it to the Remote Mounting Header (H13) shown in Figure 1‑4.
Wildcard I/O Expansion Interfaces
Wildcard Port Headers 0 and 1 each accommodate up to four stacked Wildcards I/O expansion modules.
Setting the QED DIP Switches
The QED Board has a 7-position DIP switch located prominently on the top of the board. The purpose and default positions of each switch are as follows:
The legend on the QED Board suggests the function of each switch. Please note that:
Switches 3 and 4 should always be ON;
Switch 2 should be ON when you’re developing and writing to the Flash memory, OFF otherwise; and,
Switches 6 and 7 together perform a special cleanup, toggling switch 7 alone resets the board.
Setting the QED Board Jumpers
A three-post jumper located between the third socket and H6 configures the primary serial port for RS-232 or RS-485 operation. If a jumper shunt is install across the two pins closest to the crystal (the default configuration), the QVGA Controller will communicate using RS-232 over serial 1. If a jumper shunt is install across the two pins closest to the J3 silk screen, the QVGA Controller will communicate using RS-485 over serial 1.
Setting the QVGA Board Jumpers
Jumpers J1, J2, and J3 on the QVGA Board
The actions of the configurable jumpers on the QVGA board are summarized in Table 1‑2.
Table 1‑2 QVGA Controller Jumper Summary.
The Remote Mounting Header
Header H13, whose location is shown in Figure 1‑4, allows you to remotely mount the power switch, buzzer, and contrast potentiometer. This allows you to move these controls from the back of the controller to a front panel for easy access and increased audibility. The default positions of the jumpers are as follows:
For a QVGA Controller with a monochrome display, jumper shunts are installed across pin pairs 1‑2 and 3‑4 to enable the on-board contrast potentiometer, and 5‑6 to enable the piezoelectric buzzer. For a QVGA Controller with an EL display, a jumper shunt is still installed across pins 5‑6 to enable the on-board buzzer, but does not have a contrast pot so pins 1-4 on the Remote Mounting Header are not connected and jumper shunts across these pins do nothing.
Remotely Mounting the Buzzer
You can mount a buzzer to your front panel for increased audibility. To remotely mount a buzzer, remove the jumper shunt across pins 5 and 6 and connect your buzzer across +5V on pin 7 and the /Beeper_ON signal on pin 5.
Remotely Mounting the Contrast Adjustment Potentiometer
If you have a monochrome display, its contrast will vary depending on the ambient temperature. Although we allow you to adjust the contrast in software, if the display is completely washed out, the contrast may have to be adjusted using the contrast adjustment potentiometer. To remotely mount a contrast potentiometer, first remove the jumper shunts across pins 1 and 2 and 3 and 4. Then, connect one side of your potentiometer to Ext_Pot_A on pin 1, the other side to Ext_Pot_B on pin 3, and the wiper to Ext_Pot_A on pin 1.
Remotely Mounting the Power Switch
You can also mount the power switch to your front panel. To remotely mount a power switch, use a toggle switch and mount one side to PWR.in on pin 9 and the other side to Switched.PWR on pin 10.
Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2012 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation