manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets

The C Programmer’s Guide to the Mosaic Handheld

Table of Contents


Introduction. How to Use This Manual

Chapter 1: Getting to Know Your Handheld Instrument

Chapter 2: Powering Your Handheld

Controlling Power

Using Battery Power

Tethered Operation

Power Metering


Chapter 3: Your First Program

Chapter 4: The IDE: Writing, Compiling, Downloading and Debugging Programs

Chapter 5: Making Effective Use of Memory

Chapter 6: Real Time Programming

Chapter 7: Failure and Run-Time Error Recovery

Chapter 8: Programming the Graphical User Interface


Chapter 9: Digital and Timer-Controlled I/O

Chapter 10: Data Acquisition

Chapter 11: Serial Communications

Chapter 12: The Battery-Backed Real Time Clock

Chapter 13: Customizing the Handheld's I/O


Appendix A: GUI Function Reference

Appendix B: Handheld Schematics

Chapter 2

<< Previous | Next>>

Powering Your Handheld

The Mosaic Handheld provides an internal battery pack for portability.  You can use a plug-in power adapter to recharge the batteries, or to power your Handheld directly.  While recharging you can continue to use the instrument.  In tethered operation, you can also bring power in through the Handheld’s DB-25 connector.

Controlling Power

Automatic Turn-On

When the Auto-On jumper, J5, on the Power Board is connected, the Handheld automatically turns on when power is applied to either the external power jack or to the EXT_VIN signal.  The EXT_VIN signal appears on pin 1 of the Power Header, H3, of the Power Board.  Power ground and EXT_VIN may also be connected to pins 1 and 2 respectively of the Handheld’s DB-25 by setting the jumpers on J1 and J2 to the position closest to the DB-25.

Manual Turn On and Off

The lower right button of the keypad is dedicated to turning the instrument on and off.  Manually pressing the button when the Handheld is OFF turns it ON, and holding it down in excess of three seconds while it is ON turns it OFF. 

Programmable Shut-Down

For orderly shutdown your software can intercept the press of the ON/OFF button, perform an appropriate exit routine, and then shut down the instrument.  Whether or not you shut down the instrument programmatically, a keypress of the ON/OFF button of greater than three seconds will force a hardware shutdown.  Further, whether or not a user presses the ON/OFF button, you can always programmatically shut down the instrument at any time.

To detect a keypress on the ON/OFF button, you must connect jumper J13 on the processor board.  Doing this connects processor Port A pin PA0 to the ON/OFF key.  Configure PA0 as an input capture (IC1) to evoke an interrupt on a rising edge.  To enable programmatic shutdown, reconfigure PA0 as an output, set it high for at least 10 microseconds, then set it low.  This action will cause an immediate shutdown.

Continuously ON

The Handheld is held continuously ON whenever external or battery power is present by connecting jumper J4 on the Power Board.  With this jumper installed the Handheld can not be turned OFF short of removing all sources of power.

Using Battery Power

The Handheld may be powered by six rechargeable size AA NiMH 2100mAH batteries for the times shown in Table 2‑1.  The battery pack provides 15 watt-hours of energy between charges.  The batteries are specified with a nominal cell voltage of 1.2 V (for a pack voltage of 7.2 v) and actually range from 1.375 for a fully charged but unloaded cell to 1.0 V at full discharge.

Table 2‑1      Typical Battery Operation Times Using Six 2100 mAH Cells.

Service Time (Hours)



Backlight OFF       0 WildCards installed.


Backlight ON        0 WildCards installed.


Backlight OFF       4 WildCards Installed


Backlight ON        4 WildCards installed.

Replacing the Batteries

The batteries are replaced by first removing the battery cover which is held in place with six Phillips machine screws.  A battery holder is permanently affixed to the Handheld.  The batteries are a tight fit in the holder, but they can be carefully removed and replaced by lifting them up at the center, where each series pair of AA cells meet.  When replacing them you must be sure to insert them with the correct polarity;  + and – signs are inscribed in the aluminum holder.

Charging the Batteries

The batteries charge automatically when the power adapter is plugged in, whether the instrument is ON or OFF at the time.  There are two charging states, fast-charge (at a 1.3 A rate) and trickle charge (at a 72 mA rate).  Whenever the power adapter is plugged in the batteries charge at either of these two rates, with the charger automatically switching between rates.

When power is first applied, the batteries fast-charge to approximately 80% of full charge within 90 minutes, then trickle charge for the remainder of their capacity over five hours.  At high ambient temperatures the fast charge is terminated earlier to prevent battery overheating, so more time is required for trickle charging.

The Handheld starts fast-charging the batteries when they are first installed and the power adapter is plugged in, or when the power adapter is first plugged in.  It switches to trickle-charge when any of the conditions of Table 2‑2 are met.  For safety, fast-charge is inhibited as long as the battery temperature is less than 1°C; fast-charge commences when the battery temperature rises above the 1°C threshold, and always ends if the batteries reach 52.5°C.

Table 2‑2      Conditions for Fast-Charge Termination.


Value at Termination

Fast-Charge Time Limit

