USB Data Acquisition Using Peripheral Interface Control Microcontroller

Supervisory Control and Data Acquisition (SCADA) systems have been widely used in industry applications. This paper describes design and implementation low-cost universal serial bus (USB) Data Acquisition (DAQ) which connected with computer through USB port and tested in SCADA system, the designed Data Acquisition build using new generation of microcontroller peripheral interface control PIC18F4550 which supported with USB module and it programmed in C-Language, the developed DAQ have 13 input analog channels and 16 digital I/O lines. At personal computer (PC) side, graphical user interface (GUI) application is designed using Laboratory Virtual Instrument Engineering Workbench (LabVIEW) program as SCADA software to acquire and monitor data and control all system I/O. The system consists of hardware part and software part. The main part of hardware is a data acquisition card


Introduction
. The use of electronic equipment has been growing rapidly.Electronic systems controlled by software have marked great strides in today's rapidly changing environment.New electronic equipment with lots of enhanced features can be easily embedded using software and can be made to work efficiently.However, this requires careful monitoring besides the presence of the user.Some examples are: systems for monitoring parameters such as temperature, pressure in closed spaces, systems for commanding different execution elements, data logging systems and the like.A widespread operation found in the above applications is data acquisition [2] .Data from the external world is read, processed, used for decisions and eventually, memorized.The digital systems may be PCs with dedicated interfaces through which a good userfriendly environment can be provided.There are different ways of connecting a microcontroller based system to a PC: the industrial system adapter ISA or peripheral control interface PCI connector, the serial port, the parallel port, or the USB port.USB based data acquisition systems can be developed using USB controllers like ISP1181 connected to P89c51RD2 microcontroller [2] , using PICI6F877 microcontroller [3]   or using T232/245BM USB interface chip to microcontroller [8,9] .Proposed system uses PIC18f4550 with inbuilt USB hardware stack.This paper describes low-cost data acquisition hardware with USB interface basing on the PIC18f4550 microcontroller and tested in both simulation and real hardware case as SCADA system.First, a short review on USB has been discussed.Second, the developments of the system and a brief on hardware and software resources used have been discussed.This is followed by system integration and validation results.Finally conclusions and the development directions are given.

USB in Brief
USB is a serial bus conceived for an easy and expandable way for connecting peripherals to PC.Its final purpose is to establish the unique interface for the PC peripherals.Similarly different peripherals are connected with the same cables and connectors.The specific features of each peripheral are assumed by the software.USB divides the serial compatible equipment into 2 classes: hubs and functions.A hub has connections, called ports, where the functions may be connected.A function is peripheral equipment which achieves a certain type of operations.USB Speeds are High Speed -480Mbits/s, Full Speed -12Mbits/s and Low Speed -1.5Mbits/s.USB specification defines four transfer/endpoint types, Control Transfers, Interrupt Transfers, Isochronous Transfers and Bulk transfers.The Universal Serial Bus is host controlled [2] .A USB device indicates its speed by pulling either the D+ or D-line high to 3.3 volts [3,4] .A full speed device, pictured in figure 2(a) uses a pull up resistor attached to D+ to specify itself as a full speed device.And in figure 2(b) a pull up resistor is attached to D-to specify itself as low speed device.These pull up resistors at the device end will also be used by the host or hub to detect the presence of a device connected to its port.Without a pull up resistor, USB assumes there is nothing connected to the bus..The more common USB descriptors are Device Descriptors, Configuration Descriptors, Interface Descriptors, Endpoint Descriptors and String Descriptors.Enumeration is the process of determining what device has just been connected to the bus and what parameters it requires such as power consumption, number and type of endpoint(s), class of the product and the like.The host then assigns the device an address and enables a configuration allowing the device to transfer data on the bus.

Systems Design
Figure 3 shows the block diagram of PIC-USB Data Acquisition System .It uses familiar microcontroller from Microchip Technology Incorporated PIC® Peripheral interface control series called pic18f4550 [6]  for a channel to be selected and a conversion to be initiated, without waiting for a sampling period and thus, reducing code overhead.The output of the sample and hold is the input into the converter, which generates the result via successive approximation.The ADC converts an analog input voltage to a 10-bit digital value through successive approximation.The system design passed through two parts software and hardware.

