Proyecto con pic y motor

Aca anexo el diagrama de conexion y todo lo referente a un proyecto para motores monofasicos, usando un integrado. Gracias de antemano por la ayuda prestada en el foro y a todos los compañeron que colabararon, acoto que esto es para 60 Hz.

el codigo lo hice en CCS
codigo:

Código:
#include<16F876.h>
#deviceadc=10
#FUSES HS,NOWDT
#use delay(clock=20000000)
#define LCD_ENABLE_PIN  PIN_C0            ////
#define LCD_RS_PIN      PIN_C1                  ////
#define LCD_RW_PIN      PIN_C2                 ////
#define LCD_DATA0       PIN_C4                 ////
#define LCD_DATA1       PIN_C5                 ////
#define LCD_DATA2       PIN_C6                 ////
#define LCD_DATA3       PIN_C7
#include <lcd.c>
#include <math.h>
#use fast_io(B)
int16 q;
int8 p;
float x;
int8 y;
float z;
int AUX;
#int_timer0
void TIMER0_isr(void){

if (y!=0){
y=y-1;
}
if (input(PIN_B1)==1){
disable_interrupts(INT_TIMER0);
output_low(PIN_B1);
}
if (y-1==0){
output_high(PIN_B1);
delay_us(200);
}
set_timer0(32);
}
#int_ext
ext_ist(){

switch (input(PIN_B0)){
case 0:
ext_int_edge(L_TO_H);
break;
case 1:
ext_int_edge(H_TO_L);
break;
}
y=p+1;
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);

enable_interrupts(INT_TIMER0);
}
void main() {
//CONFIGURACION DE LOS PINES E/S
set_tris_b(0x05);
output_low(PIN_B1);
output_low(PIN_B3);

//CONFIGURACION DEL CONVERTIDOR A/D
setup_adc_ports(0);
setup_adc(ADC_CLOCK_INTERNAL);
//CONFIGURACION DE LAS INTERRUPCIONES
enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
ext_int_edge(H_TO_L);
//INICIALIZACION DE LA PANTALLA LCD
lcd_init();
//INICIALIZACION DE LAS VARIABLES
p=24;
AUX=0;

for (;;) {
//PROCESO DE CONVERSION Y ADQUISICION
set_adc_channel(0);          //HABILITACION DEL CANAL 0
delay_us(20);                    //TIEMPO DE ADQUISICION
q = read_adc();                  //LECTURA DEL VALOR CONVERTIDO DEL CANAL 0

//MANEJO DE INFORMACION POR EL PULSADOR
if ((INPUT(PIN_B2)==0)&(AUX==0)){
AUX=1;
delay_ms(300);
}
if ((INPUT(PIN_B2)==0)&(AUX==1)){
AUX=0;
delay_ms(300);
}
//OPERACIONES MATEMATICAS
if ((q<=358)&(q>=92)){
p = (((17)*q)-(720))/100; 
z = 67.7*sqrt(pi-((p*1.0)*377/10000)+sin(2*((p*1.0*377)/10000))/2); 
switch (AUX){

case 0:
printf(lcd_putc,"\f  Voltaje RMS\n     %3.2f",z );
delay_ms(100);
break;

case 1:
printf(lcd_putc, "\fDesfasaje de:");
if (p<10) {
printf(lcd_putc, "\n   0.%ums", p);
}
else {
x = p/10.0;
printf(lcd_putc,"\n    %01.2fms",x);
}
delay_ms(100);
break;
}
}
if(q>358){
printf(lcd_putc, "\f VoltajeLimite");
output_high(PIN_B3);
delay_ms(500);
output_low(PIN_B3);
delay_ms(500);
}
if(q<92){
switch (AUX){

case 0:
printf(lcd_putc, "\f  Voltaje RMS\n");
printf(lcd_putc, "     119.65");
delay_ms(100);
break;

case 1:
printf(lcd_putc, "\fDesfasaje de:\n");
printf(lcd_putc, "   0.8ms");
delay_ms(100);
break;
}
}
}
}

anexo la simulacion en proteus
 

Adjuntos

  • prueba.rar
    22.8 KB · Visitas: 22
Última edición por un moderador:
Atrás
Arriba