0% found this document useful (0 votes)
21 views61 pages

Practica 4

This document describes an experiment using an Arduino to acquire data samples over time and plot the voltage values on a graph. The program code defines a function to read analog-to-digital converter (ADC) values serially from the Arduino and store them in a vector to plot the voltage versus time. The results show the voltage readings for 800 samples of a digital input signal to the Arduino ADC.

Uploaded by

Edson Paz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views61 pages

Practica 4

This document describes an experiment using an Arduino to acquire data samples over time and plot the voltage values on a graph. The program code defines a function to read analog-to-digital converter (ADC) values serially from the Arduino and store them in a vector to plot the voltage versus time. The results show the voltage readings for 800 samples of a digital input signal to the Arduino ADC.

Uploaded by

Edson Paz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

TRABAJO DE DISEÑO DE SISTEMAS DE CONTROL

LABORATOTIO No 4

Adquisición de datos Con Arduino

1. Probar los Programas y adquirir datos almacenándolos en un vector para luego despegarlos en una
gráfica de muestras vs tiempo escalado en voltios vs tiempo
%EJEMPLO1
2. function voltaje=ADC_Serial(muestras)
3. close all;
4. clc;
5. voltaje=0;
6.
7. delete(instrfind({'port'},{'COM3'}));
8. puerto=serial('COM3');
9. puerto.BaudRate=9600;
10.
11. fopen(puerto);
12. contador=1;
13.
14. figure('Name','Grafica voltaje')
15. title('GRAFICA VOLTAJE ADC-SERIAL');
16. xlabel('Numero de Muestras');
17. ylabel('Voltaje (V)');
18. grid off;
19. hold on;
20. while contador<=muestras
21. ylim([0 5.1]);
22. xlim([0 contador+50]);
23. valorADC=fscanf(puerto,'%d')';
24. voltaje(contador)=valorADC(1)*5/1024;
25. plot(voltaje);
26. drawnow
27. contador=contador+1;
28. end
29. fclose(puerto);
30. delete(puerto);
31. end
PARA UN CASO DE 800 MUESTRAS, PARA LA ENTRADA DE UNA SEÑAL DIGITAL

ans =

Columns 1 through 3

3.8232 3.2910 3.8281

Columns 4 through 6

3.5107 3.8281 3.7549

Columns 7 through 9

3.8232 3.8232 3.8232

Columns 10 through 12

3.7256 3.8281 3.7549

Columns 13 through 15
3.8232 3.8574 3.8281

Columns 16 through 18

3.7744 3.8232 3.6865

Columns 19 through 21

3.8232 3.8135 3.8232

Columns 22 through 24

3.8428 3.8232 3.7354

Columns 25 through 27

3.8281 3.7402 3.8232

Columns 28 through 30

3.8574 3.8232 3.8184

Columns 31 through 33

3.8232 3.7109 3.8232

Columns 34 through 36

3.7939 3.8232 3.8623


Columns 37 through 39

3.8232 3.7451 3.8281

Columns 40 through 42

3.7207 3.8232 3.8330

Columns 43 through 45

3.8232 3.8184 3.8232

Columns 46 through 48

3.7012 3.8232 3.7500

Columns 49 through 51

3.8281 3.8623 3.8232

Columns 52 through 54

3.7695 3.8281 3.7158

Columns 55 through 57

3.8281 3.8281 3.8281

Columns 58 through 60
3.8428 3.8232 3.7207

Columns 61 through 63

3.8232 3.7451 3.8281

Columns 64 through 66

3.8672 3.8232 3.8037

Columns 67 through 69

3.8281 3.7012 3.8232

Columns 70 through 72

3.8037 3.8232 3.8477

Columns 73 through 75

3.8281 3.7402 3.8281

Columns 76 through 78

3.7354 3.8232 3.8525

Columns 79 through 81

3.8232 3.8232 3.8232


Columns 82 through 84

3.7061 3.8232 3.7793

Columns 85 through 87

3.8232 3.8672 3.8281

Columns 88 through 90

3.7549 3.8232 3.7256

Columns 91 through 93

3.8281 3.8379 3.8281

Columns 94 through 96

3.8330 3.8232 3.7158

Columns 97 through 99

3.8281 3.7500 3.8281

Columns 100 through 102

3.8672 3.8281 3.7842

Columns 103 through 105


3.8232 3.7061 3.8281

Columns 106 through 108

3.8232 3.8232 3.8477

Columns 109 through 111

3.8232 3.7256 3.8281

Columns 112 through 114

3.7402 3.8232 3.8574

Columns 115 through 117

3.8232 3.8135 3.8232

Columns 118 through 120

3.7012 3.8232 3.7939

Columns 121 through 123

3.8281 3.8574 3.8232

Columns 124 through 126

3.7402 3.8232 3.7305


Columns 127 through 129

3.8232 3.9014 3.8232