Software Design Circuit connection and PIC programming
The system designed and tested as SCADA system in simulation using LabVIEW program instead using traditional SCADA software which represent GUI our man machine interface(MMI).Proteus 7 professional software programs from Lab center Electronics used to design and test the DAQ circuit and the source code program was written in C language and compiled using mikroC for PIC software program.The microcontroller and other components of the circuit are connected as shown in the figure5, and it need to install the virtual USB from the start<< all programs<<Proteus 7 professional software program and figure6 show the flow chart for the source code program.

Device Enumeration
The main step for identification is USB device enumeration -this complex sounding feat is in fact the initial communication with the USB host (your PC) when the device tells the host what it is and how it wishes to communicate.USB communication is performed using 'endpoints' which send information either to the host or to the device.As well as setting up the communication channels the device must also pass its device name and two other important values: the VID and product ID.The VID is the Vendor ID and identifies the manufacturer of the device.To get your own VID you need to pay a thousand bucks or so to the USB standards body.In this example Microchip VID is used to save the expense.If you are serious about producing and selling devices you will need to register one of your own.The Product ID together with the VID they form a unique identifier for your device.When your device first enumerates Windows will store the VID and Product ID combination for the device; this is true even if you use a generic driver like the HID since it cuts down on the amount of time Windows needs to get your device ready.This is important because, if you decide to change your device's enumeration information (add more endpoints, etc.), you will also need to at least change the Product ID before reconnecting otherwise you will get 'Device not started' errors even if you code is flawless (from experience I've noticed that Linux is not quite as fussy and tends not to complain if you keep the same VID/ Product ID combination).
In mikroC program which the source code is written in C language it possible for user programmer to create its own descriptor file for the microcontroller from Tolls<<HID Terminal <<Descriptor, to write vendor name and product name and it saved in the same location on the program folder, I named my DAQ SCADA System as shown in figure7.After all mentioned we successfully run the system (SCADA) in simulation program and the interface and communication are satisfied between the microcontroller (DAQ) side and the LabVIEW (GUI) side case1 all analog sensor represented by variable resistor are easily displayed as gauges indicator also the digital sensor represented by digital switches and displayed as 8 LEDs in LabVIEW front panel in other hand we made full control on the 8LEDs connected to the output of the DAQ which can control the 8actuaters through drive circuit the figure 18 show samples of 2 cases for testing the system.Case2 the 4 analog sensor connected to 4 signal generator each signal generator set to generate square, saw tooth and sinusoidal signal respectively .

Hardware Design
Hardware design consists from these stages:

Building the Card
Figure 19 Shows the USB interface that has been adapted by making use of RC4, RC5, and VDD AND VSS of PIC18F4550 microcontroller.The RC4 line (PIN23) is used as data line D-and connect to pin2 of USB B type connector and The RC5 line (PIN24) is used as D+ data line and connect to pin3 of USB B type connector, VDD pin11 is connect to pin1of USB connecter and VSS pin12 is connect to pin4 (GND) of USB connector .The USB interface lines are connected to pins 2 and 3 (D-and D+ channels) of USB B Type connector.osc1(pin13) and osc2 pin( 14) connected to crystal20MHZ frequency and connected to ground across two capacitor each of 22pf .VUSB (pin 18) connect to ground across 1nf capacitor.All other ports of microcontroller are used, 13 lines for input analog channels, 8 lines for digital sensor and 8 for digital output as shown in figure 19(b).

Download hex file which contain source code program in into the microcontroller Testing the DAQ in real hardware
The system tested in real hardware it used to read two signals from variable resistor and 8 digital signals from digital switch and receive control signal from the user from front panel and it accomplished successfully figure 20 show the proto type card connected with PC via USB port.

Conclusions
PIC microcontroller based USB Data acquisition has been designed, programmed, implemented and test in SCADA system.The system hardware developed is a low-cost alternative to commercially available systems that use USB controllers because it cost only 20$.Using a unique combination of hardware and software with optimum utilization of the resources, a low cost Data Acquisition System has been developed to data logging and supervisory control in mini industry process and monitor voltage variations from analog channels, for temperature controlling and the like.The experimental result shows that the system can work stably ,effectively and the results show currently support the hardware and software developed.Further, this system can also be used to increase the USB transfer speed.There is a possibility of continuous development of the software which can be adapted to various transducers, to calculate and display various parameters.