Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - dekindy

#1
พอดีผมเกิดทำขา L หักขานึงแต่ไม่เยอะ
จะส่งผลให้ค่า L เปลี่ยนไปหรือไม่
#3
ขอวิธีแก้หน่อยครับ กำลังจะส่งงานด้วย เซงเลย
#4
zero voltang switching คืออะไรครับ แล้วดียังไง ผมล่ะไม่ค่อยเข้าใจ :-[
#5
ขอบคุณมากครับผม ผมใช้ C คร่อม ก่อนเข้าไมโคร น่าจะได้แล้ว ขอบคุณมาก
#6
unsigned cnt;
unsigned int count = 0 ;
int duty_cycle=0;
int freq=0 ;

void interrupt() {             //interrupt Timer0
  //int get ;
  TMR0   = 217;                //set Timer0
  INTCON = 0x20;

  if(count < duty_cycle)
   {
   PORTC.F0 =1;
   }
  else{
     PORTC.F0 =0;
      }

  if(count==25)               //Overflow 100
  {
   count=0;
   duty_cycle=freq;            //set duty_cycle
  }
  else
      {
      count ++ ;
      }
                   }

void main() {

      int a=0;
      int b=0;
      int c=0;

      unsigned int adc_rd;
      unsigned char ch;
      long tlong, Error,nlong,temp;

      //Frequency 500 Hz

      OPTION_REG = 0x80;
      TRISC.F0 = 0;
      TMR0  = 217;
      INTCON = 0xA0;
      //PORTC.F0 = 1;
      count=0;
      Lcd_Init(&PORTD);
      LCD_Cmd(LCD_CURSOR_OFF);
      LCD_Cmd(LCD_CLEAR);

PR2 = 0b00100110 ;
T2CON = 0b00000101 ;
CCPR1L = 0b00010000 ;
CCP1CON = 0b00011100 ;

while (1) {
      LCD_out(1,4,"Temperature");
      adc_rd  = ADC_read(2);
      nlong = ((long)adc_rd /9)+5;

      ch    = (nlong%1000)/100;
      LCD_Chr(2,7,48+ch);

      ch    = ((nlong%1000)%100)/10;
      LCD_Chr_CP(48+ch);

      ch    = (((nlong%1000)%100)%10);
      LCD_Chr_CP(48+ch);
     // Button select duty_cycle 25% 50% 100%

     if(PORTB.F4==0)
     {
                    a=1;
                    TRISC.F2 = 0;
                    TRISC.F1 = 0;
                    PORTC.F1 = 1;
                   
                    //delay_ms(500);
     }
     if(PORTB.F5==0)
     {
                    a=2;
                    TRISC.F2 = 0;
                    TRISC.F1 = 0;
                    PORTC.F1 = 1;
     }
     if(PORTB.F6==0)
     {
                    a=3;
                    TRISC.F2 = 0;
                    TRISC.F1 = 0;
                    PORTC.F1 = 1;
     }
     switch(a)
     {
              case 1:                                            //25%

                      Error=50-nlong;
                      // freq=0;
                      if(Error >= 0)                                //error > 0
                                 {
                                    if(freq > 26)
                                    {
                                       freq--;
                                               // delay_ms(100);
                                          if(freq < 1)
                                             {
                                                freq=0;
                                             }
                                    }
                      if(freq < 26)
                                 {
                                    freq++;
                                        //delay_ms(100);
                                       if(freq > 26)
                                          {
                                             freq=26;
                                          }
                                 }

                                 }

                       if(Error < 0)                           //error < 0
                                 {
                                 if(freq >0)
                                 {
                                 freq--;
                                 //delay_ms(100);
                                 if(freq <= 1)
                                 {
                                 freq=0;
                                 }
                                 }
                                 //freq = 50;
                                 }
                      if(PORTB.F5==0||PORTB.F6==0)
                                 {
                                 break;

             case 2:                                             //50%

                      Error=60-nlong;
                     if(Error >= 0)                                //error > 0
                                 {
                                    if(freq > 26)
                                    {
                                       freq--;
                                                //delay_ms(100);
                                          if(freq < 1)
                                             {
                                                freq=0;
                                             }
                                    }
                      if(freq < 26)
                                 {
                                    freq++;
                                        //delay_ms(100);
                                       if(freq > 26)
                                          {
                                             freq=26;
                                          }
                                 }

                                 }
                     if(Error<0)                           //error <0
                                 {
                                 if(freq >0)
                                 {
                                 freq--;
                                 //delay_ms(100);
                                 if(freq <= 1)
                                 {
                                 freq=0;
                                 }
                                 }
                                 }
                     if(PORTB.F4==0||PORTB.F5==0)
                                 {
                                 break;
              case 3:                                            //75%

                      Error=70-nlong;                           //error >0
                      if(Error >= 0)                                //error > 0
                                 {
                                    if(freq > 26)
                                    {
                                       freq--;
                                                //delay_ms(100);
                                          if(freq < 1)
                                             {
                                                freq=0;
                                             }
                                    }
                      if(freq < 26)
                                 {
                                    freq++;
                                        //delay_ms(100);
                                       if(freq > 26)
                                          {
                                             freq=26;
                                          }
                                 }

                                 }
                      if(Error<0)                           //error <0
                                 {
                                 if(freq >0)
                                 {
                                 freq--;
                                 //delay_ms(100);
                                 if(freq <= 1)
                                 {
                                 freq=0;
                                 }
                                 }
                                 }
                      if(PORTB.F4==0||PORTB.F5==0)
                                 {
                                 break;
                                 }
                                 }
default: Lcd_Out(1,1,"");
}
}
}
}
#7
วงจรครับ
#8
LCD_out(1,4,"Temperature");


      adc_rd  = ADC_read(2);

      nlong = ((long)adc_rd)/4;

     
      ch    = (nlong%1000)/100;
      LCD_Chr(2,7,48+ch);

      ch    = ((nlong%1000)%100)/10;
      LCD_Chr_CP(48+ch);

      ch    = (((nlong%1000)%100)%10);
      LCD_Chr_CP(48+ch);

อันนี้โค้ดนะคัฟ