Author Topic: Problam in my AVR program  (Read 2258 times)

0 Members and 1 Guest are viewing this topic.

Offline gulgulTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Problam in my AVR program
« on: February 17, 2010, 03:23:12 AM »
hai,
     I used 16F877A pic.I write the AVR program in c language.The transformer tappings 0-160v-192v-233v-240v-280v.The 240v tapping used to connect output load.Input adc reading is ok . I used the variack and readuse the input voltage the relay on/relay off condition chatteringhow rectify the problam in my program please help me.

/*PROGRAM TO 16F877A*/
#include<pic.h>
//**********************************************************************************//
#define    RA0   // INPUT VOLTAGE CONTROL
#define    RB0 // ZERO CROSS
//**********************************************************************************//
void main()
{   

   int adc_value1,adc_value,adc_value2;

   TRISD=0b001000000;   // PORT CONFIGRATION
   PORTD=0b001000000;

   TRISB=0x00;      // OUT PUT PANNEL DISPLAY
   PORTB=0x00;

   OPTION = 0b00000111;    //INTERRUPT ON FOLLING EDGE

   TRISA=0xFF;      // RA0,RA1,RA2 ARE INPUT
   
   PORTB = 0b00000001;   // RB0 IS ZERO CROSS AND ALL ARE OUTPUT
   TRISB = 0b00000001;
   
   INTCON =0b11110000;   // GIE=1;
   T0IF = 0;
   TMR0 = 98;
   T0IE = 1;   
   INTF = 0;
   INTE = 1;
   ADCON1 = 0x82;      //RA0,RA1,RA3 as Analog inputs & R//A2,RA5 as digital I/Os
   while(1)
{


   ADCON0=0x81;            // RA0 anolog input .32/fosc
   delay();               // ANALOG AQUISITION TIME
   ADGO=1;   
   while(ADGO==1);            //WAIT TILL THE CONVERSION IS OV
   adc_value=ADRESH<<8;
   adc_value=adc_value+ADRESL;

if(MainsPresent)
{
if (adc_value>=973)// INPUT VOLT 285V(HIGH VOLT CHANGR OVER)
   {
      UPSON=1;      // UPSON_LED
      RL1=1;         // CHANGE OVER RELAY
      RL2=0;         // BUCK BOOST OFF
      RL3=0;         // 240V AVR OFF      
      RL4=0;         // 190V/160V OFF MODE
      MAINSON=0;
      ENABLE=1;
      mains_f=0;
   
   }



if ((adc_value<=956)&&(adc_value>=800))// INPUT VOLT 280V(UPS CHANGE TO MAINS)RL2

   {
      UPSON=0;      // INDICATION   // UPSON_LED   
      MAINSON=1;      // Mains on indication
      RL1=0;         // CHANGE OVER RELAY
      RL2=1;         // 280V tapping
      RL3=0;         // 240v tapping      
      RL4=0;         // 192/160v   
      ENABLE=0;      // UPS mode shutdown voltage=1
      mains_f=1;
      delay1();
   
      
   }
if((adc_value<=795)&&(adc_value>=668))// INPUT VOLTAGE 233V

   {

      UPSON=0;          // INDICATION
      ENABLE=0;
      RL1=0;         // CHANGE OVER RELAY   
      RL2=0;         // BUCK BOOST ON
      RL3=1;         // 240V TAPPING OFF   
      RL4=0;         // 190/160V OFF MODE   
      MAINSON=1;      // INDICATION
      mains_f=1;
      delay1();
   
   
   }
if ((adc_value<=662)&&(adc_value>=559))// INPUT VOLTAGE 192V

   {

      UPSON=0;      // INDICATION
      ENABLE=0;
      RL1=0;         // CHANGE OVER RELAY      
      RL2=0;         // 280V TAPPING OFF
      RL3=0;         // 240V TAPPING   
      RL4=1;         // 192V/160v TAPPING
      RB7=1;
      mains_f=1;
      delay1();   
   }
if ((adc_value<=553)&&(adc_value>=461))// INPUT VOLTAGE 160V

   {
      MAINSON=1;
      UPSON=0;          // INDICATION
      ENABLE=0;
      RL1=0;         // CHANGE OVER RELAY
      RL2=0;         // 280V TAPPING
      RL3=0;         // 240V TAPPING
      RL4=0;         // 192/160V TAPPING
      RB7=1;
      mains_f=1;
      delay1();
   
   
   }
if(adc_value<=460)      // INPUT VOLTAGE <=135V

   {
      MAINSON=0;
      ENABLE=1;      //
      UPSON=1;      // INDICATION
      RL1=1;         // CHANGE OVER RELAY
      RL2=0;         // 280V TAPPING
      RL3=0;         // 240V TAPPING
      RL4=0;         // 192/160v Tapping            
      mains_f=0;
      delay1();
   }
}
else if(!MainsPresent)
      {
      MAINSON=0;
      ENABLE=1;
      RL1=1;
      }

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,704
  • Helpful? 173
    • Society of Robots
Re: Problam in my AVR program
« Reply #1 on: February 17, 2010, 05:52:37 AM »
Quote
I used 16F877A pic.I write the AVR program in c language
Wait, a PIC or AVR? :P


Quote
I used the variack and readuse the input voltage the relay on/relay off condition chatteringhow rectify the problam in my program
A what? ???


What error are you getting?

Offline gulgulTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: Problam in my AVR program
« Reply #2 on: February 18, 2010, 09:56:33 AM »
hai,
    I think AVR is auto voltage regulator(ie this program is line intractive ups avr.Input phase volt 160v this time i get out put voltage 240v.This boosting time relay chattering .how i can rectify the problam

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Problam in my AVR program
« Reply #3 on: February 19, 2010, 06:41:22 AM »
Hi,

Without knowing the circuitry that goes before the controller, it's impossible to give a real answer, but you should check if the circuit going to your A/D-C is well behaved and not jumping around.
Put a 'scope probe (x10 setting) on your A/D-C input and watch how it looks while the relays chatters.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 

SMF spam blocked by CleanTalk