■ PHOTO 2. Simple, elegant, powerful, and cheap thanks
to reusable hardware and firmware technology.
companion power supply bypass capacitor that are tied in
parallel to the PIC’s VCAP pin.
The PIC24’s I/O pins can source and sink up to 18
mA each. To ease the burden on the PIC’s I/O subsystem,
I’ve buffered visual indicators LED1 and LED2 with a
couple of NUD3105 MOSFET switches. The NUD3105
devices are designed to drive small inductive loads up to
500 mA. Note the absence of series gate resistors for Q1
and Q2 as the required gate resistors are internal to the
NUD3105 components. If you decide to drive inductive
loads with the NUD3105s, the freewheeling diodes are
also integral to the devices.
ASSEMBLING A PIC24F/PIC32MX
USB TRAINER
Every electronic component mounted on the
assembled Trainer you see in Photo 2 can be mounted
and soldered by hand. The entire USB Trainer design
■ SCREENSHOT 1. The LEDs can be separated from the
PIC24FJ256GB106’s I/O pins by simply removing the trace
jumpers between the PIC I/O pin and the MOSFET switch
gates. The header pads surrounding the PIC will mate
perfectly with an external board’s pads laid out on 0.1
inch centers.
60
June 2010
consists of 27 easy-to-find electronic components that can
be obtained from Mouser ( www.mouser.com).
In the recent past, I’ve received emails from readers
informing me that some of my Design Cycle projects are a
bit too pricey. So, to keep the costs down and Design
Cycle readers happy, the PIC24F/PIC32MX USB Trainer is
built upon an inexpensive two-sided ExpressPCB PCB.
Many of you that will build your own version of the
PIC24F/PIC32MX USB Trainer have a specific set of
external peripheral devices that you will add to the base
Trainer design. With that thought in mind, note the absence
of additional pushbuttons, RS-232 converters, or LCDs in
the base design. The idea is to allow you to add only the
peripherals you need for your application without having
to work around peripherals your application will never use.
Due to its low parts count, the PIC24F/PIC32MX USB
Trainer is simple enough to be assembled using only a
schematic diagram. To further ease your assembly burden,
the Trainer’s PCB silkscreen component identification
layout shown in Screenshot 1 matches the component
identification found in Schematic 1.
CODING THE PIC24F/PIC32MX
USB TRAINER
Thanks to Microchip, coding the PIC24FJ256GB106
for USB duty is just as easy as assembling the USB Trainer
hardware. The PIC24F/PIC32MX code is based on the
Microchip USB libraries that are part of their Application
Libraries v2010-02-09. Keeping with my low-cost mantra,
these tools are free for a download. The compiler of
choice for this project is Microchip’s C30 which isn’t free.
I get loads of emails from readers asking if the free Lite
compiler editions will run Design Cycle projects. That
you’ll have to determine for yourselves as there are an
infinite number of peripheral configurations and
applications that can or cannot be compiled with any
particular C compiler. In other words, there are just some
things that I can’t test.
In that the USB stack is provided as a package, all we
have to do to utilize the packaged tools is build or modify
four user files. Modification of existing USB stack user files
is the easier road to follow. A word of caution: DO NOT
modify the USB stack package files under any
circumstances. With that, let’s begin our coding task with
the HardwareProfile.h file:
#ifndef HARDWARE_PROFILE_H
#define HARDWARE_PROFILE_H
#include “HardwareProfile - EDTP 24F-PIC32MX USB
TRAINER.h”
#endif
That’s it for the HardwareProfile.h file. Now, let’s do
the real work inside of the HardwareProfile - EDTP 24F-
PIC32MX USB TRAINER.h file. The first order of business is
to put our brand on this USB code: