Sei sulla pagina 1di 10

FINAL REPORT

PROGRAMMING SEMINARY I
AUTHOR: BLANCA LUCERO CERVERA LOPEZ
DATE: 13-12-12

INTRODUCTION

The seminary programming goal is use the MatLab software; we use a sequential programming
and the mathematics tools of the software that we apply for to make the calculus, example of the
path and error in the torques of each robots joints. Also we did task of acquire and generate
analogies signals with acquisition devices of National Instruments, the NI9221 to the signals
acquisition and the NI9263 for the signals generated since PC. In this seminary, we did several
tasks and a final project using the LabVIEW software, where we use a close loop system, with a RC
circuit as the plant, a PI controller for to apply in the acquisition of data. The next is a short
explication about the tools used in the seminary.

MatLab
Is an environment for to do applications where there is mathematic calculation and allows see its
results in graphics. MatLab integrates numerical analysis, lineal algebra, signal processing and
graphic visualization. It has several programs specialized that are named TOOLOXES as the Data
Acquisition and they extend the number of functions that MatLab has in its main program. In this
seminary we dont utilize some toolboxe. The window of MatLab has three important parts: the
Workspace, the Command windows and the Command history, too it has an programming editor
for to generate files .m named scripts that can to be utilized in other programs similar to MatLab
as the Octave and in this scripts the user program the projects with a sequential programming.

Acquisition Data Device of National Instruments used:
NI9221: Is a module for the acquisition of voltage analog signals of 12 bits and 8 channels. Its
operate range is 60 .
NI9263: Is a module for to generate voltage analog signals simultaneous of 4 channels and 16 bits.
Its operate range is 10 .

LabVIEW, (Laboratory Virtual Instrument Engineering Workbench):
Is a programming language graphic used to the design of acquisition data systems, of
instrumentation and control. It allows an easy integration with hardware, especially with device of
measurement, acquisition and processes data. The LabVIEW consist at two parts:
1. Block Diagram:
Here we realize the graphic programming of make the system.
2. Front Panel:
This part of the software is used for to see the graphic programming be in the
Block Diagram, it has two types of tools: the controls that see inputs to diagram
block, and the indicators that show the output of systems programmed in block
diagram.



Fig.1 MatLab Window: 1= Command Window that is where the user write the mathematics operations that
he want do, but arent saved. 2= Workspace show the variables, structures, objects, etc used to in the
applications that the user do in the editor of MatLab. 3= Command History saves the commands used in the
command windows. 4= Current Folder is a files explorer to do easy the search of the files.




Fig.2 Editor of MatLab, here the user does the programming of the algorithms that he designs. 1=Place to
write the code in a sequential programming. 2=Options to run the code that the user do.

1
2
3
4
1
2

Fig.3 Left: Front Panel of LabVIEW showing some controls and indicators. Right: Block Diagram where the
user does his programs.


DEVELOPMENT

One the applications of MatLab is solver differentials equations with its integrators as the ode23
and the ode45, this facilitates the simulation of lineal systems of the differential equations to the
user know the behavior at the time of the systems. In the editor of MatLab the user can create
functions that facilitate the programming and the application of the integrators of the software.
One function read constants or variables of input and creates other variables of output, and
streamlines the calculus in the applications.

For example, the simulation of the positions of an mechanism, where the user know the model of
this mechanics, as a robot of the two free grades, where we can some integrator of MatLab for to
solver the model of the robot and with the options to graphic we know the behavior of the joints
across of the time. Too is possible to do simulations to apply controllers and to graphic the error in
the position of end effector or the joints respect some desired position.

At this seminary we did task applying the ode45 integrator for to simulate the changes at the
position of the joints of a robot of two free grades, having the dynamic model of the mechanism.
The structure of ode45 for the applications that we did in the seminary is:

[, ] = 45(_, [

],
0
)

Where and return the solution of the equations of the robots model, in this case those
equations are in the function named _. To each integrator the user should give
an interval of time [

] to solver the differentials equations system, and initials conditions


0

for stars the integration of the equations.

Other applications of the MatLab consist in the data acquisition using its library daqregister()
and the NI9221 module for read a voltage analog signal in the MatLab, creating a script for we can
read the module and see the signal using the tools to graphic of the program, while the NI9263
module we using in the seminary, we can generate voltage analogies and direct signals in the
script and we send the signals to RC circuit. With both modules we obtained a system of data
acquisition, creating a script where we configures the modules, we create the voltage signal, we
send this signal to an output of NI9263 and we also read the output of circuit using a input of the
NI9221 and reading this module in the itself script graphing both signals, the generated and the
received. With this task we can read analogies signals in MatLab using the correct module and we
can generate voltage signals and applicate this signals to some systems. This practices that we did
in the seminary arent in real time, although MatLab has the option for to read and send signals in
real time.












Fig.4Block diagram of a system of data acquisition, where is generated the signal in MatLab and we send this
signal to the plant of some system with a DAC because the signal generated in MatLab is discrete, and where
we read the output of the plant whit a ADC because in this case is analog signal, and we apply a controller to
signal received in the pc using a script of MatLab.


The library Daqregister(nidaq) is required to read the modules NI9221 and NI9263 in MatLab
and we should execute this library before connect the modules to PC, also we should install the
drivers to those modules, we install the software Measurement & Automation of National
Instruments v.5.0 for install all the drivers to the modules and verify its correct operation. To the
acquisition and generation of the signals we calculate the send time and read time, the send and
read frequency of signal. The size of the sample sent is different to the sample that is read, also its
speed sampling.

For to realize the data acquisition in a script of MatLab first we configure the modules giving the
sampling frequency, the channels used in each module, and the type module used.


Input Signal of the
plant and created
in Matlab
Input
Signal of
the plant
System
Plant
ADC
NI 9221
DAC
NI 9263
CONTROLLER

Fig.5 Code of MatLab used to configure the NI92263 and NI9221 modules, to generate a signal and read a
signal in one script. SampleRate is the sampling frequency for each module. SamplesPerTrigger is the trigger
time in each simple of the input signal.



Fig.6 RC circuit for the task where we apply the data acquisition at MatLab

Also we can simulate the effect of the controllers as PI, PD, PID, etc, of some system. This was did
in the programming seminary and was applied to a planar robot of two free grades, we can
graphic the change in the position in each joint, the change of the error when the controller was
applied, the controller was a PI in this case.


NI9221
NI9263
FINAL PROJECT

To finalize the seminary we realize a project where we apply the acquisition of signals with the
NI9221 and NI9263 modules, but we use the LabVIEW software, too we apply a PI controller to the
RC circuit of the figure 6. For the design and application of the controller we realize:
- Configure the NI9221 and NI9263 modules in LabVIEW
- Generate and send the input signal to the RC circuit
- Acquisition of the output signal of the circuit
- Design and application of the PI controller to the circuit


INPUT SIGNAL TO THE CIRCUIT:

For we generate the input signal of the RC circuit, first we generate the voltage signal simulated in
LabVIEW using the Signals Simulator of the software. We generate a square signal of 2Vpp with a
frequency of 0.1Hz. This signal was introduced to circuit with the NI9263 device. At the figure 7
you see the programming in LabVIEW for generate the signal, for generate during a prolonged
time we used a while loop that will last the time need for the simulation of the signal. For
configure the NI9263 device we use the DAQ Assistent module of LabVIEW, bur this module is
the National Instrument, we only congifure the parameter of frequency, channel, etc, because
LabVIEW is 100% compatible with this modules. We configure the signal for send one sample and
the process for this is showed in the figure 8.


a) b)
Fig.7 Generation of the input signal of the RC circuit; we using the NI9263 module. A) Block diagram of
LabVIEW where we generate the signal and we send the signal to the NI9263 using the DAQ Assistant. B)
Block diagram of the generation of the analog signal to RC circuit without feedback.


NI 9263
(DAC)

Filter
RC





Fig.5 Configure the NI 9263 module, the configuration of the NI9221 module is similar to this.


OUTPUT SIGNAL OF THE RC CIRCUIT AND PI CONTROLLER

