Sei sulla pagina 1di 9

SEPTIEMBRE

FEBRERO 10

UNIVERSIDAD POLITÉCNICA SALESIANA


INFORME DE LA PRUEBA II
FILTROS PASA BAJOS CON DSPIC30F4013
SISTEMAS MICROPROCESADOS I

DOCENTE
Ing. Electrónico.
Luis Oñate

INGENIERIA ELECTRÓNICA
FECHA: 23 DE ENERO DE 2011

ESTUDIANTES
RUIZ JUAN
DANIEL HUACA
LUIS SANGOQUIZA

UNIVERSIDAD POLITÉCNICA SALESIANA


UNIVERSIDAD POLITÉCNICA SALESIANA

INFORME DE LA PRUEBA II

TEMA: FILTROS PASA BAJOS CON DSPIC30F4013

OBJETIVOS:

1. Realizar con el microcontrolador DSPIC30F4013 un programa para realizar un


filtro pasa bajos.

DESARROLLO

Para esta práctica utilizaremos el DSPIC30f4013 el cual debemos conocer su


funcionamiento además de cómo utilizarlo.

DIAGRAMA DEL PIC16F877A

Además debemos utilizar el Programa Mikrobasic for dsPIC el cual es de gran ayuda
para la realización de la práctica.

Imagen del programa Mikrobasic for dsPIC


Ing. Electrónica
Informe Sistemas Microprocesados I
UNIVERSIDAD POLITÉCNICA SALESIANA

El programa es de gran ayuda para quemar el código al dsPIC el cual debemos


utilizarlo correctamente.

Imagen del programa dsPICFLASH

PROCESO:
Habilitar el puerto F con el puerto B como una salida además escribimos el código generado
para copilar ademñas de quemar el punto hex en la tarjeta para dsPIC.

ENTRADAS:
El puerto B para que reciba la frecuencia de 1khz.

SALIDAS:
El puerto F para conectar al MPC4921.

DIAGRAMA DE FLUJO

INICIO

PUERTO RB1
ENTRADA

PUERTO F COMO
SALIDAS AL MCP4921

SEÑAL DE FILTRO PASA


BAJOS
Ing. Electrónica
Informe Sistemas Microprocesados I
UNIVERSIDAD POLITÉCNICA SALESIANA

CÓDIGO DEL PROGRAMA MIKROBASIC FOR DSPIC30F4013

program filtropasabajos

' This code was generated by filter designer tool by mikroElektronika


' Date/Time: 17/01/2011 07:00:06 p.m.
' Support info: http://www.mikroe.com

' Device setup:


' Device name: P30F4013
' Device clock: 080.000000 MHz
' Sampling Frequency: 22050 Hz
' Filter setup:
' Filter kind: IIR
' Filter type: Lowpass filter
' Filter order: 30
' Design method: Chebyshev type I

const
BUFFER_SIZE = 8
FILTER_ORDER = 30
COEFF_B as integer[FILTER_ORDER+1]=(
0x0000, 0x0000, 0x0000, 0x0001, 0x0005, 0x0019, 0x0068, 0x0166, 0x0404,
0x09D0, 0x149C, 0x2579, 0x3B55, 0x5227, 0x63C2, 0x6A68, 0x63C2, 0x5227,
0x3B55, 0x2579, 0x149C, 0x09D0, 0x0404, 0x0166, 0x0068, 0x0019, 0x0005, 0x0001,
0x0000, 0x0000, 0x0000)
COEFF_A as Integer[FILTER_ORDER+1]=(
0x0000, 0x0000, 0x0000, 0xFFFF, 0x0006, 0xFFE2, 0x007C, 0xFE5F, 0x0499,
0xF4F4, 0x16D1, 0xD721, 0x3FD8, 0xA8AB, 0x68EA, 0x9121, 0x6720, 0xABA0,
0x3CA1, 0xD9D9, 0x14EF, 0xF60A, 0x0414, 0xFE94, 0x006A, 0xFFE6, 0x0005,
0xFFFF, 0x0000, 0x0000, 0x0000)

SCALE_B = 85 '
SCALE_A = -27 '

LOAD_PIN = 4 ' DAC load pin


CS_PIN = 5 ' DAC CS pin

dim
inext as Word ' Input buffer index
input_ as Word[BUFFER_SIZE] ' Input buffer
output_ as Word[BUFFER_SIZE] ' Output buffer

' This is ADC interrupt handler.


' Analogue input is sampled and the value is stored into input buffer.
' Input buffer is then passed through filter.
' Finally, the resulting output sample is sent to DAC.
sub procedure ADC1Int org $2A ' ADC interrupt handler

Ing. Electrónica
Informe Sistemas Microprocesados I
UNIVERSIDAD POLITÉCNICA SALESIANA

dim CurrentValue as word

input_[inext] = ADCBUF0 ' Fetch sample

CurrentValue = IIR_Radix( SCALE_B, '


SCALE_A, '
@COEFF_B, ' b coefficients of the filter
@COEFF_A, ' a coefficients of the filter
FILTER_ORDER+1,' Filter order + 1
@input_, ' Input buffer
BUFFER_SIZE, ' Input buffer length
@output_, ' Input buffer
inext) ' Current sample

output_[inext] = CurrentValue

inext = (inext+1) and (BUFFER_SIZE-1) ' inext := (inext + 1) mod BUFFER_SIZE;

while SPI1STAT.1 = 1 ' wait for SPI module to finish, if doing something
nop
wend
LATF.CS_PIN = 0 ' CS enable for DAC
SPI1BUF = $3000 or CurrentValue ' Write CurrentValue to DAC ($3 is required
by DAC)
while SPI1STAT.1 = 1 ' Wait for SPI module to finish write
nop
wend
LATF.LOAD_PIN = 0 ' Load data in DAC
LATF.LOAD_PIN = 1 '
LATF.CS_PIN = 1 ' CS disable for DAC

IFS0.11 = 0 ' Clear AD1IF


end sub

' This is Timer1 interrupt handler.


' It is used to start ADC at
' periodic intervals.
sub procedure Timer1Int org $1A ' Timer1 interrupt handler

ADCON1.1 = 1 ' Start sampling


ADCON1.15 = 1 ' Start conversion

IFS0.3 =0 ' Clear TMR1IF


end sub

' Main program starts here.


' Firstly, hardware peripherals are initialized and then
' the program goes to an infinite loop, waiting for interrupts.

Ing. Electrónica
Informe Sistemas Microprocesados I
UNIVERSIDAD POLITÉCNICA SALESIANA

main:
' DAC setup
TRISF.LOAD_PIN = 0 ' LOAD pin
TRISF.CS_PIN = 0 ' CS pin
LATF.CS_PIN = 1 ' Set CS to inactive
LATF.LOAD_PIN = 1 ' Set LOAD to inactive

' SPI setup


SPI1_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_FCY_DIV1,
_SPI_PRESCALE_1,
_SPI_SS_DIS, _SPI_DATA_SAMPLE_MIDDLE,
_SPI_CLK_IDLE_HIGH,
_SPI_IDLE_2_ACTIVE)

inext = 0 ' Initialize buffer index


Vector_Set(input_, BUFFER_SIZE, 0) ' Clear input buffer
Vector_Set(output_, BUFFER_SIZE, 0) ' Clear output buffer

' ADC setup


TRISB = $FFFF ' Use PORTB for input signal
ADCON1 = $00E2 ' Auto-stop sampling, unsigned integer out
ADCON2 = $0000
ADCON3 = $021A ' Sampling time= 3*Tad, minimum Tad selected
ADPCFG = $0000 ' Configure PORTB as ADC input port
ADCHS = $0001 ' Sample input on RB1
ADCSSL = 0 ' No input scan

' Interrupts setup


IFS0 = 0
IFS1 = 0
IFS2 = 0
INTCON1 = $8000 ' Nested interrupts DISABLED
INTCON2 = 0
IEC0 = $0808 ' Timer1 and ADC interrupts ENABLED
IPC0.12 = 1 ' Timer1 interrupt priority level = 1
IPC2.13 = 1 ' ADC interrupt priority level = 2

' Timer2 setup


PR1 = $038B ' Sampling = 22050 Hz. Value of PR1 is dependent on
clock.
T1CON = $8000 ' Timer1 ON, internal clock FCY, prescaler 1:1

while true ' Infinite loop,


nop ' wait for interrupts
wend
end.

Ing. Electrónica
Informe Sistemas Microprocesados I
UNIVERSIDAD POLITÉCNICA SALESIANA

DIAGRAMA DEL CIRCUITO EN MIKROBASIC FOR DSPIC

Imagen del circuito

IMAGEN EN EL PROTOBOARD

Imagen de la prueba realizado en el Protoboard

Ing. Electrónica
Informe Sistemas Microprocesados I
UNIVERSIDAD POLITÉCNICA SALESIANA

Imagen de la prueba realizado en el Protoboard

Imagen de la prueba realizado en el Protoboard

Ing. Electrónica
Informe Sistemas Microprocesados I
UNIVERSIDAD POLITÉCNICA SALESIANA

Imagen de la prueba realizado en el Protoboard

CONCLUSIONES:

• Pudimos darnos cuenta que es de gran utilidad la tarjeta para dsPIC30F4013


para realizar varias prácticas para Micros I
• Además tenemos más práctica en la utilización de la tarjeta para la realización
de las prácticas.
• Como en lo teórico pudimos realizarlo con la tarjeta y visualizarlo en el
osciloscopio.

BIBLIOGRAFÍA

• Datasheet del dsPIC30F4013.

Ing. Electrónica
Informe Sistemas Microprocesados I

Potrebbero piacerti anche