modificado PIC 16F716

#include <16f716.h>           //Pic a utilizar
#fuses hs,nowdt,noprotect
#use delay (clock = 8000000)   //Cristal de 8 Mhz       
#include <lcd420.c>            //Libreria de Lcd
#define use_portb_lcd          //Configuracion de Lcd

   int32 Q,Q1,Q2;
   float P,P1,P2,P3=0;
   float V3=0;
 
 
main()
   {
   V3=29,89925251868703;
 
   setup_adc_ports(all_ANALOG);
   setup_adc(adc_clock_div_32);   
   lcd_init();
 
  lcd_gotoxy(1,1);printf(lcd_putc, "*****  40 VDC  *****");
  lcd_gotoxy(1,2);printf(lcd_putc, "***** 2 0 2 0  *****");
 
  delay_Ms(1200);
  printf(lcd_putc,"\f");
  lcd_gotoxy(1,1);printf(lcd_putc, "*CONTROLADOR  CARGA*");
  lcd_gotoxy(1,2);printf(lcd_putc, "CHARGER BATTERY 40V ");
 
  delay_Ms(1500);
  printf(lcd_putc,"\f");
 
   while (1) {
                       
         
         set_adc_channel(0);
         //Conversión adc voltios
         Q=read_adc();
         P=(Q*5.0/1023)*V3;
         delay_Ms(15);
       
         set_adc_channel(1);
         //Conversión a corriente
         Q1=read_adc();
         P1=(Q1*5.0/1023)*V3;
         delay_Ms(15);
       
         set_adc_channel(2);
         //Conversión adc voltios
         P2=(Q2*5.0/1023)*V3;
         Q2=read_adc();
         delay_Ms(15);
       
         P3=P2*P1;
         delay_Ms(15); 
       
       
       
            if(P>1)  {   //¿se ha mostrado digito funcion if?
                       
            lcd_gotoxy(1,1);printf(lcd_putc,"VI");
            lcd_gotoxy(4,1);printf(lcd_putc, "%02.2fV",P);
                     
                  IF (P2>1){
                 
                     lcd_gotoxy(11,1);printf(lcd_putc,"VC");
                     lcd_gotoxy(14,1);printf(lcd_putc,"%02.2fV",P2);
                     lcd_gotoxy(1,2);printf(lcd_putc,"Am");
                     lcd_gotoxy(4,2);printf(lcd_putc, "%02.2fA",P1);
                  }
                  ELSE{
                     P2=0;
                     lcd_gotoxy(11,1);printf(lcd_putc,"VC");
                     lcd_gotoxy(14,1);printf(lcd_putc,"%02.2fV",P2);
                     lcd_gotoxy(1,2);printf(lcd_putc,"Am");
                     lcd_gotoxy(4,2);printf(lcd_putc, "%02.2fA",P1);
                  }
            lcd_gotoxy(11,2);printf(lcd_putc,"PT");
            lcd_gotoxy(14,2);printf(lcd_putc,"%02.2fW",P3);
           
           
            delay_Ms(900);
            printf(lcd_putc,"\f");
           
            }
            else {        //(*) NO negacion
     
               P=0;
               P1=0;
               P2=0;
               P3=0;         
               lcd_gotoxy(1,1);printf(lcd_putc,"VI");
               lcd_gotoxy(4,1);printf(lcd_putc, "%02.2fV",P);
             
               lcd_gotoxy(1,2);printf(lcd_putc,"Am");
               lcd_gotoxy(4,2);printf(lcd_putc, "%02.2fA",P1);
             
               lcd_gotoxy(11,1);printf(lcd_putc,"VC");
               lcd_gotoxy(14,1);printf(lcd_putc,"%02.2fV",P2);
             
               lcd_gotoxy(11,2);printf(lcd_putc,"PT");
               lcd_gotoxy(14,2);printf(lcd_putc,"%02.2fW",P3);
             
               delay_Ms(900);
             
               printf(lcd_putc,"\f");
           
       
          }
         }
}

Comentarios

Entradas populares de este blog

FUENTE LABORATORIO PIC 18F2550 (CÓDIGO) PROTON IDE COMPILER

Voltimetro con pic CCS compemdio

VOLTIMETRO CON PIC CCS PROTEUS