Anda di halaman 1dari 5

Enhanced mTouch Capacitive Touch Eval.

Kit: PIC32CTMUEvalBoard_2ChanSliderDemo

What This Demo Does

This demo supports the two channel slider daughter card. In it two ADC
channels are used to measure your finger position along slider and between
one and sixteen LEDs are lit to indicate the sensed position.

Required Development Resources:

a. Enhanced mTouch Capacitive Touch Evaluation Kit (DM183026-2)
(2-Channel Slider Sensor Daughter Board, PICKit Serial Analyzer)
b. PIC32 CTMU Capacitive Touch Evalukation Board (AC323027)
c. A debugging/programming development tool
- PICkit 3 In-Circuit Programmer/Debugger (PG164130), or
- MPLAB ICD 3 In-Circuit Debugger (DV164035), or
- MPLAB REAL ICE In-Circuit Emulator (DV244005)
and the RJ-11 to ICSP Adapter (AC164110)
d. MPLAB IDE V8.63 or better and C32 Compiler V2.02
d. MPLAB.X V 1.20 and XC32 Compiler V1.00

Optional Development Resources:

a. PICKit Serial Analyzer (PKSA) (DV164122)
(If not using the Enhanced mTouch Capacitive Touch Evaluation Kit)

Plugging in DirectKey Daughter Card:

Plug the 2-Channel Slider daughter card into the bottom of the edge connector
instead of the top of the connector. This aligns the button signals with ADC
channels AN0-AN1.

Compiling and Downloading the Demo:

1. Extract the contents of the .ZIP file to someplace convenient on your hard
drive. The folder's MPLAB project is self-contained, and can be moved to
any location after extraction, as long as the directory names inside the
project are not changed or the contents moved.

2. Load the demo code into MPLAB by double clicking the appropriate
dot mcp project file:


2. Connect the REAL ICE debugger to J1 on the evaluation board's left edge.
3. Power up the board by connecting a USB port on your computer to the mini-B
port on the evaluation board's left edge.

4. Choose the REAL ICE debugger tool in MPLAB IDE by selecting

Debugger>Select Tool and then click on 6 REAL ICE.

The REAL ICE tab of the output window should display something like this:
Connecting to MPLAB REAL ICE...
Firmware Suite Version...... 01.26.81
Firmware type......................PIC32MX
Target Detected
Device ID Revision = 00000000

5. Build the project by selecting Project>Build All.

6. Download your code into the evaluation board microcontroller by

selecting Debugger>Programming>Program All Memories.

7. Run the demo code by selecting Debugger>Run.

(The LEDs on the top side of the board should all light up, starting with
the right (LED 1) and ending with the left-most (LED 16). Then the LEDs
should turn off in the reverse order.)

Loading PICKit Serial Analyzer Firmware

Out of the box the PICKit Serial Analyzer (PKSA) does not support the serial
data stream provided by the demo. Firmware must be loaded using the application
found in the directory

mTouchCapDemos\Utilities\mTouch GUI\Pickit Serial Loader

Launch the executable PickitLoaderAuto.exe to load the firmware. Follow the

instructions shown in the dialog window to reset the PKSA and then to load
the Windows device driver after the PKSA is programmed.

Running the Demo:

This demo displays the button or slider status on the row of LEDs.
Additionally, the UART interface to the PKSA can display button signals and
decoded status using a Profilab executable found in a subdirectory of the

1. After the PICKit Serial Analyzer (PKSA) drivers have been installed,
connect it to the evaluation board:

J2 RA9 <---> PKSA Pin 1 (Tx) (optional)

J2 RC4 <---> PKSA Pin 6 (Rx)
GND <---> PKSA Pin 3 (GND)

Connect the PKSA to your computer using a USB cable. Depress the PKSA push
button until all three LEDs light. Then release the button. If the UART
interface on the evaluation board is operating the red "Busy" LED should
light, showing that there is UART traffic between the demo application and
the PKSA.

The UART interface runs at 115.200 kbaud, no parity, 8 bits, no stop bit.
Typically the PKSA driver provides com port 9, but you may need to check
which com port is available using Windows Device Manager.

2. Monitor button signals and decode status using a hyperterminal application

or the Profilab executable provided. (On Windows 7 you can use a free
hyperterminal alternative such as RealTerm.)
The Profilab mTouch GUI executable is located in the folder

