Conference PaperPDF Available

Hardware and software designing of USB based plug n play data acquisition device with C# and LabView compatibility

Authors:

Abstract

As interdisciplinary sciences getting popular with every passing day, the need of electronic devices interfacing with a PC is also increasing. Very useful products (Arduino, RasberryPi, etc) made their way in commercial market to cater such needs however they require programming skills, specific IDE's (integrated development environments) and lack compatibility with useful tools such as NI (National Instrument) LabView[1] and C#. Since these two (C# and LabView) are supposed to be widely used for their user friendliness, but unfortunately are not prioritised as a development option due to lack of supporting hardware which is either too expensive, rare or too complex. Hence in this research the data acquisition device (DAQ) has been designed and developed to provide a hassle free solution for those who choose LabView to avoid programming or programmers who want to control and observe electronic devices such as sensors/actuators as a part of their research projects. This device is connected to PC over USB and interfaces with C# and LabView using a Direct Link Library (.dll file). It can control up to 8 Digital Inputs, 8 Digital outputs, 8 Analog Inputs and 2 Analog (PWM) outputs. Moreover some Virtual Instruments such as 4 Channel Oscilloscope, Function Generator, Logic Analyzer and PID controller has also been developed in C# to cater the needs of students and researchers.
2015 IEEE 21st International Symposium for Design and Technology in Electronic Packaging (SIITME)
978-1-5090-0332-7/15/$31.00 ©2015 IEEE 1 22-25 Oct 2015, Brasov, Romania
Hardware and Software Designing of USB based
plug n play Data Acquisition Device with C# and
LabView compatibility
Sameed Tehami, Muhammad Ahmed Khan
Electrical Engineering & Information Technology
Technische Hochschule Ingolstadt
Ingolstadt, Germany
tihamee@gmail.com / engineerahmedkhan@gmail.com
Osama Mazhar
Computer Vision and Robotics
University of Burgundy
Burgundy, France
osamazhar@yahoo.com
Abstract As interdisciplinary sciences getting popular with
every passing day, the need of electronic devices interfacing with
a PC is also increasing. Very useful products (Arduino,
RasberryPi, etc) made their way in commercial market to cater
such needs however they require programming skills, specific
IDE’s (integrated development environments) and lack
compatibility with useful tools such as NI (National Instrument)
LabView[1] and C#. Since these two (C# and LabView) are
supposed to be widely used for their user friendliness, but
unfortunately are not prioritised as a development option due to
lack of supporting hardware which is either too expensive, rare
or too complex. Hence in this research the data acquisition device
(DAQ) has been designed and developed to provide a hassle free
solution for those who choose LabView to avoid programming or
programmers who want to control and observe electronic devices
such as sensors/actuators as a part of their research projects.
This device is connected to PC over USB and interfaces with C#
and LabView using a Direct Link Library (.dll file). It can
control up to 8 Digital Inputs, 8 Digital outputs, 8 Analog Inputs
and 2 Analog (PWM) outputs. Moreover some Virtual
Instruments such as 4 Channel Oscilloscope, Function Generator,
Logic Analyzer and PID controller has also been developed in C#
to cater the needs of students and researchers.
KeywordsEmbedded Computing; LabView; C#; Data
Acquisition.
I. INTRODUCTION
A. Background
Data acquisition is a versatile and important tool in
engineering sciences. However in Electrical engineering where
PC interface with sensors and actuators is needed, this Data
Acquisition (DAQ) is not confined to just „Acquisition‟ of data
but also includes pre and post processing, to make it
understandable for a computer or user and provide storage
options. Multiple approaches on different technologies have
been made by different individuals [2] and organizations [3] in
this regard but they are mostly complex or expensive. Since
most engineering-related software concentrate on resolving
only one specific task (the task the system is designed to do),
each engineering system needs and uses its own software
platform, requiring special resources for both the development
and operating processes. [4]
The need of such an interface card was felt while pursuing
research project related to Feedback and Control Systems
during engineering studies. In order to implement designed
controllers and observe their response in powerful tools such as
MATLAB and LabView, appropriate tools were not available
and practices were limited to simulations only. While searching
online for an affordable solution, Elektor USB Data acquisition
card [2] was found online. The .hex file, setup, installation
guide and DIY instructions were available however working
with that card was not a practical approach due to limitations
both from hardware and software sides. The card wasn‟t
compatible with Windows7 or later edition; it was only
compatible with LabView 2008 and prone to noise thus
unstable during operation.
B. Challenges and Requirements
A particular data acquisition device was needed which must
have following properties:
USB interface.
Compatible with different platforms
(Windows/Linux).
Plug n Play.
Noise immunity such as inductive interference.
Simple interface with C# and LabView.
Stable to errors (exceptions handled).
Some routine applications such as multiple channel
low frequency Oscilloscope, Function Generator,
Logic Analyzer, PID and Digital controller design
with data storage to cater the testing needs of
researchers.
Fig. 1. Process Flow Diagram of DAQ
DAQ Initialization Handshake with
Computer
User Interface
(LabView/C#
GUI)
Data processing
as per user
requirement
Data logging for
post processing
Safe Execution of
application
2015 IEEE 21st International Symposium for Design and Technology in Electronic Packaging (SIITME)
978-1-5090-0332-7/15/$31.00 ©2015 IEEE 2 22-25 Oct 2015, Brasov, Romania
II. MATERIALS AND METHODOLOGY
A. Hardware
The main component of DAQ card is 8bit microcontroller
from Microchip naming PIC18F4550. The reasons to choose
this particular IC are (a) USB interface support (b) Low cost
and easy availability (c) multiple Input and output ports (d)
Dual Inline Package for rapid prototyping. Beside this, a USB
B type port was used to connect this device with PC using
commercially available USB A to B type auxiliary cable. Other
circuit components were resistors, capacitors, LED indicators,
and terminal connectors. The circuits were developed on single
sided Printed Circuit Boards. Figure 2 contains the circuit
diagram of DAQ device.
B. C# DAQ Interface
The most important task was to establish a stable and
independent interface between DAQ device and PC over USB.
There are two parts of code for this task; first part is firmware
whose stack “USB Framework 2.9” was obtained from
Microchip library. This firmware was developed around the
stack in C language, compiled in MikroC compiler and then
programmed on PIC18F4550 IC using Pickit2 programmer [7].
Second part is accessing this USB device from C# application.
For this purpose, USB Generic HID C# Class Library was used
provided by Microsoft for .NET applications under GPL
licence and completely free for use [6]. Figure 1 shows DAQ
initialization, process and safe termination process.
In this library, there are initializing parameters and in order
to make it driverless and platform independent, A DLL (direct
link Library) namely “usb_daq.dll” was drafted to establish
USB connection and directly access the values on IO ports of
microcontroller. The USB interfacing code along with
functions to access the IO ports were embedded in the
usb_daq.dll file which is simply included as reference in the
beginning of code allowing user to keep the development
environment simpler and easily accessible [7].
During C# application development, user simply includes
the usb_daq.dll file and call following commands from main
form to access the Digital and Analogue IO (Input Output)
ports.
The necessary thing to consider here is assigning PID
(Product Identity) and VID (Vendor Identity). These unique
identities of USB device are used to differentiate them from
other USB devices attached to system. Since this isn‟t a
commercial product, VID was set to 0001 and PID as 1333 in
hexadecimal format to avoid complexity with other USB
devices attached to PC.
To simplify the hassle of individually calling each memory
buffer from PIC18F4550, customized functions were written in
usb_daq.dll file which allow developer to access these buffers
by calling simple functions such as:
enable_a_in (pin number) // to enable analog
channel up to desired pin number (0 7).
get_a_in (pin number) // get analog data from
indicated pin of analog input port.
get_d_in (pin number) // get digital data from
indicated pin of digital input port.
set_a_out (pin number, value) // set analog value
at the indicated pin of PWM port.
set_d_out (pin number) // set digital logic high at
the indicated pin of digital output port.
clr_d_out (pin number) // clear digital logic high at
the indicated pin of digital output port.
The object oriented interface helps user to develop the
application in user friendly environment paving way for further
research and development.
III. DESIGN AND DEVELOPMENT
A. Simulation
This usb_daq.dll was tested on Proteus Simulation tool. A
virtual USB port was initialized in the simulator and the
firmware was tested by linking it with a sample application
which displays the values on Input and Output ports. The
values set in C# application were observed in simulator
environment paving way for hardware prototype. Figure 3
shows the test carried out in Proteus Simulator.
Fig. 3. Proteus Simulation of usb_daq.dll.
Fig. 2. Schematic of DAQ circuit
2015 IEEE 21st International Symposium for Design and Technology in Electronic Packaging (SIITME)
978-1-5090-0332-7/15/$31.00 ©2015 IEEE 3 22-25 Oct 2015, Brasov, Romania
B. Prototype
After successful simulation of USB interface, a prototype was
developed in order to carry out smooth testing of functions
developed and help during development of applications. This
includes indicators such as LED bar and switches for Digital
Input Outputs, Variable resistor for Analog inputs and 3mm
LEDs for Analog Outputs. This prototype was designed
properly on Single sided Printed Circuit Boards to make it
presentable. These sub boards were fixed over a card board for
safety purpose. Figure 4 contains pictorial representation of
Prototype circuit.
C. Application development in C#
To depict all these IO in C# application, An UI (User Interface)
was developed with graphing utility and analogue knobs from
NI Measurement Studio for .NET applications [8]. All Input
Outputs were interfaced in this application enabling user to test
the device thoroughly as well as help in further application
development. Below is attached Figure 5 which contains
testing results carried out on the developed UI.
Further application development was carried out to design
general applications which can cater different testing needs of
individuals. For this purpose multiple applications were
developed such as 4 channels Oscilloscope, Waveform
Generator, Logic Analyzer, PID control Lab, Convolution
applet, Digital Signal Processing Lab, and Digital Controller
Design Lab. The only user specific application was On/Off
controller which was used to control the temperature of a
thermal actuator with a temperature sensor as feedback
element. All other applications were general purpose and could
be used for any suitable task. Figure 6 contains the main menu
to access these applications.
All these applications are individual project within themselves
and thus explaining them individually will result in
unnecessary elongation of this paper. The most used
application among them was PID (Proportional Integral
Differential) control Lab and hence explained here briefly. It
was a helpful tool in carrying out various Feedback Control
tasks. This application allows user to enter values of
Proportional (Kp), Integral (Kd) and Differential (Kd) gains with
set point and loop cycle time and calculates the desired PID
output by observing the feedback from the system[9][10]. A
pictorial description of PID controller Lab is given in figure 7.
Fig. 7. PID Controller developed in C# Performing a PI control of an
unstable system.
Fig. 6. Applications developed in C# compatible with USB DAQ.
Fig. 5. UI developed in C# accessing control to all IOs of USB DAQ.
2015 IEEE 21st International Symposium for Design and Technology in Electronic Packaging (SIITME)
978-1-5090-0332-7/15/$31.00 ©2015 IEEE 4 22-25 Oct 2015, Brasov, Romania
D. DAQ-NI LabView Integration
NI LabView, In spite of its difficult interface and non
conventional block programming, still is the most powerful
software in terms of system development and process design.
The usb_daq.dll file developed for C# was interfaced with NI
LabView. The interface is quite simple and just like „plug n
play‟ device; it is connected and executed in the software side.
A sub VI (Virtual Instrument) has been made in name of “USB
DAQ CARD V2.0” which can be included in the main loop
and the IO ports can be utilized as per user requirements. This
can be used to develop custom applications by user. figure 8
shows a GUI (Graphical User Interface) developed in LabView
to access all the IOs of USB DAQ device.
From back end development view of LabView as shown in
figure 9, it can be clearly observed that steps carried out in
order to establish connection of DAQ with LabView VI were
same as those carried out in C#. The PID and VID were
assigned to class constructor and then simple checks for
finding target device and connectivity were checked. Rest is
simple as all Input Outputs can be connected to actuators and
indicators to control their actions and observe their response on
front end.
E. Final Hardware
During testing, it was observed that static charge and inductive
interference can result in erroneous values especially at
Analogue Inputs. This was an issue of high concern because in
real systems, noise immunity is necessary. Therefore in final
design, anti aliasing Low pass filters with cut off frequency of
1.2 KHz [11] were placed at all 8 channels of analogue Inputs.
This resulted in smooth readings free from noise and provided
additional stability to DAQ. Moreover terminal headers were
placed at IO ports allowing user to easily connect any
actuator/sensor at required port. The top view of silk screen and
final hardware are shown in figure 10.
IV. DISCUSSION AND FUTURE POSSIBILITIES
This DAQ device was used in multiple feedback control
applications such as DC motor speed control, Position control
of a geared DC motor, Inverted Pendulum, Temperature
Control System, Ball balance on a beam and Flow control. The
results were highly encouraging and this multipurpose device
decreased the workload by many folds.
In order to attain the status of Industrial monitoring and
Control System, This DAQ can be communicated via Ethernet
(LAN) to transmit data on long distances in industry. Moreover
industrial standard actuators and sensors can be linked to it by
developing signal conditioning modules which can transmit
data on USB voltage levels (0-5 volts).
REFERENCES
[1] Naveenkumar R, Dr Prasad Krishna “Low Cost Data Acquisition and
Control using Arduino Prototyping Platform and LabVIEW”,
International Journal of Science and Research (IJSR), India Online
ISSN: 2319-7064
[2] José Luis RupérezFombellida “USB Data Acquisition Card”, Elektor
Electronics Worldwide, November 2007.
[3] Data Acquisition, National Instruments. http://www.ni.com/data-
acquisition
[4] Cezar Liviu CERVINSCHI “Data Acquisition and Storage in
Engineering Systems”, Database Systems Journal vol. II, no. 3/2011.
[5] Muhammad Ali Mazidi., PIC Microcontroller, Prentice Hall, New York,
2007.
[6] Faraz Rasheed, C# School, First Edition, Programmer‟s Heaven, 2006.
[7] Joe Mayo, Microsoft Visual Studio 2010 A Beginners Guide, Mc Graw-
Hill, New York, 2010.
[8] Measurement Studio for .NET Languages, NI Discussion Forums,
http://forums.ni.com/
[9] Francis H. Raven, Automatic Control Engineering, Mc Graw-Hill, New
York, 1995.
[10] Araki M. PID Control, Control Systems Robotics and Automation - Vol.
II.
[11] Sophocles, J. Orfanidis, Introduction to Signal Processing, Prentice Hall,
New York, 1995.
Fig. 9. Back end development view of USB DAQ interface with LabView.
Fig. 8. GUI (Graphical User Interface) of USB DAQ interface with
LabView.
Fig. 10. Silk screen of final DAQ hardware with anti aliasing filter highlighted
in red. The actual hardware is also shown beside it.
... Since ease of use was primary in the creation of the USB, many features have been designed in to make USB devices among the easiest to install. USB devices are true "plug-and-play" [4]. The host PC automatically identifies a peripheral when it is plugged in, and searches for the software necessary to operate it. ...
Article
An abstract is not available.
Data Acquisition and Storage in Engineering Systems
  • Cezar Liviu
