USB Data acquisition with PIC18F4550
This project is simple and small component count USB data acquisition or USB DAQ. The main core of USB device is PIC18F4550 .The
firmware for PIC modified from Microchip CDC library.
I use Delphi 6 on PC side to communicate with PIC18F4550
source code availible.
Specifications
- 8 Digital output
- 8 Digital input
- 8 Analog output
- No external power required
- Simple ASCII command
- 3 command to communicate PC with PIC
Figure 1 Schematic
Command
CommandPC Send PIC respone
Write digital output *ANS#13-
Read digital input *B#13*BHH#13
Read analog input*AK#13*AKXXXX#13
When :
N = bit that we need to set or clear (0-7)
S = state of bit (0-1)
HH = Input status from digital input port (00-FF)
K = Channel of analog input ( 0-7)
XXXX = analog input value in decimal of 10 bit binary (0000-1023 )
#13 = end of command
Example to set bit 0 of digital output
*A01#13
Example to clear bit 0 of digital output
*A00#13
Example to read digital input
*B#13
then PIC respone with
*B7F#13
This mean bit 7 of digital input was low
Example to read analog input channel 4
*C4#13
then PIC respone with
*C41023#13
This mean that analog channel 4 have 5 volt on this channel
becuase 1023 = 3FFh
Figure 2 PC side software
When connect this USB Data acquisition with PC then windows ask for driver after driver installed(only first time) you will have a new COMx if not connect the COMx not create by Windows.
How to set configuration read this article
Download source code
Firmware C18 Compiler , Delphi 6 example,Windows device driver (Win2K/XP)
No comments:
Post a Comment