Once we generate the input signal of the circuit and we send the signal to the circuit, we used the
NI9221 module for to see the output signal of the circuit in LabVIEW and we can create a close
loop system, and we apply the PI controller for correct the error in the output signal of the circuit
and the input signal of the circuit. The configuration of the NI9221 module is similar to the NI9263,
but we change the type express task and the parameters in the DAQ Assistant. For the correction
in the error between signals we use PID module of LabVIEW to generate the PI controller. With
this module, we only select the correct gain proportional Kp and the correct time integral Ti, we
give zero to the derivate time Td. The reference signal of the controller is the signal that we
generate in the first part and the signal to control is the output signal of the circuit that we can
manipulate in LabVIEW with the help NI9221 module, therefore the output signal of the controller
is the input signal of the circuit. For send signals down of the limit of the device NI9221 and
NI9263 we use a output range in the PI module of the 9. At the figure 8 is showed the
programming in LabVIEW of the controller applied to the signals of the circuit.
1. With the right bottom
of mouse you select
the Express option
of the menu that is
showed and after you
select the DAQ
Assistant module.

2. Once that you do this, a
window is showed to
create a new task express
and you select Generate
Signals, Analog Output,
Voltage options. This
because we want a analog
voltage input signal to the
RC circuit.

3. After the window of DAQ assistant is showed
and here you configure the parameters of the
NI9263module, we select the 1 sample (on
Demand) option.
4. Once that this is did, we configuration of the
module is finish in Ok bottom.

a)








b)

Fig.8 a) Block diagram of LabVIEW with the system with feedback and the PI controller applied to the circuit.
b) Block diagram general of the system with the controller applied to the circuit.

We graphic the signal generated, that is the reference signal, the input signal of the circuit, that is
the output signal of controller, and the output signal of the circuit, that is the signal of feedback of
the system. But for this, we create a array with the samples of the signal during all time in
LabVIEW for to save this array in a file .lvm compatible with Microsoft Excel and graphic the signal
in this program. All this was because LabVIEW graphic only the sample actual in each instant of
time but dont save the signal complete.


RESULTS

At the figure 10 you see the results obtained during the program executed, we probe the program
with several values for the parameters of the PI, and we obtain the better results with the

= 1,

= 0.001. Once the execution of the program is stooped the samples of the signals are
save in the array named Dynamic array and the file .lvm is created in form automatic.
After this array is open in Excel to graphic the signals in this program.

() +
1

()

0

PI Controller
NI 9263
(DAC)


+

Filter
RC



NI 9221
(ADC)

(Signal
Reference)


Fig.9 Block Diagram of LabVIEW with the PI controller and the Dynamic Array to graphic the output signal of the circuit that is the signal
controlled in the LabVIEW. Here is showed two flat sequence that we use for generate, send and read the signals in LabVIEW and for create the
array to graphic the signal controlled. The flat sequence gives the sequence correct for execute the program in LabVIEW becase this software
dont has a sequential programming.
Flat Sequence 1
Flat Sequence 2
While Loop


a)
b)
Fig. 10 a) Results with

= 1,

= 0.01, first is showed the signal generated as the signal of reference to


controller, after is showed the output of the controller that is the input to the circuit and finally is showed the
signal controlled that is the output of the circuit and is the signal that is compared with the reference signal.
b) Results obtained with

= 1,

= 0.001.


a)
b)
Fig. 11 a) Results obtained with

= 1,

= 0.01, b) Results obtained with

= 1,

= 0.001.
-1.50
-1.00
-0.50
0.00
0.50
1.00
1.50
V
o
u
t

o
f

t
h
e

c
i
r
c
u
i
t

(
V
)
t (seg)
Parameters of controller PI: Kp=1, Ti=0.01
-1.50
-1.00
-0.50
0.00
0.50
1.00
1.50
V
o
u
t

o
f

t
h
e

c
i
r
c
u
i
t

(
V
)
t (seg)
Parameters of controller PI: Kp=1, Ti=0.001
Signal generated Controller Signal Controlled Signal

Potrebbero piacerti anche