Practica 5 Sext0

Descargar como docx, pdf o txt
Descargar como docx, pdf o txt
Está en la página 1de 11

Práctica 4

SISTEMA DE CONTROL DE VELODIDAD DE UN MOTOR DE CD EN LAZO


ABIERTO CON PIC16F887
Objetivo: El alumno comprobara el funcionamiento de un sistema de control de velocidad de un motor de cd usando el modulo
pwm del microcontrolador pic16f887 a lazo abierto incrementando o decrementando la velocidad con teclas.

Trabajo previo:
1.- Investigar la hoja de datos de CI PIC16F887.

Material y equipo:
 Tablilla proto board (tablilla de prototipos)
 Multímetro digital auto rango
 Cables Para Conexiones diversas (cable de interfon)
 Fuente de alimentación +12V 0V +5V
 Pinzas de punta (tipo alicata chica)
 MODULO DE POTENCIA L298
 Resistencias diversos valores
 Capacitores diversos valores
 PIC16F887
 OSCILADOR DE CRISTAL 4MHz
 SW SPST
 POTENCIOMETRO 10K
 MOTOR CD 12 A 24 VCD

Instrucciones:
1. Arme los circuitos en la tablilla protoboard y antes de energizarlos pida al instructor verifique las conexiones.

2. La práctica debe contener en el formato proporcionado por el instructor lo siguiente: El diagrama esquemático, cálculos,
mediciones realizadas, fotografías y sus conclusiones.

3. anexe su investigación previa a la práctica realizada e intégrelo a su portafolio de evidencias previamente evaluado por el
instructor.

Desarrollo de la Práctica:
Arme el circuito de la siguiente figura, programe el PIC y energícelo para observar su correcto funcionamiento, haga los ajustes
necesarios para que el circuito funcione adecuadamente y obtener un control de velocidad digital de un motor de cd en lazo abierto.

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD


CODIGO DE PROGRAMACION:

char txt[7];
//PUERTOS DONDE SE CONECTA LA LCD AL PIC
bit LCD_RS at RD0_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
//MENSAJE QUE VA APARECER AL PRINCIPIO
char msg1 []= "BIENVENIDO";
char msg2 []="GRAN DEME";
//DEFINIR VARIABLES PARA GUARDAR
ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD
int DATO,PWM,aumento=0;
char i[16];
int ancho_pulso=0;
unsigned short current_duty, old_duty, current_duty1, old_duty1;
void InitMain() {
ANSEL=0X00;
ANSELH=0;
C1ON_bit = 0; // Disable comparators
TRISD=0X00;
PORTA = 255;
TRISA = 255; // configure PORTA pins as input
TRISB=0XFF;
TRISC=0X00;
PORTD=0;
PORTC=0;
PORTB=0;
PWM1_Init(5000); // Initialize PWM1 module at 5KHz
}
void main() {
InitMain();
current_duty = 1; // initial value for current_duty
PWM1_Start(); // start PWM1
PWM1_Set_Duty(current_duty); // Set current duty for PWM1
//ACCIONES QUE VA A HCER EL DISPLAY
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,2,msg1); //APARECE EL PRIMER MENSAJE QUE ES
BIENVENIDO
Lcd_Out(2,2,msg2); //APARECE EL SEGUNDO MENSAJE QUE ES
GRAN DEME
delay_ms(2000); //TIEMPO QUE APARECEN
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_CLEAR); //LIMPIA EL DISPLEY BORRA LOS
MENSAJES
delay_ms(1000);
ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD
while(1)
{
if(PORTB.F1==0 && aumento<=254)//DISMINUYE EL PWM
{
portc.f5=1;
portc.f4=0;
aumento++;
delay_us(100);
}
if(PORTB.F6==0 && aumento>=0)//DISMINUYE EL PWM
{
portc.f5=0;
portc.f4=1;

aumento--;
delay_us(100);
}
if(PORTB.F7==0)
{
aumento=0;
delay_us(100);

}
PWM1_Set_Duty(aumento);
PWM=(aumento)*100/254;
Lcd_out(1,2,"PORCENTAJE DE");
Lcd_out(2,2,"PWM=");
IntToStr(PWM,txt);
Lcd_Out_Cp(txt);
Lcd_out(2,13,"%");
delay_ms(10);
}}

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD


CONCLUCION:

EN ESTA PRACTICA OCUPAMOS PUSH BOTON PARA AUMENTAR DE


UNO EN UNO LA MODULA POR ANCHO DE PULSO Y HACI PODER
AUMENTAR LA VELOCIDAD DEL MOTOR O DISMINUIRLA CON EL
OTRO BOTON LOS CUALES ESTAN EL PULL UP Y EL TERCER
BOTON EL DEL PARO O STOP EL CUAL SERIA COMO UN PARO DE
EMERGENCIA ANTE UN ACCIDENTE;

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD


Práctica 5
SISTEMA DE CONTROL DE VELODIDAD DE UN MOTOR DE CD EN LAZO
ABIERTO CON PIC16F887
Objetivo: El alumno comprobara el funcionamiento de un sistema de control de velocidad de un motor de cd usando el modulo
pwm del microcontrolador pic16f887 asi como el modulo de conversión análogo digital cuya señal de consigna es fijado por un
potenciómetro, el sistema es a lazo abierto.

Trabajo previo:
1.- Investigar la hoja de datos de CI PIC16F887.

Material y equipo:
 Tablilla proto board (tablilla de prototipos)
 Multímetro digital auto rango
 Cables Para Conexiones diversas (cable de interfon)
 Fuente de alimentación +12V 0V +5V
 Pinzas de punta (tipo alicata chica)
 MODULO DE POTENCIA L298
 Resistencias diversos valores
 Capacitores diversos valores
 PIC16F887
 OSCILADOR DE CRISTAL 4MHz
 SW SPST
 POTENCIOMETRO 10K
 MOTOR CD 12 A 24 VCD

Instrucciones:
1. Arme los circuitos en la tablilla protoboard y antes de energizarlos pida al instructor verifique las conexiones.

2. La práctica debe contener en el formato proporcionado por el instructor lo siguiente: El diagrama esquemático, cálculos,
mediciones realizadas, fotografias y sus conclusiones.

3. anexe su investigación previa a la práctica realizada e intégrelo a su portafolio de evidencias previamente evaluado por el
instructor.

Desarrollo de la Práctica:
Modifique el circuito de la práctica anterior y ahora diseñe un programa que le permita controlar la velocidad del motor manipulando un
potenciómetro para modificar la velocidad, el potenciómetro se conectara a la entrada analógica AN0, arme el circuito y energícelo
para observar su correcto funcionamiento, haga los ajustes necesarios para que el circuito funcione adecuadamente y obtener un
control de velocidad de un motor de cd en lazo abierto.

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD


CODIGO DE PROGRAMACION;
Sbit LCD_RS at RD0_bit;
Sbit LCD_EN at RD1_bit;
Sbit LCD_D4 at RD2_bit;
Sbit LCD_D5 at RD3_bit;
Sbit LCD_D6 at RD4_bit;
Sbit LCD_D7 at RD5_bit;

Sbit LCD_RS_Direction at TRISD0_bit;


Sbit LCD_EN_Direction at TRISD1_bit;
Sbit LCD_D4_Direction at TRISD2_bit;
Sbit LCD_D5_Direction at TRISD3_bit;
Sbit LCD_D6_Direction at TRISD4_bit;
Sbit LCD_D7_Direction at TRISD5_bit;
// End LCD module connections

Char txt1[] = “6G”;


Char txt2[] = “ELECTRONICA “;
Char PWM;

Char pulso;

Unsigned short current_duty, old_duty, current_duty1, old_duty1;


