Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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 [
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,
= 1,
= 0.001.
a)
b)
Fig. 11 a) Results obtained with
= 1,
= 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