Practica 5 Sext0
Practica 5 Sext0
Practica 5 Sext0
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.
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);
}}
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.
Char pulso;
InitMain();
Pulso=0;
PWM1_Start(); // start PWM1
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);
PWM=pulso*100/254;
Lcd_out(2,2,”PWM=”);
IntToStr(PWM,txt2);
Lcd_Out_Cp(txt2);
Lcd_out(2,12,”%”);
}
}
}
}
Char pulso;
Void main(){
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
InitMain();
Pulso=0;
PWM1_Start(); // start PWM1
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);
PWM=pulso*100/254;
Lcd_out(2,2,”PWM=”);
IntToStr(PWM,txt2);
Lcd_Out_Cp(txt2);
Lcd_out(2,12,”%”);
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.