Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] building a voltage regulator

Status
Not open for further replies.

Deexith Hasan

Advanced Member level 4
Joined
Oct 24, 2014
Messages
111
Helped
4
Reputation
8
Reaction score
3
Trophy points
18
Activity points
740
i'm designing a voltage regulator that allows only voltage range between 200-250v ac 50hz to the output and blocks all other voltages....
i'm designing this with help of atmega8......

my problem is the adc of mcu or the total system of mcu samples the input at every 21 ms but my input signal is 50hz is it normal........
i tried to increase the crystal frequency(20MHZ->40Mhz) but got little difference in sampling rate of 19ms....

- - - Updated - - -

i have attached the code and proteus simulation




Code:
#include <avr/io.h>
#include <util/delay.h>
#include <lcd_4bit.h>
#include <adc.h>


#define F_CPU 20000000

void delay()
{
unsigned char i;
for(i=0;i<10;i++)
{
lcd_cmdwrite(0xC0);
lcd_datawrite((0x30+i));
PORTD=~(PORTD|0b01111111);
_delay_ms(800);

}
}




  void main(void)
  {
    unsigned char u=0;
	unsigned long b;
	 lcd_reset();
	 
	 lcd_install();
	  DDRD=0XFB;
		 
	 
	  while(1)
	  {
	    
	    if(u==0)
		{
		 lcd_cmdwrite(0X01);
		 lcd_goto(0,0);
		 
		 lcd_stringwrite("ON DELAY");
		 delay();
		 
		 u=1;
		 
		 lcd_cmdwrite(0x01);
		 b=adc_read(5);
		 b=b*449;
		 lcd_goto(1,0);
		 lcd_goto(1,0);
		 lcd_stringwrite(" V=");
	   	 lcd_nowrite(b);
		 if (b>210000&&b<250000)
		 {
		 while((PIND&0B00000100)==0);
		 
		 lcd_goto(0,0);
		 lcd_stringwrite("PERFECT"); 
		 PORTD=PORTD|0B00000001;
		 }
		}
		
	         
			  
			while(b>210000&&b<250000)
			   {  
			      b=adc_read(5);
				  b=b*449;
		          lcd_goto(1,0);
			      lcd_stringwrite(" V=");
	   		      lcd_nowrite(b);  
			   	  lcd_goto(0,0);
		          lcd_stringwrite("PERFECT"); 
			      PORTD=PORTD|0B00000001;
				  PORTD=~(PORTD|0b01111111);
				  
			   }
			    PORTD=PORTD&0B11111110;
				lcd_cmdwrite(0x01);
				
			   while(!(b>210000&&b<250000))
			   {
			    PORTD=PORTD&0B11111110;
				
			    lcd_goto(0,0);
				
			    lcd_stringwrite("CHECK VOLTAGE");
			    u=0;
				b=adc_read(5);
				b=b*449;
		        lcd_goto(1,0);
		        lcd_stringwrite(" V=");
	   	        lcd_nowrite(b);
			   }
			   
			 
			
		 
			
	  }
	
	
	
	
  }
 

Hard to say anything without schematics. What should your atmega do? It can be done by only one comparator.
 

one of the reasons for such execessive delay is :
some part of your c code is eating up the time.

for a 20mhz atmega , it have lot of time for this application(of finding the voltage range and displaying)

one solution is , write your code in atmega assembly language . this will not have the problem you have faced.

another , if you are not familiar with assembly, find that part of the c code which eats up the time and rewrite.
 

Just make a conversion and compare on interrupts. It will be able to catch value every 1ms and even less.
 

what is the range of input (minm to maximum)given to adc ?
usable range ?
8 or 10bits ?
 

Connect your input source to a relay circuit and control the relay with Atmega

So you are getting ADC values, check what are the ADC values for the input of 200-250v.
Depending on the min and max values ON/OFF the relay.

So
 

after rectification i'm getting 16v for 230v ac i/p and made 2.5v using voltage divider and measured using ADC of mcu.........i need to place this setup in mains which handles 40 amps can i use 40 amp relay kt-909 or contactor relay??
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top