USB Data Acquisitio
José Luis Rupérez Fombellida
This data acquisition card for connection to the USB has eight digital outputs, eight digital inputs, two 10-bit analogue outputs and eight 10-bit analogue inputs for voltage swings of 0 to 5 V. The system’s core is a Microchip USB-savvy microcontroller type PIC18F4550 programmed in C. The circuit isbuilt on a compact PCB and requires no external power supply.
Measurement cards and systems you can connect to a PC have been a constant success factor in the long history of Elektor. Whether it’s stand-alone for control over the RS232 or LPT ports (anyone remember those?), as a plugin card for the ISA bus (ditto) or now, recently, for the USB, it’s a blockbuster if our readers can (1) generate andread digital control signals, and (2) do the same for analogue signals! The card described in this article could be at the hub of a great many applications to do with measurement and control. the PC recognise a valid USB device! In this article hopefully we cater for readers only interested in digital and analogue connectivity with the real world, as well as for those with a deeper interest inhow USB actually works on a microcontroller and, equally important, can be made to do something really useful — all at very low cost, of course.
DIP40 device which should attract applause and other expressions of approval from the I-hate-SMDs camp.
The circuit diagram of this small wonder of technology is given in Figure 1. It’s not much more than a powerful CPU (IC1) surroundedby input and output connectors and a few status LEDs. The function of the connectors is as follows, with the relevant PIC lines in brackets: K1 = 8-bit digital output for 05 V TTL swing (RD0-RD7). K2 = USB connector for linking to your PC (RC4-RC5). K3 = 8-bit digital input for 0-5 V TTL swing (RB0-RB7). K4 = two analogue outputs for 0-5 V swing (RC1-RC2). K5 = 8 analogue inputs (AN0/
PIC18F4550 for USB
Fortunately, there are microcontrollers that make the USB interface between the PC (the host) and the circuit we wish to design (the device) more or less transparent. That’s because they are provided with dedicated hardware and software to implement USB ‘the easy way’. All totally invisible of course to those who just want to use the USB device yet know nothing about it (which shouldnot include you)! One such processor is Microchip’s PIC 18F4550, which has the additional advantage of lots of (free) software being available for it. Also, the device is available as a
We want USB
Arguably, RS232, ISA and even Centronics are things of the past when it comes to digital and analogue signals specifically for measurement and control by/on a PC. USB is the way forward both in termsof speed and ease of connection, although the latter is a complex matter especially as far as software is concerned. For example, a lot of thought (and time) goes into making
Personal Download for villanueva, henry | copyright Elektor
elektor - 11/2007
digital & analogue; input & output
R1 10K C1 R2 470R 11 32 C3 100n RD0 RD2 RD4 RD6 1 3 5 7 9 VDD VDD100n 18 C2 470n
2 4 6 8 10 RD1 RD3 RD5 RD7 RD0 RD1 RD2 RD3 RD4 RD5 RD6 RD7
1 19 20 21 22 27 28 29 30
MCLR RD0 RD1 RD2 RD3 RD4 RD5 RD6 RD7
6 2 3 4 5 7 8 9 10 33 34 35 36 37 38 39 40 AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7
CCP1 1 3 5 7 9 R3 27R R4 27R 2 CCP2 4 6 8 10
1 2 3 4 5 6
15 RC0 CCP2 16 RC1 CCP1 17 RC2 23 RC4 24 RC5 25 RC6 26 RC7
AN0/RA0 AN1/RA1 AN2/RA2 AN3/RA3 AN4/RA5 AN5/RE0 AN6/RE1 AN7/RE2 RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7
AN0 AN2 AN4 AN6 1 3 5 7 9 2 4 6 8 10 AN1 AN3 AN5 AN7
RB0 RB2 RB4 RB6 1 3 5 7 9 2 4 6 8 10 RB1 RB3 RB5 RB7