Columns 130 through 132

3.9209 3.8232 3.8037

Columns 133 through 135

3.8232 3.8770 3.8281

Columns 136 through 138

4.0088 3.8232 3.8379

Columns 139 through 141

3.8281 3.7158 3.8232

Columns 142 through 144

3.8525 3.8281 3.8721

Columns 145 through 147

3.8281 3.6670 3.8232

Columns 148 through 150


3.6865 3.8232 3.8770

Columns 151 through 153

3.8232 3.7891 3.8232

Columns 154 through 156

3.6182 3.8281 3.7988

Columns 157 through 159

3.8232 3.8721 3.8281

Columns 160 through 162

3.6963 3.8281 3.6768

Columns 163 through 165

3.8232 3.8818 3.8232

Columns 166 through 168

3.8525 3.8281 3.6475

Columns 169 through 171

3.8281 3.7598 3.8281


Columns 172 through 174

3.9355 3.8281 3.7451

Columns 175 through 177

3.8281 3.6670 3.8281

Columns 178 through 180

3.8770 3.8281 3.8965

Columns 181 through 183

3.8232 3.6621 3.8232

Columns 184 through 186

3.7061 3.8281 3.9209

Columns 187 through 189

3.8232 3.7744 3.8232

Columns 190 through 192

3.6279 3.8232 3.8232

Columns 193 through 195


3.8232 3.8867 3.8281

Columns 196 through 198

3.6816 3.8281 3.6914

Columns 199 through 201

3.8281 3.9014 3.8232

Columns 202 through 204

3.8428 3.8232 3.6279

Columns 205 through 207

3.8281 3.7988 3.8232

Columns 208 through 210

3.9063 3.8232 3.7207

Columns 211 through 213

3.8281 3.6816 3.8232

Columns 214 through 216

3.8916 3.8281 3.8623


Columns 217 through 219

3.8281 3.6523 3.8232

Columns 220 through 222

3.7305 3.8232 3.9258

Columns 223 through 225

3.8232 3.7451 3.8232

Columns 226 through 228

3.6621 3.8232 3.8525

Columns 229 through 231

3.8184 3.8818 3.8135

Columns 232 through 234

3.6719 3.8037 3.6914

Columns 235 through 237

3.8037 3.9014 3.7939

Columns 238 through 240


3.7891 3.7939 3.6133

Columns 241 through 243

3.7793 3.7939 3.7744

Columns 244 through 246

3.8574 3.7598 3.6426

Columns 247 through 249

3.7500 3.6182 3.7402

Columns 250 through 252

3.8184 3.7207 3.7598

Columns 253 through 255

3.7012 3.5400 3.6865

Columns 256 through 258

3.6475 3.6621 3.7695

Columns 259 through 261

3.6328 3.5596 3.6084


Columns 262 through 264

3.4814 3.5840 3.6572

Columns 265 through 267

3.5449 3.6328 3.5107

Columns 268 through 270

3.3838 3.4766 3.4033

Columns 271 through 273

3.4424 3.5889 3.4033

Columns 274 through 276

3.3887 3.3643 3.2227

Columns 277 through 279

3.3252 3.3789 3.2813

Columns 280 through 282

3.3887 3.2324 3.1348

Columns 283 through 285


3.1787 3.1006 3.1348

Columns 286 through 288

3.2666 3.0908 3.1494

Columns 289 through 291

3.0469 2.9053 2.9932

Columns 292 through 294

3.0176 2.9492 3.0811

Columns 295 through 297

2.9004 2.8467 2.8564

Columns 298 through 300

2.7637 2.8223 2.9346

Columns 301 through 303

2.7832 2.8662 2.7441

Columns 304 through 306

2.6221 2.7002 2.6660


Columns 307 through 309

2.6660 2.8125 2.6270

Columns 310 through 312

2.5928 2.5928 2.4805

Columns 313 through 315

2.5635 2.6367 2.5391

Columns 316 through 318

2.6318 2.5098 2.3926

Columns 319 through 321

2.4854 2.4072 2.4707

Columns 322 through 324

2.5977 2.4609 2.4658

Columns 325 through 327

2.4561 2.2949 2.4512

Columns 328 through 330


2.4805 2.4512 2.5537

Columns 331 through 333

2.4512 2.3486 2.4512

Columns 334 through 336

2.3389 2.4512 2.5488

Columns 337 through 339

2.4512 2.4951 2.4512

Columns 340 through 342

2.2900 2.4512 2.4316

Columns 343 through 345

2.4512 2.5684 2.4512

Columns 346 through 348

2.3779 2.4512 2.3242

Columns 349 through 351

2.4512 2.5293 2.4512


Columns 352 through 354

2.5195 2.4512 2.3047

Columns 355 through 357

2.4512 2.3730 2.4512

Columns 358 through 360

2.5781 2.4512 2.4170

