circuit board or panel-mounted, as you prefer.
Building the Circuit
Table 1 shows the current drawn under various
conditions to allow you to tailor your power supplies
depending on what you choose to include in the design.
I used a breadboard for the prototype, but techniques
such as stripboard, custom PCB (printed circuit board),
etc., could also be used. Unfortunately, the free version of
Eagle only creates circuit boards up to 80x100 mm (which
is too small), so there is no PCB design at present.
Care should be taken when laying out the oscillator
circuitry. Keep track lengths short and position the crystal
and its capacitors close to the MCU. Also keep the analog
(op-amps) area separate from the logic to avoid digital
noise on the analog signals.
The capacitors shown to the bottom right of the
schematic are for general decoupling. Position a 0.1 μF
capacitor as close as possible to each chip. These provide
good high frequency decoupling. The larger value
polarized capacitors are for bulk decoupling and are not
so critical in their placement.
Construction is straightforward. Anyone with basic
electronic skills (soldering, reading a schematic, and so
on) will be able to put the unit together.
Software: The Brains
mistralXG's software is written in C, using the
Microchip C18 compiler (student edition). The compiler
and MPLAB integrated development environment (IDE)
are both available as free Windows downloads from the
The individual modules are listed in Table 2. Each C
module is shown with its directory path relative to the main.c
module and a brief description of its function. A matching
*.h file for each *.c module contains definitions used in the
other modules. There are some additional *.h files included
with the framework to control things such as how the
MCU senses when the USB port is connected to the PC.
Framework File Changes
The completed circuit needs ground, +5V, +12V,
and -12V power supplies; ±12V are only needed if the
daughter board is used. If not, the op-amps can also be
omitted and only +5V is required.
■ TABLE 1. Power supply measurements.
Condition +5V +12V -12V
supply supply supply
50 mA Not Not
250 mA Not Not
600 mA 25 mA 25 mA
No daughter board,
No daughter board,
backlight on max.
Daughter board playing
music, backlight on max.
50 mA from the
MCU I/O pin
Main user function
system\usb\usbctrltrf\ usbms.c is the
usbctrltrf.c modified usbgen.c
from the framework
42 March 2009
Several sample applications are included with the USB
Firmware Framework. mistralXG is based on the Generic
sample with a few simple text changes to reflect that a
MIDI streaming interface is being used. The framework
comprises all modules in Table 2, with the exception of
those in the user\ directory.
Many framework files are used without change, but a
few have to be tweaked. For example, io_cfg.h defines the
pinout for Microchip's standard evaluation boards, so this
was modified to match mistralXG's I/O. Perhaps
the trickiest file holds the USB descriptor (auto
files\usbdsc.c). This file and its associated header
file (usb\usbdefs\usbdefs_std_dsc.h) define the
information that is presented to the PC during
enumeration. Getting them right is quite difficult —
I managed to blue screen my Windows XP system
several times while experimenting with mistralXG's
descriptors. It's likely you'll need to make descriptor
changes if you plan to extend the features of
mistralXG. I recommend reading the relevant USB
specifications carefully before starting!
A couple of important pieces of information
are held in the descriptors. These are the vendor ID
and product ID (VID and PID). The PC uses these
to identify a device during enumeration. mistralXG
has its own unique VID/PID combination.
USB to MIDI
MIDI to USB
mistralXG Application Firmware
The main() routine (Example 1) first initializes
the system by calling the framework initialization
code which, in turn, calls the
initialization routines for the
application modules. It then
loops around servicing the user
■ TABLE 2.