Seminar Topics & Project Ideas On Computer Science Electronics Electrical Mechanical Engineering Civil MBA Medicine Nursing Science Physics Mathematics Chemistry ppt pdf doc presentation downloads and Abstract

Full Version: PIC Communication with USB pdf
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
PIC Communication with USB

[attachment=48435]

Introduction

The purpose of this article is to explain how to interface a PIC microcontroller to a PC via the USB port.
Although the concepts are universal, the examples are specifically for use with mikroElektronika’s
MikroBASIC Pro for PIC.
My journey into PIC microcontrollers and USB communication began with my interest in Microsoft® Flight
Simulator 2004. I am an instrument-rated private pilot, but due to medical reasons, I can no longer fly. FS
2004 gives a very good simulation of instrument flight. There are some things it won’t do, nor allow me to do,
but overall it satisfies my urge to fly in an instrument environment. Plus, it allows me to fly aircraft that in real
life I couldn’t afford to really learn how to fly. My wonderfully patient wife thinks it’s a dumb game because
she can’t ever see anything happening, but I know I’m cruising at 24,000 feet at 180 knots in pressurized
comfort and in total control!
I already had a flight yoke, throttle quadrant and rudder pedals, but I wanted to increase the realism of flight
simulator by using real physical switches and knobs instead of mouse clicks to activate avionics and cockpit
functions. I purchased the Super Rotary Encoder from Desktop Aviator which allowed me to interface 16
rotary or 32 push-button switches and up to 8 axes. By doing some fancy programming and installing a
program called FSUIPC I was able to interface with over 100 push-button switches and 10 rotary switches.
Unfortunately, I needed to add one more rotary switch, but I was out of room.

Hardware

Usually the first place I look for inexpensive goods is Ebay®. I found a large number of PIC programmers, but
I felt I needed more. Searching the internet I found mikroElektronika, a company in Serbia, that produces both
the hardware and software that I needed.

Development Board

The EasyPIC6 development board they manufacture allows me to program many different PIC
microcontrollers, and contains the circuits to develop and test LEDs, LCD graphical and character displays,
switches, one analogue to digital converter (ADC) and various interfaces. It also contains a port expander and
access to the microcontroller’s ports via header pins.
The software that comes with the board contains examples designed for the PIC16F887 microcontroller, and the
board comes with one of those microcontrollers. What a great tool for developing different applications! In
fact, I purchased an additional Serial 7-Segment Display board for a particular application I have in mind. The
EasyPIC6 did not come with the stand-alone 2x16 LCD display, the graphic LCD 128x64 with touch screen,
nor the one-wire temperature sensor, but I was able to purchase those from other suppliers.

Software

MikroElektronika allows you to download trial versions of each of their compilers. Assembly language is a bit
cumbersome, I know nothing of Pascal, I know some C language, but I am very fluent in BASIC, so I decided
to purchase their MikroBASIC Pro compiler for PIC. Prior to purchasing the full license, I used the trial
version with the included examples to test my USB connections.

Personal Thanks

Before going any farther, I want to extend my thanks to the mikroElektronika (ME) team for their excellent
products and support. Their hardware, software, libraries and examples made my development work almost
effortless. Sure I had a pretty steep learning curve, but the tools provided by ME made learning how to program
a microcontroller pretty easy. The ME team put a lot of hard work into both the hardware and software, and
provide the results at a very reasonable price.

USB Descriptor

This was probably the most difficult for me to get right. The USB descriptor is used during the enumeration
process to identify the peripheral device to the host, i.e. identify the microcontroller to the PC. This has to be
correct, otherwise your microcontroller will not be recognized and you will get a device error message.