Columns 361 through 363

2.4512 2.2900 2.4512

Columns 364 through 366

2.5000 2.4512 2.5439

Columns 367 through 369

2.4512 2.3340 2.4512

Columns 370 through 372

2.3486 2.4561 2.5586

Columns 373 through 375


2.4512 2.4805 2.4512

Columns 376 through 378

2.2803 2.4512 2.4561

Columns 379 through 381

2.4512 2.5488 2.4512

Columns 382 through 384

2.3584 2.4512 2.3340

Columns 385 through 387

2.4512 2.5391 2.4463

Columns 388 through 390

2.5000 2.4365 2.2852

Columns 391 through 393

2.4268 2.3779 2.4170

Columns 394 through 396

2.5439 2.3975 2.3389


Columns 397 through 399

2.3779 2.2412 2.3584

Columns 400 through 402

2.4219 2.3291 2.4170

Columns 403 through 405

2.2900 2.1729 2.2510

Columns 406 through 408

2.1826 2.2070 2.3486

Columns 409 through 411

2.1631 2.1826 2.1094

Columns 412 through 414

1.9824 2.0508 2.1240

Columns 415 through 417

1.9971 2.1338 1.9385

Columns 418 through 420


1.8701 1.8848 1.8164

Columns 421 through 423

1.8311 1.9678 1.7969

Columns 424 through 426

1.8701 1.7578 1.6309

Columns 427 through 429

1.7285 1.7432 1.7041

Columns 430 through 432

1.8359 1.6699 1.6211

Columns 433 through 435

1.6455 1.5479 1.6260

Columns 436 through 438

1.7334 1.6113 1.6992

Columns 439 through 441

1.5918 1.4697 1.5869


Columns 442 through 444

1.5332 1.5771 1.7236

Columns 445 through 447

1.5771 1.5527 1.5771

Columns 448 through 450

1.4502 1.5771 1.6357

Columns 451 through 453

1.5771 1.6748 1.5771

Columns 454 through 456

1.4648 1.5771 1.4990

Columns 457 through 459

1.5771 1.7090 1.5771

Columns 460 through 462

1.6113 1.5771 1.4258

Columns 463 through 465


1.5771 1.6113 1.5771

Columns 466 through 468

1.6943 1.5771 1.4990

Columns 469 through 471

1.5771 1.4795 1.5771

Columns 472 through 474

1.6846 1.5771 1.6406

Columns 475 through 477

1.5771 1.4355 1.5771

Columns 478 through 480

1.5527 1.5771 1.7285

Columns 481 through 483

1.5771 1.5088 1.5771

Columns 484 through 486

1.4502 1.5771 1.6504


Columns 487 through 489

1.5771 1.6602 1.5771

Columns 490 through 492

1.4502 1.5771 1.5039

Columns 493 through 495

1.5723 1.7090 1.5723

Columns 496 through 498

1.5576 1.5625 1.4258

Columns 499 through 501

1.5527 1.6064 1.5381

Columns 502 through 504

1.6455 1.5137 1.4209

Columns 505 through 507

1.4941 1.4111 1.4697

Columns 508 through 510


1.5967 1.4404 1.5039

Columns 511 through 513

1.4014 1.2695 1.3623

Columns 514 through 516

1.3916 1.3184 1.4600

Columns 517 through 519

1.2646 1.2256 1.2109

Columns 520 through 522

1.1377 1.1621 1.2939

Columns 523 through 525

1.1035 1.2207 1.0547

Columns 526 through 528

0.9668 1.0010 0.9961

Columns 529 through 531

0.9521 1.1328 0.8984


Columns 532 through 534

0.9033 0.8496 0.7715

Columns 535 through 537

0.7959 0.9131 0.7471

Columns 538 through 540

0.8936 0.6982 0.6348

Columns 541 through 543

0.6494 0.6250 0.6006

Columns 544 through 546

0.7959 0.5615 0.6396

Columns 547 through 549

0.5273 0.4248 0.4980

Columns 550 through 552

0.6006 0.4834 0.6494

Columns 553 through 555


0.4736 0.4297 0.4688

Columns 556 through 558

0.4004 0.4639 0.6201

Columns 559 through 561

0.4639 0.5811 0.4639

Columns 562 through 564

0.3516 0.4639 0.4541

Columns 565 through 567

0.4639 0.6543 0.4639

Columns 568 through 570

0.4688 0.4688 0.3662

Columns 571 through 573

0.4639 0.5762 0.4688

Columns 574 through 576

0.6201 0.4639 0.3857


Columns 577 through 579

0.4688 0.4053 0.4639

Columns 580 through 582

0.6299 0.4639 0.5664

Columns 583 through 585

0.4639 0.3369 0.4639

Columns 586 through 588

0.5078 0.4639 0.6299

Columns 589 through 591

0.4736 0.4346 0.4736