mTouchCapDemos\Utilities\mTouch GUI\Executable

After the executable is launched, you will notice 7 icons on the upper right
side of the GUI window. The are, from left to right:

Load Settings (F3) (Folder Icon)

Save Settings (F2) (Diskette Icon)
Print Front Panel (F5) (Printer Icon)
Copy Front Panel to Clipboard (F4) (Clipboard Icon)
Configuration: Application (Red Screwdriver Icon)
Configuration: Hardware (F6) (Red Screwdriver Icon)
Configuration: Front Panel (F7) (Hammer/Wrench Icon)

Hit F6 and verify the serial interface is using the correct com port on
your PC. If it is you should be seeing activity on the GUI. Try to
assert buttons or a slider value and verify the correct activity shows up
on the GUI. The plots will show the measured voltage (in adjusted ADC
counts) for each of the capacitors on the daughter card. The GUI will
also show you the decoded button or slider status. You can use these
signals to tune the settings in mTouchConfig.h to improve sensitivity and
noise immunity.


If nothing is happening on the GUI:

3.1 Verify that the red "Busy" LED on the PICKit Serial Analyzer is lit.
If it isn't reset the PICKit Serial Analyzer by pressint its button
until all LEDs are lit. You should now see activity on the GUI.

3.2 Verify that the GUI is using the correct com port by checking the
Windows Device Manager under "Ports (COM & LPT)"

3.3 If the GUI still doesn't work, check that there is activity on the
com port using a hyperterminal. If there is no activity you need
to reboot your PC and start over. (Sorry, that's the best we can do.)


Microchip has provide the Profilab mTouch GUI as an aid to development.

We have found Profilab to be a useful tool, costing less than 100 Euros.

If the GUI executable is helpful, your welcome.

But Microchip cannot provide additional support for it, other than giving
out the Profilab project and a compiled executable. If it doesn't work
you're on your own. (Sorry.)

If the GUI still doesn't work you can still capture com port traffic
with a hyperterminal application and plot the results using Excel or
Open Office's Calc.

A Note on Charge/Discharge Cycles

The ADC on PIC32 devices has a much higher bandwidth than those on 16 bit and 8
bit devices from Microchip. Consequently the sample and hold (SAH) capacitor
in the ADC is much smaller. Thus is is necessary to use multiple ADC charge or
discharge cycles to achieve the same performance. The number of cycles is
defined in mTouchConfig.h by:

// CTMU charge timing for Rev 4

#if defined( PIC24HJ128_CAP_TOUCH_EVAL_BOARD )

#elif defined( DSPIC33FJ128_CAP_TOUCH_EVAL_BOARD )

#elif defined( PIC32MC764F128_EXPLORER_16_BOARD ) | \


#elif defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) | \

#define ChargeDelay() asm("NOP");asm("NOP");asm("NOP");asm("NOP") // 100

// Eleven ChargeDelay's brings unasserted button voltage to half scale

#define CTMU_CHARGE_DELAYS ChargeDelay(); ChargeDelay(); \
ChargeDelay(); ChargeDelay(); \
ChargeDelay(); ChargeDelay(); \
ChargeDelay(); ChargeDelay(); \
ChargeDelay(); ChargeDelay(); \


For some button capacitor designs only three cycles are needed to drive the
voltage of an unasserted button to Vdd/2. For other buttons you may need to
add additional cycles by modifying the timer call back routine found in the
file TimerCallbackFunc1.c, TimerCallbackFunc2.c, or TimerCallbackFunc3.c.

Checking For Correct Button 'Scope Signals


You never really know if the application is working to peak performance without
examining the signals at each button capacitor. For that you will need a good
active single-ended 'scope probe, such as a Tektronix 6245, with a probe
capacitance less than 1 pF. Put channel one on the button capacitor signal and
channel two on the reference channel. (Use a regular probe on channel two.)

The Powerpoint briefing,

"Additional Information for PIC32 CVD and CTMU Demos.pdf",

has examples of button signals, both unasserted and asserted, for all cap
touch measurement techniques.

PICKit Serial Analyzer User's Guide - DS51647
AN1250 "Microchip CTMU for Capacitive Touch Applications" - DS01250
mTouch Advanced Capacitve Evaluation Kits User's Guide - DS41385
Profilab-Expert Software: