Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

AC Voltmeter with Digital Display

Description

Comments

what is seg 1 seg 2 and seg 3

and data is our ac input 220v

what is the clock plus is there any crystal use for give dat pulse??

 

 

the seg1,seg2,seg3 and clock and data are the pins which connct to microcontroller . in the next circuit you will find the exact meaning of this.the first diagram show only 7 segment multiplexing .

can you use another language?

hello if you know another language then you can convert this easly becaue i have explan all logics 

thank you

Dear

Harwinder Harry
 
Thank for sharing this nproject I have compile with Mikro C. but in the simulation not getting the proper output digit are flicking only
 

 

plz give me hex code.

 

Please, send me hex file. thank you.

HI 

PLEASE If you can to writ the program in MicroC 

Has anyone noticed?. The full bridged polarity is reversed.

Yeah, I see, but we can change it easily, am I right? But I can't see PIC include file declaration. I think source code is not complete one. It is mixed with C and asm.

hello all of you

 first thing is that i have write this code in microc.

2nd is the whole code is in c no assmbly is use in this

 

Hi,

What is quartz frequency please ?

Hello Dear.

  

 Please tell me the exact specification of these resistor , like wattage?  

i am desigening this circuit for arduino is there any protection needed. like fuse or something.

required pic16f676 based stabilizer circuit 90v to 290v 5 step with hex file.

 

pl. send me he file.


  
/*****************************************************************
5 Step Stablizer
DATE = 07.10.2009
Working perfectly without Relay chattering between steps

0x0131-0x0134  = 0.83
----0x3A-----
0x00F7-0x00F9  = 0.67
----0x0C-----
0x00EB-0x00ED  = 0.64
----0x2D-----
0x00BE-0x00C0  = 0.51


0X01DA-0X01DE  = 300V  = 1.14
0X016B-0X016C  = 0.84
----64--------
0X012A-0X012C  = 0.67
----17--------
0X0119-0X011A  = 0.64
----51--------
0X00E6-0X00E7  = 0.51

new values of adc OK
0X011C-0X011E  = 340V
0X00F3-0X00F4  = 300V
0X00B8-0X00B9  = 0.84
-----34------
0X0096-0X0097  = 0.67
-----8-------
0X008E-0X008E  = 0.64
-----28------
0X0072-0X0072  = 0.51

Change Log
===================================================================
Date   Change    Functions
===================================================================
08.10.2009  intermediate steps added between step 1&2 and 3&4
20.10.2009  overvolt cut during erase, tdr time to 10sec, resetVolt1 also changed       
26.10.2009  ADC read method changed, all functions test properly
    alarm ofter step 5, 300v set point during erase,
    working OK.
27.10.2009  TDR switch and bicolor LED also added. 
10.01.2009  Low Cut Added, init at step5, min TDR start time, gap adjustment  
*****************************************************************/
#include<pic.h>
#include<htc.h>
__CONFIG(0x3F4C);
/*****************************************************************/
#define SWITCH     RA2
#define TDR     RA5
#define BUZZER     RC3
#define LED_GREEN   RC4
#define LED_RED    RC5
/*****************************************************************/
#define LED_NORMAL() ((LED_GREEN=1),(LED_RED=0))
#define LED_ERROR()  ((LED_RED=1),(LED_GREEN=0))
#define LED_STANDBY() ((LED_RED=1),(LED_GREEN=1)) 

#define NORMAL  1
#define ERROR 2
#define STANDBY 3
#define LOW_CUT /*0x0058*/0x0050

#define EEPROM_MAX_ADDRESS  128
#define OVER_VOLT   0x00F6
#define FACT1    34-3//gap adjusted
#define FACT2    8-5
#define FACT3    (36-5)+3//gap adjusted
/*****************************************************************/
#define RL1 RA1
#define RL2 RC0
#define RL3 RC1
#define RL4 RC2
/*****************************************************************/
#define ADDR_SPH  0x00
#define ADDR_SPL  0x01
#define RL4_TIMER() ((F_RL4=1),(time=0),(btime=0),(state=STANDBY))
#define RL4_OFF()   ((F_RL4=0),(RL4=0),(state=ERROR))
//#define ADDR_STEP  0x01