Columns 592 through 594

0.3809 0.4785 0.6104

Columns 595 through 597

0.4980 0.6104 0.5078

Columns 598 through 600


0.3955 0.5273 0.4688

Columns 601 through 603

0.5469 0.7031 0.5713

Columns 604 through 606

0.5811 0.5908 0.4541

Columns 607 through 609

0.6250 0.6836 0.6494

Columns 610 through 612

0.7715 0.6836 0.5811

Columns 613 through 615

0.7129 0.6152 0.7471

Columns 616 through 618

0.8594 0.7861 0.8301

Columns 619 through 621

0.8154 0.6592 0.8496


Columns 622 through 624

0.8496 0.8789 0.9863

Columns 625 through 627

0.8984 0.8252 0.9131

Columns 628 through 630

0.8008 0.9229 1.0107

Columns 631 through 633

0.9229 0.9961 0.9180

Columns 634 through 636

0.7764 0.9229 0.8594

Columns 637 through 639

0.9229 1.0742 0.9180

Columns 640 through 642

0.8984 0.9229 0.7959

Columns 643 through 645


0.9229 1.0205 0.9229

Columns 646 through 648

1.0498 0.9229 0.8301

Columns 649 through 651

0.9229 0.8594 0.9229

Columns 652 through 654

1.0645 0.9229 0.9570

Columns 655 through 657

0.9180 0.7764 0.9131

Columns 658 through 660

0.9619 0.8984 1.0205

Columns 661 through 663

0.8740 0.8105 0.8398

Columns 664 through 666

0.7715 0.7959 0.9424


Columns 667 through 669

0.7471 0.8594 0.6934

Columns 670 through 672

0.6006 0.6201 0.6689

Columns 673 through 675

0.5566 0.7617 0.4883

Columns 676 through 678

0.4980 0.4102 0.3711

Columns 679 through 681

0.3516 0.5273 0.2783

Columns 682 through 684

0.4785 0.2148 0.1855

Columns 685 through 687

0.1514 0.1758 0.0879

Columns 688 through 690


0.3418 0.0342 0.1709

Columns 691 through 693

0 0 0

Columns 694 through 696

0.1221 0 0.2197

Columns 697 through 699

0 0.0537 0

Columns 700 through 702

0 0 0.2051

Columns 703 through 705

0 0.2148 0

Columns 706 through 708

0.0195 0 0.0293

Columns 709 through 711

0 0.2490 0
Columns 712 through 714

0.1660 0 0

Columns 715 through 717

0 0.1221 0

Columns 718 through 720

0.2295 0 0.0732

Columns 721 through 723

0 0 0

Columns 724 through 726

0.1904 0 0.2051

Columns 727 through 729

0 0 0

Columns 730 through 732

0.0049 0 0.2393

Columns 733 through 735


0 0.1758 0

Columns 736 through 738

0 0 0.1025

Columns 739 through 741

0 0.2490 0

Columns 742 through 744

0.0635 0 0

Columns 745 through 747

0 0.1709 0

Columns 748 through 750

0.2148 0 0.0244

Columns 751 through 753

0 0.0049 0

Columns 754 through 756

0.2393 0 0.1855
Columns 757 through 759

0 0 0

Columns 760 through 762

0.0879 0 0.2637

Columns 763 through 765

0 0.0830 0

Columns 766 through 768

0 0 0.1758

Columns 769 through 771

0 0.2295 0

Columns 772 through 774

0.0293 0 0

Columns 775 through 777

0 0.2344 0

Columns 778 through 780


0.1953 0 0

Columns 781 through 783

0 0.0586 0

Columns 784 through 786

0.2686 0 0.0928

Columns 787 through 789

0 0 0

Columns 790 through 792

0.1709 0 0.2344

Columns 793 through 795

0 0.0342 0

Columns 796 through 798

0 0 0.2295

Columns 799 through 800

0 0.1953
>>

2. Realizar una ampliación de la adquisición de datos por medio de dos entradas analógicas y verificar
cual

el tiempo de muestreo.

function voltaje=ADC_Serial2(muestras)
close all; %Cierra todo lo que matlab tenga abierto
clc; %limpiar la pantalla
voltaje=0;%Declara variable en la cual se van a guardar los valores
voltaje1=0;%Declara variable en la que se van a guardar los datos de la primera
señal
voltaje2=0;%Declara variable en la que se van a guardar los datos de la segunda
señal

delete(instrfind({'port'},{'COM3'})); %borrar cualquier puerto serial abierto


puerto=serial('COM3'); %declaro variable llamada puerto y se crea el com4
puerto.BaudRate=9600; %Establecer velocidad de transmisión

fopen(puerto);
contador=1;

figure('Name','Grafica de dos señales')%Nombre de la ventana


title('GRAFICA DE DOS SEÑALES'); %Titulo de la grafica
xlabel('Numero de Muestras'); %Leyenda o titulo del eje x
ylabel('Voltaje (V)'); %Leyenda o titulo en el eje y
grid on; %Apagar cuadricula
hold on;
%Ciclo para capturando valores e ir realizando la grafica paso a paso
while contador<=muestras
valorADC=fscanf(puerto,'%d%d'); %Toma el valor recibido por el puerto y lo
guarda en la variable
voltaje(contador)=valorADC(1)*5/1023; %Hace la conversión a voltaje
contador=contador+1;
end

a=1; %variable contadora para las casillas del vector de la señal 1


%Ciclo para ir separando los datos de la primera señal
for i=1:2:muestras %Ciclo para contar desde la casilla 1 hasta el numero de
muestras avanzando de dos en dos
voltaje1(a)=voltaje(i);
end

a=1; %variable contadora para las casillas del vector de la señal 2


for i=2:2:muestras %Ciclo para contar desde la casilla 2 hasta el numero de
muestras avanzando de dos en dos
voltaje2(a)=voltaje(i); %guarda el valor de la casilla i del vector que contiene
las dos señales en el vector que solo va a contener la segunda señal
a=a+1;
end
vectorM=(1:1:muestras/2)% vector que va a representar el numero de muestra en el
eje X de la grafica
plot(vectorM,voltaje1,vectorM,voltaje2) %Grafica de las dos señales
%cierra y borra el puerto utilizado, borra todas las variables utilizadas
fclose(puerto);
delete(puerto);
end

PARA LA ENTRADA DE DOS SEÑALES DIGITALES

vectorM =

Columns 1 through 11
1 2 3 4 5 6 7 8 9 10 11

Columns 12 through 22

12 13 14 15 16 17 18 19 20 21 22

Columns 23 through 33

23 24 25 26 27 28 29 30 31 32 33

Columns 34 through 44

34 35 36 37 38 39 40 41 42 43 44

Columns 45 through 55

45 46 47 48 49 50 51 52 53 54 55

Columns 56 through 66

56 57 58 59 60 61 62 63 64 65 66

Columns 67 through 77

67 68 69 70 71 72 73 74 75 76 77

Columns 78 through 88

78 79 80 81 82 83 84 85 86 87 88
Columns 89 through 99

89 90 91 92 93 94 95 96 97 98 99

Columns 100 through 110

100 101 102 103 104 105 106 107 108 109 110

Columns 111 through 121

111 112 113 114 115 116 117 118 119 120 121

Columns 122 through 132

122 123 124 125 126 127 128 129 130 131 132

Columns 133 through 143

133 134 135 136 137 138 139 140 141 142 143

Columns 144 through 154

144 145 146 147 148 149 150 151 152 153 154

Columns 155 through 165

155 156 157 158 159 160 161 162 163 164 165

Columns 166 through 176


166 167 168 169 170 171 172 173 174 175 176

Columns 177 through 187

177 178 179 180 181 182 183 184 185 186 187

Columns 188 through 198

188 189 190 191 192 193 194 195 196 197 198

Columns 199 through 200

199 200

ans =

Columns 1 through 6

0 3.7097 0 3.7048 0 3.7097

Columns 7 through 12

0 3.7097 0 3.7097 0 3.7048

Columns 13 through 18

0 3.7048 0 3.7048 0 3.7048

Columns 19 through 24
0 3.7146 0 3.7097 0 3.7097

Columns 25 through 30

0 3.7048 0 3.7146 0 3.7195

Columns 31 through 36

0 3.7292 0 3.7537 0 3.7830

Columns 37 through 42

0 3.8319 0 3.8759 0 3.9296

Columns 43 through 48

0 3.9883 0 4.0616 0 4.1202

Columns 49 through 54

0 4.2131 0 4.2669 0 4.3500

Columns 55 through 60

0 4.4282 0 4.5015 0 4.5797

Columns 61 through 66

0 4.6628 0 4.7556 0 4.8289


Columns 67 through 72

0 4.9022 0 4.9756 0 5.0000

Columns 73 through 78

0 5.0000 0 5.0000 0 5.0000

Columns 79 through 84

0 5.0000 0 5.0000 0 5.0000

Columns 85 through 90

0 5.0000 0 5.0000 0 5.0000

Columns 91 through 96

0 5.0000 0 4.9951 0 5.0000

Columns 97 through 102

0 5.0000 0 5.0000 0 5.0000

Columns 103 through 108

0 5.0000 0 5.0000 0 5.0000

Columns 109 through 114


0 5.0000 0 5.0000 0 5.0000

Columns 115 through 120

0 5.0000 0 5.0000 0 5.0000

Columns 121 through 126

0 5.0000 0 5.0000 0 5.0000

Columns 127 through 132

0 5.0000 0 5.0000 0 5.0000

Columns 133 through 138

0 5.0000 0 5.0000 0 5.0000

Columns 139 through 144

0 5.0000 0 5.0000 0 5.0000

Columns 145 through 150

0 5.0000 0 5.0000 0 5.0000

Columns 151 through 156

0 5.0000 0 5.0000 0.0244 5.0000


Columns 157 through 162

0.0733 5.0000 0.1124 5.0000 0.1613 4.9462

Columns 163 through 168

0.2053 4.8974 0.2542 4.8485 0.2981 4.7898

Columns 169 through 174

0.3568 4.7263 0.3959 4.6628 0.4399 4.6090

Columns 175 through 180

0.4936 4.5308 0.5425 4.4575 0.5816 4.3891

Columns 181 through 186

0.6305 4.3157 0.6745 4.2424 0.7234 4.1691

Columns 187 through 192

0.7722 4.1007 0.8113 4.0078 0.8553 3.9296

Columns 193 through 198

0.8944 3.8514 0.9384 3.7732 0.9677 3.6755

Columns 199 through 204


0.9971 3.5728 1.0264 3.4848 1.0362 3.3724

Columns 205 through 210

1.0508 3.2698 1.0508 3.1525 1.0508 3.0547

Columns 211 through 216

1.0508 2.9668 1.0459 2.8641 1.0411 2.8006

Columns 217 through 222

1.0264 2.7224 1.0166 2.6588 0.9922 2.5953

Columns 223 through 228

0.9677 2.5318 0.9384 2.4927 0.8993 2.4242

Columns 229 through 234

0.8602 2.3851 0.8113 2.3558 0.7527 2.3216

Columns 235 through 240

0.6989 2.2972 0.6354 2.2727 0.5718 2.2581

Columns 241 through 246

0.5083 2.2287 0.4399 2.2141 0.3812 2.1994


Columns 247 through 252

0.3177 2.1799 0.2590 2.1799 0.2102 2.1750

Columns 253 through 258

0.1564 2.1652 0.0978 2.1701 0.0489 2.1750

Columns 259 through 264

0.0049 2.1603 0 2.1701 0 2.1652

Columns 265 through 270

0 2.1652 0 2.1457 0 2.1457

Columns 271 through 276

0 2.1212 0 2.1163 0 2.0919

Columns 277 through 282

0 2.0772 0 2.0381 0 2.0137

Columns 283 through 288

0 1.9844 0 1.9697 0 1.9404

Columns 289 through 294


0 1.9110 0 1.8866 0.0196 1.8671

Columns 295 through 300

0.0489 1.8377 0.0782 1.8133 0.1173 1.7889

Columns 301 through 306

0.1662 1.7693 0.2151 1.7449 0.2639 1.7253

Columns 307 through 312

0.3177 1.7155 0.3763 1.6960 0.4301 1.6960

Columns 313 through 318

0.4888 1.6764 0.5474 1.6813 0.6012 1.6764

Columns 319 through 324

0.6598 1.6716 0.7136 1.6618 0.7576 1.6764

Columns 325 through 330

0.8065 1.6667 0.8602 1.6569 0.8993 1.6618

Columns 331 through 336

0.9433 1.6618 0.9873 1.6667 1.0264 1.6569


Columns 337 through 342

1.0655 1.6618 1.0899 1.6667 1.1095 1.6569

Columns 343 through 348

1.1144 1.6618 1.1241 1.6618 1.1193 1.6618

Columns 349 through 354

1.1193 1.6667 1.1193 1.6716 1.1095 1.6667

Columns 355 through 360

1.0997 1.6618 1.0802 1.6618 1.0606 1.6716

Columns 361 through 366

1.0362 1.6569 1.0068 1.6618 0.9775 1.6667

Columns 367 through 372

0.9433 1.6667 0.9042 1.6618 0.8700 1.6618

Columns 373 through 378

0.8358 1.6618 0.7967 1.6667 0.7576 1.6667

Columns 379 through 384


0.7136 1.6618 0.6843 1.6716 0.6549 1.6618

Columns 385 through 390

0.6354 1.6618 0.6109 1.6618 0.6012 1.6618

Columns 391 through 396

0.5865 1.6618 0.5865 1.6667 0.5865 1.6667

Columns 397 through 400

0.5865 1.6667 0.5914 1.6618

>>

3. Adquirir las muestras de un sistema de segundo orden de simple entrada y simple salida cuya entrada sea
una señal de pulsos cuadrados de frecuencia 10 [Hz]

function voltaje=ADC_Serial(muestras)

close all;
clc;
voltaje=0;

%Borra datos que se encuentren previos y vuelve a declarar el puerto y la


%velocidad de transmisión
delete(instrfind({'port'},{'COM3'}));
puerto=serial('COM3');
puerto.BaudRate=9600;

fopen(puerto);%abre el puerto a utilizar


contador=1;

%configura la ventana donde se va a mostrar la grafica


figure('Name','Grafica voltaje')
title('GRAFICA VOLTAJE ADC-SERIAL');
xlabel('Numero de Muestras');
ylabel('Voltaje (V)');
grid off;
hold on;

%Ciclo para ir realizando la grafica paso a paso


while contador<=muestras
ylim([0 5.1]); %Limites del eje y
xlim([0 contador+50]); %Limites del eje x
valorADC=fscanf(puerto,'%d')';
voltaje(contador)=valorADC(1)*5/1024; %Hace la conversión a voltaje
plot(voltaje); %Grafica el voltaje
drawnow
contador=contador+1;
end
%cierra y borra el puerto utilizado, borra todas las variables utilizadas
fclose(puerto);
delete(puerto);
end

PARA EL CASO DE UNA ENTRADA DEL CIRCUITO INTEGRADO 555

ans =

Columns 1 through 6
0.3271 3.3398 3.5986 3.4717 3.5986 3.5303

Columns 7 through 12

3.5986 3.5547 3.5938 3.5547 3.5938 3.5547

Columns 13 through 18

3.5986 3.5596 3.5986 3.5596 3.5986 3.5596

Columns 19 through 24

3.5986 3.5596 3.5938 3.5693 3.5938 3.5596

Columns 25 through 30

3.5938 3.5547 0.0879 1.3818 3.5938 2.8223

Columns 31 through 36

3.5938 3.2813 3.5938 3.4521 3.5938 3.5254

Columns 37 through 42

0.0879 1.3672 3.5938 2.8076 3.5938 3.2813

Columns 43 through 48

3.5938 3.4570 3.5938 3.5156 3.5986 3.5400


Columns 49 through 54

3.5938 3.5596 3.5938 3.5596 3.5938 3.5547

Columns 55 through 60

3.5938 3.5547 3.5986 3.5645 3.5938 3.5596

Columns 61 through 66

3.5986 3.5547 3.5938 3.5645 3.5938 3.5645

Columns 67 through 72

3.5986 3.5596 3.5986 3.5596 3.5938 3.5645

Columns 73 through 78

3.5986 3.5596 3.5986 3.5547 3.5986 3.5596

Columns 79 through 84

3.5986 3.5645 3.5986 3.5596 3.5938 3.5547

Columns 85 through 90

3.5986 3.5645 3.5938 3.5645 3.5938 3.5596

Columns 91 through 96
3.5986 3.5596 3.5986 3.5645 3.5938 3.5645

Columns 97 through 102

3.5986 3.5645 3.5986 3.5645 0.0879 1.3818

Columns 103 through 108

3.5938 2.8174 3.5986 3.2813 3.5986 3.4570

Columns 109 through 114

3.5938 3.5205 0.0928 1.3623 3.5938 2.8174

Columns 115 through 120

3.5986 3.2861 3.5986 3.4521 3.5986 3.5156

Columns 121 through 126

3.5938 3.5498 3.5986 3.5596 3.5986 3.5547

Columns 127 through 132

3.5938 3.5596 3.5938 3.5645 3.5938 3.5596

Columns 133 through 138

3.5938 3.5596 3.5986 3.5596 3.5938 3.5645


Columns 139 through 144

3.5986 3.5547 3.5938 3.5596 3.5986 3.5645

Columns 145 through 150

3.5938 3.5645 3.5938 3.5596 3.5938 3.5645

Columns 151 through 156

3.5986 3.5693 3.5986 3.5596 3.5986 3.5596

Columns 157 through 162

3.5986 3.5693 3.5938 3.5645 3.5986 3.5596

Columns 163 through 168

3.5986 3.5645 3.5938 3.5645 3.5986 3.5596

Columns 169 through 174

3.5938 3.5596 3.5938 3.5645 3.5938 3.5596

Columns 175 through 180

0.0928 1.3770 3.5986 2.8223 3.5938 3.2910

Columns 181 through 186


3.5986 3.4521 3.5986 3.5156 0.0879 1.3672

Columns 187 through 192

3.5986 2.8174 3.5986 3.2764 3.5986 3.4521

Columns 193 through 198

3.5938 3.5254 3.5986 3.5449 3.5938 3.5498

Columns 199 through 200

3.5986 3.5596

>>

Investigar
1. Cual la velocidad de conversión en las tarjetas Arduino Uno, Mega y Due

Arduino cuenta con un ADC.

Este conversor ADC va conectado a un multiplexor, para que así, con uno solo de estos podamos tener varías entradas,
como es en el caso de las placas Arduino que normalmente cuenta con 6 de estas. La Arduino MEGA en cambio cuenta
con 16 entradas analógicas.

A continuación, haremos un programa con Arduino para calcular el tiempo de muestreo que tiene nuestra placa. Para
este ejemplo solo requerimos de una placa Arduino y el código será el siguiente:

2. void setup(){
3.
4. Serial.begin(9600);
5. muestreo();
6.
7. }
8.
9. void loop(){
10. }
11.
12. void muestreo(){
13.
14. unsigned long time1=0;
15. unsigned long time=0;
16. Serial.println("*************************");
17. Serial.println("ENSAYO TIEMPO DE MUESTRO:");
18. Serial.println("*************************");
19. for(byte i =0; i<4; i++){
20. time1=micros();
21. int A=analogRead(A0);
22. time=micros()-time1;
23. Serial.print(" Muestra: ");
24. Serial.print(i+1);
25. Serial.print(" Tiempo: ");
26. Serial.println(time);
27. }
28.
29. }
30. Activando el serial monitor podremos ver los resultados de nuestro experimento:

31.
32. El código que he utilizado para este fin es el siguiente:
33. unsigned long tini;
34. unsigned long tbucle;
35. unsigned long ttotal;
36. unsigned long tdummy;
37. int i=0;
38. int val=0;
39. void setup() {
40. Serial.begin(9600);
41. Serial.println("Comenzamos!");
42. }
43. void loop() {
44. i++;
45. Serial.print("Medida ");
46. Serial.print(i);
47. Serial.print(":t");
48. tini = millis();
49.
50. tdummy=millis();
51. for(unsigned long int i=0;i<10000;i++){
52. }
53. tbucle=millis();
54.
55. for(unsigned long int i=0;i<10000;i++){
56. al=analogRead(A2);
57. }
58. ttotal=millis();
59.
60. Serial.print((float)(ttotal-tbucle-(tbucle-tini))/10.00);
61. Serial.println(" uS");
62. }
63. Los tiempos obtenidos son:

Excepto en la primera medida, las demás tiene un tiempo de muestreo de 112 micro segundos, lo que equivale a una
frecuencia de muestreo de 8.928 kHz, podemos tomar por valido ya que estoy utilizando una placa Arduino UNO. A
demás debemos tener en cuenta una pequeña perdida de tiempo que tenemos al guardar y calcular las variables time1
y time.
Otro factor a tener en cuenta del ADC es su resolución, para ello hablamos de los bits de resolución que tiene, los bits
no permiten hacer combinaciones, cuantos mas tengamos mayor numero de combinaciones podremos hacer, cada
una de estas combinaciones muestra una medida del sistema analógico, la cantidad de medidas que tenemos serán 2
elevado al numero de bits de resolución. Puesto que Arduino UNO, en mi caso, tiene un ADC de 10 bits
de resolución tendrá 1024 combinaciones. La placa Arduino DUE por ejemplo cuenta con un ADC de 12 bits
(4096 combinaciones).
Pero hay un segundo factor que interviene en la resolución, es el rango de medida, El rango de Voltae de las
placas Arduino por defecto es de 5v o 3.3v. Con esto sabemos que en voltios tenemos una resolución igual a;

A continuación haremos un ejemplo con Arduino de la resolución midiendo el voltaje en un potenciómetro, iremos
girando las manecilla del potenciómetro y veremos que conversión da el ADC y a que corresponde en voltaje.
Comprobaremos a demás que el paso calculado antes de 4.88mV es correcto.

64. El código que utilizaremos es el siguiente:


65. int contador;
66.
67. void setup(){
68.
69. contador=1;
70. Serial.begin(9600);
71. Serial.println("*****************");
72. Serial.println("ENSAYO RESOLUCION");
73. Serial.println("*****************");
74. }
75.
76. void loop(){
77.
78. muestreo();
79. contador++;
80. }
81.
82. void muestreo(){
83.
84. int A=analogRead(A0);
85. float B= float(A)*5/1023;
86. Serial.print(" Muestra: ");
87. Serial.print(contador);
88. Serial.print(" Medida Digital: ");
89. Serial.print(A);
90. Serial.print(" Medida Analogica: ");
91. Serial.println(B, 5);
92.
93. delay(1000);
94. }

Una vez compilado, abrimos el serial monitor y comenzamos a rotar el potenciómetro para ver que sucede, si ha sido
montado correctamente, os saldrá lo siguiente:

A partir de estos datos reales podemos conocer el resolución tenemos cuando trabajamos en el rango de voltaje de 0 a
5v, para ello cogemos dos muestras cuales quieras, por ejemplo la 21 y la 22 y hacemos lo siguiente:
Arduino UNO, en mi caso, tiene un ADC de 10 bits de resolución tendrá 1024 combinaciones. La placa Arduino DUE por
ejemplo cuenta con un ADC de 12 bits (4096 combinaciones).
Pero hay un segundo factor que interviene en la resolución, es el rango de medida, El rango de Voltae de las
placas Arduino por defecto es de 5v o 3.3v. Con esto sabemos que en voltios tenemos una resolución igual a;

You might also like