190 likes | 280 Views
Designing a USB Enabled Sensor Interface for Data Acquisition. Chris McMurrough April 3 rd , 2008. Overview. Introduction Basics of embedded USB Introduction to the PIC18F4550 Circuit and PCB design using Eagle Layout Editor PCB fabrication Working with SMDs
E N D
Designing a USB Enabled Sensor Interface for Data Acquisition Chris McMurrough April 3rd, 2008
Overview • Introduction • Basics of embedded USB • Introduction to the PIC18F4550 • Circuit and PCB design using Eagle Layout Editor • PCB fabrication • Working with SMDs • Programming the PIC18F4550 with CCS C Compiler • Using the device in Windows
Introduction • Suppose you are designing a PC application that must take input from various types of real world sensors. How can this be accomplished? • Data Acquisition Card • Expensive, usually occupies a PCI slot, not very portable, requires a specific API, many interfacing options absent, not programmable • Data Acquisition Module • Expensive, usually bulky, requires a specific API, many interfacing options absent, not programmable • Microcontroller with RS232 • Requires a level translator and power supply • There is an alternative…
Introduction (continued) • Microcontroller interfaced via USB • Many interfacing options available on one chip • No external power supply required • Fully programmable • No special API required • Inexpensive • Small in size • Can use as many devices as the host USB bus will support • The bottom line • This approach allows you to build a fully customizable device for data acquisition and control
Basics of embedded USB • There are two types of hardware USB interfaces available for microcontrollers • Off-chip USB transceivers, such as FTDI • On chip USB transceivers, such as on the PIC 18F4550 • There are many software interfaces that can be used • Bulk Transfer • Interrupt Transfer • HID (Human Interface Device) • VCP (Virtual COM Port) • The basic USB device consists of… • Hardware interface • Software interface • Driver for host PC
Introduction to the PIC18F4550 • USB capable microcontroller from Microchip • Requires minimal external components • Many interfaces available • A2D • GPIO (General Purpose IO) • UART • I2C (Inter-Integrated Circuit) • SPI (Serial Peripheral Interface) • USB • PWM generation and capture (Pulse Width Modulation) • Specifications: • Clock: 8 MHz, Up to 48 MHz with external oscillator • RAM: Up to 2 Kb • Program Space: 32 Kb • Data EEPROM: 256 bytes • Full speed USB 2.0 transceiver
Circuit and PCB design using Eagle Layout Editor • Complete solution for Printed Circuit Board design • Allows you to create circuit schematics, and then board layouts • Signal traces are automatically routed • Projects can be exported into files suitable for manufacture • Freeware version available for boards under 4 x 3.2 inches
PCB fabrication • Once board design has been completed, they can be manufactured • The design is exported to a manufacturing format, such as a GERB • The GERB is sent to a manufacturer • Average turnaround time, about 1 week • Cost for a single board is about $30 • Cost per board drops dramatically as volume increases • Manufacturers often sponsor student projects or offer substantial discounts
Working with SMDs • Surface mount devices are a class of components that are soldered onto the metal pads on the PCB • Advantages • Much smaller than through-hole • Can be mounted quickly with practice • Overall produces higher quality solder joints • Disadvantages • Requires hot air rework station, which can be expensive • Can be intimidating at first
Working with SMDs (continued) • Mounting process • Solder paste is applied to PCB pads • Component is placed on pads • Hot air heats the component, causing the solder to become viscous and adhere to pads and component pins • Process is repeated until everything is mounted
Programming the PIC18F4550 with CCS C Compiler • CCS C compiler is a popular compiler for PIC devices • The usb_cdc library is provided for USB communications • Library functions behave exactly like a serial port • getc() -> usb_cdc_getc(); • putc(char) -> usb_cdc_putc(char); • kbhit() -> usb_cdc_kbhit() • usb_cdc_init() enables the interface
Using the device in Windows • Install the CDC driver (it is probably already there) • When plugged in, the device will appear as a COM port • In your program, just read and write to the port • You can select any baud rate you want, the driver handles the rest • Using .NET, just include System.IO.Ports and create a SerialPort object
Links • Eagle Layout Editor • www.cadsoft.de • Advanced Circuits • www.4pcb.com • CCS C Compiler • www.ccsinfo.com • Surface mounting video (time permitting) http://www.youtube.com/watch?v=0O2UEGLJeAI