#define RL_OFF_ALL() ((RL1=0),(RL2=0),(RL3=~0),(RL4=0))
#define RL_STEP0() ((RL1=0),(RL2=0),(RL3=0))
#define RL_STEP1() ((RL1=0),(RL2=0),(RL3=1))
#define RL_STEP12()((RL1=0),(RL2=1),(RL3=1))
#define RL_STEP21()((RL1=0),(RL2=0),(RL3=0))
#define RL_STEP2() ((RL1=0),(RL2=1),(RL3=0))
#define RL_STEP3() ((RL1=0),(RL2=1),(RL3=1))
#define RL_STEP34()((RL1=1),(RL2=1),(RL3=1))
#define RL_STEP43()((RL1=0),(RL2=1),(RL3=0))
#define RL_STEP4() ((RL1=1),(RL2=1),(RL3=0))
#define RL_STEP5() ((RL1=1),(RL2=1),(RL3=1))
/*****************************************************************/
unsigned char counts;
unsigned int adc_sum;
bit F_SQ_WV,F_MSINT,F_NOTSET,F_BUZ,F_ALARM,F_RL4,F_TDR,F_LC;;
unsigned char eepromAddress;
unsigned int setVolt1,setVolt2;
unsigned int resetVolt1,resetVolt2;
unsigned char step;
unsigned int time;
unsigned int adc_result;
unsigned int adc_val;
unsigned int altime;
unsigned char btime;
unsigned char state;
/*****************************************************************/
void delay(unsigned int);
void save_to_eeprom(unsigned int);
void adc_init(void);
void adc_read_10bit(void);
void timer0_init(void);
void interrupt t0_int(void);
void calibrate_osc(void);
void wait_for_adc(void);
void delayms(void);
void get_sine(void);
void alarm_init(void);
void init_main(void);
/*****************************************************************/
void interrupt t0_int(void)
{
 if(T0IF)
 {
  CLRWDT();
  //TMR0=0x86;//2ms timer
  TMR0=0xE0;//500uS timer with 4Mhz internal oscillator
  if(F_RL4)
  {
   time++;
   if(time>/*10000*/100)
   {
    F_TDR=1;
    btime++;
    time=0;
    if(btime>12)
    {
     F_RL4=0;
     RL4=1;
     state=NORMAL;
    }
   }
   if(/*(TDR==0)&&*/(F_TDR))
   {
    F_TDR=0;
    F_RL4=0;
    RL4=1;
    state=NORMAL;
   }
  }
  if(F_ALARM)
  {
   altime++;
   if(altime>5000)
   {
    altime=0;
    F_BUZ=1;
   }
  }
/*  adc_read_10bit();

  if((adc_result>50)&&(F_UH==0))
   F_UH=1;
  if(F_UH)
  {
   if((counts<16)&&(adc_result>50))
   {
    adc_sum+=adc_result;
    counts++;
   }
   else if(counts==16)
   {
    //badc_val=adc_sum/counts;
    //if(badc_val<0x01FF)
    // adc_val=badc_val;
    F_ADC_SAMPLE=0;
    adc_val=adc_sum/counts;
    F_ADC_SAMPLE=1;
    counts=0;
    adc_sum=0;
    F_UH=0;
   }
   else
   {
    counts=0;
    adc_sum=0;
    F_UH=0;
   }
  }*/
  T0IF=0;
 }
}

void wait_for_adc()
{
 unsigned char k;
 for(k=0;k<5;k++)
 {
  get_sine();
 }
}

void get_sine()
{
 adc_result=0;
 while(adc_result>50)
  adc_read_10bit();
 while(adc_result<=50)
  adc_read_10bit();
 adc_sum=0;
 for(counts=0;counts<40;counts++)
 {
  adc_read_10bit();
  adc_sum+=adc_result;
  delayms();
 }
 adc_val=adc_sum/counts;
}

void delayms()
{
 unsigned char i;
 for(i=0;i<50;i++);
}
void alarm_init()
{
 F_BUZ=0;
 F_ALARM=0;
 altime=0;
}

void beep(unsigned int b)
{
 BUZZER=1;
 delay(b);
 BUZZER=0;
}
  
void init_main()
{
 WPUA2=1; 
 TRISA2=1;//FOR SWITCH
 TRISA5=1;//TDR SWITCH
 TRISC3=0;//BUZZER  
 TRISC4=0;//LED1 
 TRISC5=0;//LED2
 BUZZER=0;
 
 TRISA1=0;//RL1
 TRISC0=0;//RL2
 TRISC1=0;//RL3
 TRISC2=0;//RL4
 F_TDR=0;
}
   