Void InitMain() {

TRISA = 255; // configure PORTA pins as input


PORTC = 0; // set PORTC to 0
TRISC = 0; // designate PORTC pins as output
PWM1_Init(500); // Initialize PWM1 module at 5KHz
PWM2_Init(500); // Initialize PWM2 module at 5KHz
}
ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD
Void main(){
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISD=0X00;
TRISB=0X0F;

InitMain();

Pulso=0;
PWM1_Start(); // start PWM1

PWM1_Set_Duty(0); // Set current duty for PWM1

Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,3,txt1); // Write text in first row
Lcd_Out(2,2,txt2); // Write text in second row
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);

While(1){
If(PORTB.F0==0){
// Initialize PWM2 module at 5KHz
While (1) { // endless loop
If (RB1_bit) { // button on RA0 pressed
Delay_ms(20);
Pulso++; // increment current_duty

If(pulso >=255){
Pulso=254;
}
PWM1_Set_Duty(pulso);

If (RB2_bit) { // button on RA1 pressed


Delay_ms(20);
Pulso--; // decrement current_duty
If(pulso<=1)
{
Pulso=1;
}
PWM1_Set_Duty(pulso);

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD


}

PWM=pulso*100/254;

Lcd_out(2,2,”PWM=”);
IntToStr(PWM,txt2);
Lcd_Out_Cp(txt2);
Lcd_out(2,12,”%”);

}
}
}
}

Sbit LCD_RS at RD0_bit;


Sbit LCD_EN at RD1_bit;
Sbit LCD_D4 at RD2_bit;
Sbit LCD_D5 at RD3_bit;
Sbit LCD_D6 at RD4_bit;
Sbit LCD_D7 at RD5_bit;

Sbit LCD_RS_Direction at TRISD0_bit;


Sbit LCD_EN_Direction at TRISD1_bit;
Sbit LCD_D4_Direction at TRISD2_bit;
Sbit LCD_D5_Direction at TRISD3_bit;
Sbit LCD_D6_Direction at TRISD4_bit;
Sbit LCD_D7_Direction at TRISD5_bit;
// End LCD module connections

Char txt1[] = “6G”;


Char txt2[] = “ELECTRONICA “;
Char PWM;

Char pulso;

Unsigned short current_duty, old_duty, current_duty1, old_duty1;


Void InitMain() {

TRISA = 255; // configure PORTA pins as input


PORTC = 0; // set PORTC to 0
TRISC = 0; // designate PORTC pins as output
PWM1_Init(500); // Initialize PWM1 module at 5KHz
PWM2_Init(500); // Initialize PWM2 module at 5KHz
}

Void main(){
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD


TRISD=0X00;
TRISB=0X0F;

InitMain();

Pulso=0;
PWM1_Start(); // start PWM1

PWM1_Set_Duty(0); // Set current duty for PWM1

Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,3,txt1); // Write text in first row
Lcd_Out(2,2,txt2); // Write text in second row
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);

While(1){
If(PORTB.F0==0){
// Initialize PWM2 module at 5KHz
While (1) { // endless loop
If (RB1_bit) { // button on RA0 pressed
Delay_ms(20);
Pulso++; // increment current_duty

If(pulso >=255){
Pulso=254;
}
PWM1_Set_Duty(pulso);

If (RB2_bit) { // button on RA1 pressed


Delay_ms(20);
Pulso--; // decrement current_duty
If(pulso<=1)
{
Pulso=1;
}
PWM1_Set_Duty(pulso);

PWM=pulso*100/254;

Lcd_out(2,2,”PWM=”);
IntToStr(PWM,txt2);
Lcd_Out_Cp(txt2);
Lcd_out(2,12,”%”);

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD


}
}
}
}

CONCLUCION:
Al poner los push botón, el primero irá al bit 2 y aumentará, el segundo al bit 1 y disminuirá el tercero al bit 0
reinicia el pwm para modulación de ancho de pulso, compramos las ondas del pwm y dimos en el blanco, en
nuestro Lcd se dan las representaciones al apretar cada push botón. Con un voltaje de de 8V ayudará a alimentar
todo nuestro circuito junto con el puente H. Y con ayuda de nuestro código hace realizar nuestra practica.

ING. DEMETRIO MEZA A. MECATRONICA AREA DE CONTROL CNAD

También podría gustarte