ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización...

22
ANEXOS

Transcript of ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización...

Page 1: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

ANEXOS

Page 2: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

A. esquemas generales

Primer diseño

Page 3: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

Segundo diseño

Page 4: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

B. Lista de componentes

Material Unidades Utilización

Resistencia 1 KΩ, ¼ de

vatio y 5% tolerancia 1

1er primer diseño

amplificador inversor

Resistencia 2,2 KΩ, ¼ de

vatio y 5% tolerancia 2

1er diseño muestra y

amplificador inversor

Resistencia 220 Ω, ¼ de

vatio y 5% tolerancia 1

1er diseño conversor

intensidad voltaje

Resistencia 1,2 KΩ, ¼ de

vatio y 5% tolerancia 1 1er diseño del P.G.A.

Resistencia 1,8 KΩ, ¼ de

vatio y 5% tolerancia 1 1er diseño del P.G.A.

Resistencia 12 KΩ, ¼ de

vatio y 5% tolerancia 1 1er diseño del P.G.A.

Resistencia 15 KΩ, ¼ de

vatio y 5% tolerancia 1 1er diseño del P.G.A.

Resistencia 120 KΩ, ¼ de

vatio y 5% tolerancia 1 1er diseño del P.G.A.

Resistencia 150 KΩ, ¼ de

vatio y 5% tolerancia 1 1er diseño del P.G.A.

Resistencia 1,5 MΩ, ¼ de

vatio y 5% tolerancia 1 1er diseño del P.G.A.

Resistencia 10 KΩ, ¼ de

vatio y 5% tolerancia 1 2º diseño del oscilador

Resistencia 680 Ω, ¼ de

vatio y 5% tolerancia 1

2º diseño del conversor

intensidad voltaje

Resistencia 4,7 KΩ, ¼ de

vatio y 5% tolerancia 2

2º diseño filtro sallen &

Key

Page 5: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

Material Unidades Utilización

Resistencia 1,2 MΩ, ¼ de

vatio y 5% tolerancia 4

2º diseño filtro sallen &

Key

Condensador cerámico de

100 nF 1 1er diseño de la muestra

Condensador cerámico de

10 nF 3

2º diseño para oscilador y

filtro Sallen & Key

Condensador cerámico de

1 nF 2

2º diseño para filtro Sallen

& Key

Condensador cerámico de

220 nF 1 2º diseño de la muestra

Condensador cerámico de

22 nF 2

2º diseño filtro Sallen &

Key

Potenciómetro de 5 KΩ 1 2º diseño de la muestra

Potenciómetro de 100 KΩ 2 2º diseño del oscilador

C. Listado de programas

Simulación del primer diseño

ANALIZADOR.CIR - ANALIZADOR DE IMPEDANCIAS

*

* Fuente para transient analysis

*

VS 1 0 SIN(0 1 5000 0 0)

*

* Fuente para AC analysis

*

*VS 1 0 AC 1 SIN

*

XOP1 0 2 3 OPAMP1

XOP2 0 5 6 OPAMP1

XOP3 6 7 8 OPAMP1

XOP4 1 12 12 OPAMP1

Page 6: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

*

S0 8 7 70 0 SW1

S1 9 7 71 0 SW1

S2 10 7 72 0 SW1

S3 11 7 73 0 SW1

*

R0 3 2 1K

R1 2 1 2.2K

R2 6 5 220

R31 8 9 1.62MEG

R32 9 10 162K

R33 10 11 16200

R34 11 0 1800

*

* Muestra

*

* RS 5 4 2.2K

* CS 4 3 100N

*

* Pins puerto paralelo:

* uno tiene que estar a 5V,

* los demás a 0.5V.

*

VS0 70 0 DC 5

RS0 70 0 1MEG

VS1 71 0 DC 0.5

RS1 71 0 1MEG

VS2 72 0 DC 0.5

RS2 72 0 1MEG

VS3 73 0 DC 0.5

RS3 73 0 1MEG

*

* SWITCH MODEL

*

.MODEL SW1 SW(VT=2.5 RON=100 ROFF=100MEG)

*

* OPAMP MACRO MODEL, SINGLE-POLE

* Connections:

* non-inverting input

* | inverting input

* | | Output

Page 7: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

* | | |

.SUBCKT OPAMP1 1 2 6

*

* Input impedance

*

RIN 1 2 10MEG

*

* DC gain = 100K and pole1 = 100HZ

* Unity gain = DC gain X pole1 = 10 MHz

*

EGAIN 3 0 1 2 100K

RP1 3 4 100K

CP1 4 0 0.0159UF

*

* Output buffer and resistance

*

EBUFFER 5 0 4 0 1

ROUT 5 6 10

*

.ENDS

*

.OPTIONS nomod nopage

*

* AC analysis

*

*.AC DEC 5 5 50000

*

* Transient analysis

*

.TRAN 0.001S 0.0006S

*

* Resultados AC analysis

*

*.PRINT AC VM(8) VP(8)

*

* Resultados transient analysis

*

.PRINT TRAN V(12) V(8)

.END

Page 8: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

Simulación del segundo diseño

PROTOTIPO.CIR - ANALIZADOR DE IMPEDANCIAS

*

* Fuente para transient analysis

*

VS 1 0 SIN(0 1 1K 0 0)

*

XOP1 0 3 4 OPAMP1

XOP2 7 8 8 OPAMP1

XOP3 11 12 12 OPAMP1

*

S0 5 4 40 0 SW1

S1 9 4 41 0 SW1

*

R1 4 3 675

R2 6 5 1200K

R3 7 6 1200K

R4 10 9 1200K

R5 11 10 1200K

R6 5 0 4700

R7 9 0 4700

*

C1 8 6 22N

C2 7 0 11N

C3 12 10 22N

C4 11 0 11N

*

* Muestra

*

* 0 < RS < 5K

*

RS 2 1 2.5K

CS 3 2 200N

*

* Pins puerto paralelo:

* uno tiene que estar a 5V,

* los demás a 0.5V.

*

VS0 40 0 PULSE(-5 5 0.0 1.0U 1.0U 0.5M 1M)

RS0 40 0 1MEG

Page 9: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

VS1 41 0 PULSE(-5 5 0.75M 1.0U 1.0U 0.5M 1M)

RS1 41 0 1MEG

*

* SWITCH MODEL

*

.MODEL SW1 SW(VT=2.5 RON=100 ROFF=100MEG)

*

* OPAMP MACRO MODEL, SINGLE-POLE

* Connections:

* non-inverting input

* | inverting input

* | | Output

* | | |

.SUBCKT OPAMP1 1 2 6

*

* Input impedance

*

RIN 1 2 10MEG

*

* DC gain = 100K and pole1 = 100HZ

* Unity gain = DC gain X pole1 = 10 MHz

*

EGAIN 3 0 1 2 100K

RP1 3 4 100K

CP1 4 0 0.0159UF

*

* Output buffer and resistance

*

EBUFFER 5 0 4 0 1

ROUT 5 6 10

*

.ENDS

*

.OPTIONS nomod nopage

*

* Transient analysis

*

*.TRAN 0.0001S 0.002S

.TRAN 0.01S 0.2S

*

* Resultados transient analysis

Page 10: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

*

*.PRINT TRAN V(1) V(40) V(41)

.PRINT TRAN V(8) V(12)

.END

Programación del cálculo del amplitud de la señal

#!/usr/bin/python

# Correlacio de senyals

import string

import math

# Inicialitzacio de variables

t=[]

v1=[]

v2=[]

infile = open('dades.dat','r')

# Llegim dades

for line in infile.readlines():

if line[0:1]!='#':

y=line[:-1]

x=y.split()

t=t+[string.atof(x[0])]

v1=v1+[string.atof(x[1])]

v2=v2+[string.atof(x[2])]

np=len(t)

c=0.0

for i in xrange(np):

c=c+v1[i]*v1[i]

c=(2*c/np)**0.5

print "C0 =",c

Page 11: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

# I ja esta!

Programación de la correlación con el método de multiplicadores

#!/usr/bin/python

# Correlacio de senyals

import string

import math

# Inicialitzacio de variables

t=[]

v1=[]

v2=[]

infile = open('dades.dat','r')

# Llegim dades

for line in infile.readlines():

if line[0:1]!='#':

y=line[:-1]

x=y.split()

t=t+[string.atof(x[0])]

v1=v1+[string.atof(x[1])]

v2=v2+[string.atof(x[2])]

np=len(t)

# Aquesta dada es interessant coneixer-la abans!!!

f=200

# Quantitats auxiliars importants

Page 12: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

dt=(t[np-1]-t[0])/(np-1)

q=int(round(1/(4*f*dt)))

# Integracio

a=0.0

for i in xrange(np-1):

a=a+v1[i+1]*v2[i+1]+v1[i]*v2[i]

a=0.5*a*f*dt

print "A =",a

b=0.0

for i in xrange(np-1):

j=i+q

jj=j+1

if j>np-1:

j=j-np

if jj>np-1:

jj=jj-np

b=b+v1[jj]*v2[i+1]+v1[j]*v2[i]

b=0.5*b*f*dt

print "B =",b

# I ja esta!

Programación de la correlación con el método de int erruptores

#!/usr/bin/python

# Correlacio de senyals

import string

import math

# Inicialitzacio de variables

t=[]

v1=[]

Page 13: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

v2=[]

infile = open('dades2.dat','r')

# Llegim dades

for line in infile.readlines():

if line[0:1]!='#':

y=line[:-1]

x=y.split()

t=t+[string.atof(x[0])]

v1=v1+[string.atof(x[1])]

v2=v2+[string.atof(x[2])]

np=len(t)

# Aquesta dada es interessant coneixer-la abans!!!

f=200

# Quantitats auxiliars importants

dt=(t[np-1]-t[0])/(np-1)

q=int(round(1/(4*f*dt)))

# Integracio

#

# La motivacio d'aquest programa es pedagogica. Hi

# algunes optimitzacions que son evidents pero que

# no s'apliquen per mantenir la claredat.

a=0.0

for i in xrange(np-1):

if v1[i+1]+v1[i] > 0.0:

a=a+v2[i+1]+v2[i]

a=0.5*a*f*dt

print "A =",a

b=0.0

for i in xrange(np-1):

j=i+q

Page 14: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

jj=j+1

if j>np-1:

j=j-np

if jj>np-1:

jj=jj-np

if v1[i+1]-v1[i] > 0.0:

b=b+v2[i+1]+v2[i]

b=0.5*b*f*dt

print "B =",b

# I ja esta!

Configuración de la tarjeta de sonio Ensoniq ES1371 para enviar la señal sinusiodal (AUMIX)

vol:100:100:P

pcm:57:57:P

speaker:0:0:P

line:0:0:P

mic:0:0:P

cd:0:0:P

igain:0:0:P

line1:0:0:P

phin:0:0:R

phout:0:0:P

video:0:0:P

Configuración de la tarjeta de sonio Sound Blaster para recibir las señales (AUMIX)

vol:100:100:P

bass:0:0:P

treble:0:0:P

synth:0:0:P

pcm:85:85:P

speaker:0:0:P

line:95:95:R

mic:0:0:P

Page 15: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

cd:0:0:P

mix:0:0:P

igain:0:0:P

ogain:0:0:P

Programación para enviar y capturar señales a travé s de las tarjetas de sonido.

/*

* Emissió i lectura d'una ona

*/

/*

* Aquests "includes" son els habituals

*/

#include<sys/ioctl.h>

#include<unistd.h>

#include<fcntl.h>

#include<sys/soundcard.h>

/*

* Include pels cosinus i arctangents

*/

#include<math.h>

#include<stdio.h>

#include<stdlib.h>

#include<sys/types.h>

/*

* Definicions importants:

*

* NYQUIST -> 2 minim, 10 minim recomanable

* ONES -> 1 minim, 10 minim recomanable

* BUF_SIZE -> NYQUIST*ONES minim, ha de ser parell

*/

#define BUF_SIZE 819200 // (Maquines de 64 bits)

Page 16: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

// #define BUF_SIZE 409600 // (Maquines de 32 bits)

#define NYQUIST 10

#define ONES 10

#define FREQ_BASE 44000

/*

* Variables que han de ser presents obligatoriamen t

*/

int audio_fd, format, channels, speed;

unsigned char audio_buffer[BUF_SIZE];

/*

* Escollim dos dispositius

*/

#define DEVICE_NAME0 "/dev/dsp"

#define DEVICE_NAME1 "/dev/dsp2"

int open_mode0 = O_WRONLY;

int open_mode1 = O_RDONLY;

/*

* Programa

*/

int main()

/*

* Declaracio de variables locals

*/

short a,b,c,d,left,right;

int delay,i,len,sortida;

int count = BUF_SIZE/2;

long icount;

double dospiik,freq,fmin,fmax,ik,k;

float fuser,temps;

pid_t child_pid;

/*

Page 17: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

* Entrada de l'usuari

*/

fmin=FREQ_BASE*ONES/count;

fmax=FREQ_BASE/NYQUIST;

printf("# Frequencies disponibles: entre %f i %f \n", fmin,

fmax);

printf("# Quina frequencia vols obtenir? ");

scanf("%f",&fuser);

printf("# Provant frequencia %f... \n",fuser);

/*

* WORKAROUND!!! No se perque cal posar aquesta lin ia

*/

fuser=fuser/2.0;

/*

* Calculem constants

*/

k=fuser*count/FREQ_BASE;

ik=floor(k);

icount=(long)ik*(count-1)/k;

icount=icount+1;

freq=FREQ_BASE*ik/icount;

printf("# La frequencia que queda es %f amb un sa mpling de %d

punts \n",freq,icount);

printf("# Hi ha %f ones amb un sampling de %f pun ts cada una

\n",ik,icount/ik);

printf("# Calculant constants \n");

dospiik=2.0*3.1415927*ik;

child_pid=fork();

if(child_pid!=0)

printf("# Soc el pare!\n");

Page 18: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

/*

* Obrim el dispositiu

*/

if ((audio_fd = open(DEVICE_NAME0, open_mode0, 0)) == -1)

perror(DEVICE_NAME0);

exit(1);

/*

* Omplim el buffer

*/

// printf("Omplint el buffer \n");

for(i=0; i<2*icount; i=i+2)

sortida = (int) 32767*sin(dospiik*i/(icount-1 ));

audio_buffer[i] = (unsigned char) (sortida & 0xff);

audio_buffer[i+1] = (unsigned char) ((sortida >> 8) &

0xff);

/*

* Configurem el dispositiu

*/

format=AFMT_S16_LE;

if(ioctl(audio_fd,SNDCTL_DSP_SETFMT,&format)==- 1)

perror("SNDCTL_DSP_SETFMT");

exit(1);

channels=1;

if(ioctl(audio_fd,SNDCTL_DSP_CHANNELS,&channels )==-1)

perror("SNDCTL_DSP_CHANNELS");

exit(1);

speed=44100;

Page 19: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

if(ioctl(audio_fd,SNDCTL_DSP_SPEED,&speed)==-1)

perror("SNDCTL_DSP_SPEED");

exit(1);

/*

* Escriptura de dades

*/

// printf("Escrivint dades \n");

if ((len = write(audio_fd, audio_buffer, 2*icou nt)) == -1)

perror(DEVICE_NAME0);

exit(1);

/*

* Tanquem el dispositiu

*/

// printf("Tancant dispositiu \n");

if ((len = close(audio_fd)) == -1)

perror(DEVICE_NAME0);

exit(1);

else

printf("# Soc el fill!\n");

// Introduir un delay equivalent a 1/4 el temps d'e scritura o

1/2 del temps de lectura

/*

* Obrim el dispositiu

*/

if ((audio_fd = open(DEVICE_NAME1, open_mode1, 0)) == -1)

perror(DEVICE_NAME1);

exit(1);

/*

* Configurem el dispositiu

Page 20: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

*/

format=AFMT_S16_LE;

if(ioctl(audio_fd,SNDCTL_DSP_SETFMT,&format)==- 1)

perror("SNDCTL_DSP_SETFMT");

exit(1);

channels=2;

if(ioctl(audio_fd,SNDCTL_DSP_CHANNELS,&channels )==-1)

perror("SNDCTL_DSP_CHANNELS");

exit(1);

speed=44100;

if(ioctl(audio_fd,SNDCTL_DSP_SPEED,&speed)==-1)

perror("SNDCTL_DSP_SPEED");

exit(1);

/*

* Esperem!!! Volem que el periode de lectura estig ui mes o

menys centrat!!!

*/

delay = (int) icount/(4*speed);

printf("# Delay = %d \n",delay);

sleep(delay);

/*

* Lectura de dades

*/

printf("# Comencem a llegir...\n");

if ((len = read(audio_fd, audio_buffer, 2*icoun t)) == -1)

perror(DEVICE_NAME1);

exit(1);

Page 21: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

// ATENCIO!!! En estereo 2*icount es la meitat de t emps que en

mono!!!

// Per tant llegirem la meitat del temps que escriu rem...

/*

* Treiem el que hem llegit per la pantalla

*/

for(i=0; i<2*icount; i=i+4)

a = audio_buffer[i];

b = audio_buffer[i+1];

c = audio_buffer[i+2];

d = audio_buffer[i+3];

temps = (double) i/(4*speed);

left = a+256*b;

right = c+256*d;

printf("%f %d %d\n",temps,left,right);

/*

* Tanquem el dispositiu

*/

if ((len = close(audio_fd)) == -1)

perror(DEVICE_NAME1);

exit(1);

/*

* Processat de les dades (Encara per fer!!!)

*/

Page 22: ANEXOS - bauma.upc.esbauma.upc.es/pfc/jordi/ProjecteJordi-anexos.pdfMaterial Unidades Utilización Resistencia 1,2 M Ω, ¼ de vatio y 5% tolerancia 4 2º diseño filtro sallen & Key

Programación para controlar el puerto paralelo.

#include <stdio.h>

#include <unistd.h>

#include <asm/io.h>

#define BASEPORT 0x278 /* lp1 */

int main()

if (ioperm(BASEPORT,3,1))

perror("ioperm");

exit(1);

outb(0,BASEPORT);

usleep(10000);

if (ioperm(BASEPORT,3,0))

perror("ioperm");

exit(1);

exit(0);

D. Datasheets