void main()
{

 OSCCAL=_READ_OSCCAL_DATA();
 adc_init();
 timer0_init();
 alarm_init();
 init_main();
 

 RL_OFF_ALL();  
 RL4_OFF();  
 RL4_TIMER(); 
 eepromAddress=0;
 F_NOTSET=0;

 if(SWITCH==0)
 {
  BUZZER=1;
  delay(60000);
  EEPROM_WRITE(ADDR_SPH,0xFF);
  EEPROM_WRITE(ADDR_SPL,0xFF);
  BUZZER=0;
  delay(10000);
  beep(10000); 
  delay(10000);
  beep(10000);
  while(SWITCH==0);
  delay(10000);
 }
 step=5;
 RL_STEP5();
 
 setVolt1=EEPROM_READ(ADDR_SPH)<<8;
 setVolt1|=EEPROM_READ(ADDR_SPL);
 if(setVolt1==0xFFFF)
 {
  F_NOTSET=1;
  setVolt1=OVER_VOLT;
 }
 else
 {
  beep(60000);
 }
 F_LC=1;
 setVolt2=setVolt1+FACT1;
 resetVolt1=setVolt1-FACT2;
 resetVolt2=setVolt1-FACT3;
 while(1)
 {
  get_sine();
  if(state==NORMAL)
   LED_NORMAL();
  if(state==STANDBY)
   LED_STANDBY();
  if(state==ERROR)
   LED_ERROR();
  if(step==0)
  {
   if(adc_val>=setVolt1)
   {
    step++;
    RL_STEP1();
    wait_for_adc();
    RL4=1;
   
    //EEPROM_WRITE(ADDR_STEP,step);
   }
   
   if(adc_val<LOW_CUT)
   {
    if(F_LC)
    {
     RL4_OFF();
     wait_for_adc();
     F_LC=0;
     BUZZER=1;
     delay(60000);
     BUZZER=0;
     delay(60000);
    }
   }
   else if((adc_val>(LOW_CUT+6)))
   {
    if(F_LC==0)
    {
     state=NORMAL;
     RL4=1;
     F_LC=1;
    }
   }
  }
  else if(step==1)
  {
   if(adc_val>=setVolt2)
   {
    step++;
    RL_STEP12();
    delay(4000);
    RL_STEP2();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
   else if(adc_val<resetVolt1)
   {
    step--;
    RL_STEP0();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
  }
  else if(step==2)
  {
   if(adc_val>=setVolt1)
   {
    step++;
    RL_STEP3();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
   else if(adc_val<resetVolt2)
   {
    step--;
    RL_STEP21();
    delay(4000);
    RL_STEP1();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
  }
  else if(step==3)
  {
   if(adc_val>=setVolt2)
   {
    step++;
    RL_STEP34();
    delay(4000);
    RL_STEP4();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
   else if(adc_val<resetVolt1)
   {
    step--;
    RL_STEP2();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
  }
  else if(step==4)
  {
   if(adc_val>=setVolt1)
   {
    step++;
    RL_STEP5();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
   else if(adc_val<resetVolt2)
   {
    step--;
    RL_STEP43();
    delay(4000);
    RL_STEP3();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
  }
  else if(step==5)
  {
   if(adc_val>(setVolt2+10))
   {
    step++;
    //RL_OFF_ALL();
    RL4_OFF();
    wait_for_adc();
    F_ALARM=1;
    //EEPROM_WRITE(ADDR_STEP,step);
   }
   else if(adc_val<resetVolt1)
   {
    step--;
    RL_STEP4();
    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
  }
  else if(step==6)
  {
   if(F_BUZ)
   {
    beep(20000);
    F_BUZ=0;
   }
   if(adc_val<(setVolt2-10))
   {
    F_ALARM=0;
    RL4_TIMER();    
    delay(20000);
    beep(20000);
    delay(20000);
    beep(8000);
    delay(20000);        
    beep(20000);
    step--;
    //RL_STEP5();

    wait_for_adc();
    //EEPROM_WRITE(ADDR_STEP,step);
   }
  }
  //delay(10000);  
  if((SWITCH==0)&&(F_NOTSET))
  {
   delay(40000);
   if(SWITCH==0)
   {
    F_NOTSET=0;
    BUZZER=1;
    setVolt1=adc_val-3;
    //save_to_eeprom(adc_val);
    save_to_eeprom(setVolt1);
    setVolt2=setVolt1+FACT1;
    resetVolt1=setVolt1-FACT2;
    resetVolt2=setVolt1-FACT3;
    step=0;
    delay(10000);
    BUZZER=0;
   }
  }
 }
}

void save_to_eeprom(unsigned int d)
{
 if(eepromAddress<EEPROM_MAX_ADDRESS)
 {
  EEPROM_WRITE(eepromAddress,d>>8);
  eepromAddress++;
  EEPROM_WRITE(eepromAddress,d);
  eepromAddress++;
 }
}
 
void adc_init()
{
 //ADCON0=0x00;//LEFT JUSTFIED AN0 CHANNEL
 ADCON0=0x80;//RIGHT JUSTFIED AN0 CHANNEL
 ADCON1=0x50;//FOSC/16
 //ADCON1=0x30;//AD RC clock
 ANSEL=0x01;//AN0 angalog channel
 TRISA0=1;
 ADON=1;
 counts=0;
 adc_sum=0;
 adc_val=0;


}
void adc_read_10bit()
{
 GODONE=1;
 while(GODONE);
 adc_result=(ADRESH<<8)|ADRESL;
}

void timer0_init()
{
 OPTION=0x03;//divide by 16 prescale
 //TMR0=0x86;//2ms timer with 4Mhz internal oscillator
 TMR0=0xE0;//500uS timer with 4Mhz internal oscillator
 T0IE=1;
 PEIE=1;
 GIE=1;

void delay(unsigned int k)
{
 unsigned int i;
 for(;k>0;k--) 

its working ?

Plz give Stubleser circuits diagram...
i want full sercute

hello,

     everything is fine....but i have a doubt....anyway whatever the input voltage may be (say 220v/440v/110v) it is going to be stepped down to operating voltage of 3-5 v. how can the microcontroller recognize the correct value of the input voltage. I am new to microcontrollers and please explain. I want to use stm8s value line discovery kit (stm8s003 mcu) instead of pic. 

thank you for all

Thanks all

sir i file best engineer whit u

 

 

Dear sir

              Please give source code for this project so that I may check it.

Thanks.

Regards

Rajesh singhal

Hello, Thank you for sharing this project. 

 

There are some hints I need to know about the code. 

 

1- What is the clock frequency? should we set it on 4Mhz internal resonator?

 

2- What are the configuration bits?

 

Does this AC-VM need any calibration? And how precise is this?

 

 

 

Seven segments are common anode or common cathode?

for an unknown reason the author has decided to share an incomplete project. Please try Proteus simulation before making this.

Hello,

 

I am AVR user. I could not understand the logic used in PIC. Can you help me with the conversion equations in ADC after conversion in which you used at the time of coding.

Hello,

 

I have used the same circuit to the voltage. But in hardware at resistor r1 220k the voltage is 13.40VDC and after r2 220k the volatage is 2.4 VDC. Am using 0-6v 500mA transformer as input.

 

Means,

 

From transformer i get 6 VAC output to bridge rectifer. The bridge rectifier gives 13.40 VDC to resitor R1. 

 

Suggest me that i need 5.1v output near resistor r2.

 

Your reply will be appreciated.

 

Regards,

Ramana Madishetty

Hello,

 

I have used the same circuit to the voltage. But in hardware at resistor r1 220k the voltage is 13.40VDC and after r2 220k the volatage is 2.4 VDC. Am using 0-6v 500mA transformer as input.

 

Means,

 

From transformer i get 6 VAC output to bridge rectifer. The bridge rectifier gives 13.40 VDC to resitor R1. 

 

Suggest me that i need 5.1v output near resistor r2.

 

Your reply will be appreciated.

 

Regards,

Ramana Madishetty

 

I am AVR user. I could not understand the logic used in PIC. Can you help me with the conversion equations in ADC after conversion in which you used at the time of coding. i want sense 0-270 volt AC.....i am complit this circuit and i have got 0-5v dc from 0- 270v AC please replay me fast .i AM WATING YOUR REPLAY...

yes

yes

Hi friends,

 how to change the code to display 16x2 Lcd

plz tell

 

crazy about electronicss

UDC1.c(15): error C200: left side of '.' requires struct/union

 

error found during creating  Hex file, any body help me.

Source Code To .HEX File Plese Give Me?

 

Nice, good code optimization
Good

good

 

can any help me for dual channel ac voltmeter(0-500v) and current diaplay circuit

 

Plz give me ac voltage meter hex file with circuits

Guys this so called project is a total BS. Don't try it. I have no idea why an idiot should waste others time sharing crap.

pls dend me 5step stabilizer pcb design & source code.

What is the power of the R1 and R2 resistor? The bridge rectifier can be 1A?

Sir i am getting two errors 
 Undeclared identifier 'WPUA' in expression 

 Undeclared identifier 'ANSEL' in expression \

Plz help

Gn

Gn

i'he need 220v ac volt meter using three 7segment.

 

Pages

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Search Engines will index and follow ONLY links to allowed domains.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This is to ensure that you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.