Cezar Liviu CERVINSCHI "Data Acquisition and Storage in Engineering Systems", Database Systems Journal vol. II, no. 3/2011.
Programmer " s Heaven
  • Faraz Rasheed
Faraz Rasheed, C# School, First Edition, Programmer " s Heaven, 2006.
Microsoft Visual Studio 2010 A Beginners Guide
  • Joe Mayo
Joe Mayo, Microsoft Visual Studio 2010 A Beginners Guide, Mc Graw-Hill, New York, 2010.
Low Cost Data Acquisition and Control using Arduino Prototyping Platform and LabVIEW
  • R Naveenkumar
  • Prasad Dr
  • Krishna
Naveenkumar R, Dr Prasad Krishna "Low Cost Data Acquisition and Control using Arduino Prototyping Platform and LabVIEW", International Journal of Science and Research (IJSR), India Online ISSN: 2319-7064
USB Data Acquisition Card
  • José Luis Rupérezfombellida
José Luis RupérezFombellida "USB Data Acquisition Card", Elektor Electronics Worldwide, November 2007.
Back end development view of USB DAQ interface with LabView. Fig. 8. GUI (Graphical User Interface) of USB DAQ interface with LabView. Fig. 10. Silk screen of final DAQ hardware with anti aliasing filter highlighted in red. The actual hardware is also shown beside it
  • Fig
Fig. 9. Back end development view of USB DAQ interface with LabView. Fig. 8. GUI (Graphical User Interface) of USB DAQ interface with LabView. Fig. 10. Silk screen of final DAQ hardware with anti aliasing filter highlighted in red. The actual hardware is also shown beside it.