> 132 minutes

High and Low Temperature Limits

<1°C or > 52.5°C

Max Rate of change of Temperature (dT/dt)

> 1°C per minute

High and Low Battery Voltage limits

<1.05 V/cell or > 1.84 V/cell

Change in Battery Voltage (-dV/dT)

< -5 mV/cell per minute


Be Careful !

Use Only Size AA NiMH Batteries:

    When using battery power you must use only nickel metal hydride (NiMH) size AA batteries.  Different sized batteries, or alkaline, nickel cadmium (NiCad), or lithium ion (Li-Ion) batteries, can not be charged safely in the Handheld and may overheat, burst, catch on fire or otherwise damage the Handheld.

Don’t Trickle Charge Too Long:

    To get optimum life from your batteries they should not be left on trickle charge for longer than needed.  So your instrument should not be left plugged in to a power source when it is not used.  Instead, it should be trickle charged for a maximum of 12 hours (typically, 5-7 hours are needed), then unplugged.

Battery Lifetime

NiHM batteries are a great battery technology to use in handheld instruments.  They are more reliable and have much better cycle life than NiCAD batteries.  Although they aren’t as light as Lithium batteries, they are an order of magnitude less costly and have much greater lifetime.  The shelf life of NiMH batteries is reliably several years if they are maintained between 10°C and 30°C and if they are charged at least once each year.  They are conservatively specified by their manufacturer at a one-year shelf life at temperatures from -20°C to +35°C.  Do not store them where the temperature fluctuates or is ever less than -20°C or greater than +45°C.

The cycle life of NiMH batteries depends on the conditions under which they are charged and discharged.  Ideally, they should be charged at temperatures between 10°C and 30°C, where they charge most efficiently. Charging should not be initiated at temperatures less than 0°C or greater than 40°C, nor continue at temperatures greater than 55°C.  The Mosaic Handheld limits fast-charge to battery temperatures between 1°C and 52.5°C.

Under ideal conditions state-of-the-art NiMH batteries lose only 10-20% of capacity over 500 charge cycles.  Significantly reduced service time despite proper charging means that the life of the battery has been attained, and the batteries should be replaced.  Normally the batteries should last at least 2 years if not overcharged or undercharged.

Tethered Operation

In tethered operation, the Handheld may be powered by applying any unregulated DC input voltage between 15 and 30 volts.  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 Handheld requires 20 watts.  Of this, 17 watts is used for fast charging and all other instrument operations need only 3 watts. Consequently, if batteries are not used only 3 watts is required to fully power the instrument.

You can supply power to the Handheld by connecting jumpers J1 and J2 on the Power Board.  If these jumpers are installed closest to the edge of the board, pins 1 and 2 of the DB-25 are connected to the Personality Board; if they are installed closest to the DB-25 connector, pins 1 and 2 of the DB-25 can be used to supply ground and power (EXT_VIN) so that the Handheld may be powered through the DB-25 connector as well as through its power jack.

Using the Power Adapter

The AC adapter provided with your Handheld supplies 24-28V at 20 W.  Plug the adapter into the jack located on the right side of the enclosure near the bottom. 

Power Metering

The Handheld can measure its own battery voltage and current. 

Monitoring Battery Current

The current is converted to a voltage and presented as a signal named MON_CHARGER.  This signal is routed to the Processor Board where it can be connected to PE6 (one of the processor’s 8-bit A/D inputs) by installing Processor Board jumper J3.  The relationship between this voltage and the battery current is given in Table 2‑3.

Table 2‑3      MON_CHARGER Voltage as a function of battery current.


Battery Current



-1.3 A

Battery is fast charging at 1.3 A


-.071 A

Battery is trickle charging at 71 mA

0.564 to 0.291

0 to 1.5 A

Battery is discharging during operation


I = (0.564 – V) / 0.182

Battery is discharging during operation

The battery current, Ibat, is related to the MON_CHARGER voltage as,

Eqn. 2‑1      Ibat = (0.564 – MON_CHARGER) / 0.182

This current is negative during charge, and positive during discharge.

Monitoring Battery Voltage

The battery voltage is monitored through an attenuating (by a factor of 4) resistive voltage divider and presented as a signal named MON_BATT/4.  This signal is routed to the Processor Board where you can connect it to PE7 by installing Processor Board jumper J4.  The measured voltage is roughly one quarter of the battery voltage.  However the battery is in series with a 0.22 ohm resistor, so that the measured voltage is actually the sum of the battery voltage and the small voltage drop across the resistor. Consequently, the actual battery voltage is given by,

Eqn. 2‑2      Vbat = 4 x MON_BATT/4  +  Ibat x 0.22 , or,

Vbat = 4 x MON_BATT/4  +  0.22 x (0.564 – MON_CHARGER) / 0.182

in which Ibat is the signed battery current of Eqn. 2‑1.  For example, while the battery is fast-charging the actual battery voltage is four times the measured MON_CHARGER/4 minus 0.286V.

For an example of how to measure battery voltage take a look at the source code of the demo application that shipped with your Handheld.



<< Previous | Next>>

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