Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ATmega8 Fan control - schematics verification, suggestions needed.

Status
Not open for further replies.

konradIC13

Member
Hello,

Is my another thread, its the final one :p My project has evolved to its almost final stage. I present a complete (maybe?) schematic of it.

What it will do?
- AVR controlled cooling pad
- Depending from input signal (from switches SW[1,2,3] ATmega8 with use of logic function will turn on/off appropriate fans and segments of RGB Led (common anode), the action will be either to turn on or off just 1 and 0.
- situation where only 1 RGB LED segment is on and only 1 fan works might happen but also there might be situation where the whole RGB diode is on and all fans are on

Parameters of fans, LED:
- FAN1 takes 240mA of current, FAN2 takes also 240mA of current
- FAN3 takes 220mA of current
- FAN4 takes 200mA of current
- RGB LED is common anode, the If of each segment (for Red, for Green, for Blue) is 20mA, voltage drop is 1.95V for Red, 3.3V for Green and 3.3V for Blue
ATmega8 output electrical characteristics:
- output current max 20mA
- output voltage low max 0.9V, high min 4.5V

Other:
- Powered from 9V DC adapter, stabilized at 5V with 78S05 (max 2A)

Questions and thoughts:
- R2, R4, R6 resistor values, are they big enough to protect MOSFET gate?
- did i place all components related to good work of U1, U4 and U6 MOSFETs? are there any other transistors i should attach to them?
- did i place all components related to good work of Q1, Q2 and Q3 NPN transistor? are there any other transistors i should attach to them?
- voltage regulator capacitor values, good/bad should I change something?
- do i have to place current limiting resistors before fans? They are 5V DC brushless fans, 5V is rated voltage and with that voltage rated current drain are as i listed above
- is there anything else i should know/change in my schematic?

View attachment 65227
 
It looks very good to me. The FETs are bigger than you need, but thats ok if you don't mind the cost.

The LEDs are running right at the 20 ma spec. which is ok to, but you might run a little lower current.

The current when the fans are trying to start can be 5 or 6 times the running current so you might want to stagger the turn on time in your code instead of turning them all on at once. The regulator should have a heat-sink.
 
Last edited:
Hello, i have assembled my design with small changes to schematic but a small problem have appeared and i have no idea where does it come from.

When i plug in power and run my device everything works as it supposed to work but after a while (from 1 min to 5 min) blue LED stops working. All other things works fine but only blue LED is not working. When i turn off the power and turn it on again it works again (everything + blue LED) but after another while (1min to 5min) blue LED is off again.

Here is my PCB, Schematic and C program
View attachment 65759
View attachment 65760

Code:
/*
 * PB1, PB2, PB3 outputs to LED segments
 * PD1, PD2, PD3 outputs to fan control
 * PC3, PC4, PC5 inputs from switches
 */ 

#define F_CPU 1000000L
#include <avr/io.h>

int main(void)
{
	char SW1,SW2,SW3;
	/*LED*/
	DDRB =0b00001110;		  //PB1, PB2, PB3 output (other inputs)
	PORTB=0b11110001;		  //PB1, PB2, PB3 initial condition low (other pulled up)
	/*SWITCHES*/
	DDRC =0b00000000;		  //PC3, PC4, PC5 input (other inputs)
	PORTC=0b11111111;		  //PC3, PC4, PC5 pulled up (other pulled up)
	/*FAN*/
	DDRD =0b00001110;		  //PD1, PD2, PD3 output (other input)
	PORTD=0b11110001;		  //PD1, PD2, PD3 initial condition low (other pulled up)

    while(1)
    {
	SW1 = (PINC & (1<<PC5));  //PC5 value to SW1
	SW2 = (PINC & (1<<PC4));  //PC4 value to SW2
	SW3 = (PINC & (1<<PC3));  //PC3 value to SW3

/* Red LED segment control
*/  
	if (((SW1&&SW3)||(SW1&&(!SW2)))!=0)
	{   
		PORTB |= (1<<PB1);    //set PB1 output as 1
	}
	else
	{
		PORTB &=~ (1<<PB1);   //set PB1 output as 0
	}
/* Green LED segment control
*/	
	if (((SW1&&(!SW3))||(SW1&&(!SW2)))!=0)
	{
		PORTB |= (1<<PB2);    //set PB2 output as 1
	}
	else
	{
		PORTB &=~ (1<<PB2);   //set PB2 output as 0
	}
/* Blue LED segment control
*/		
	if (((SW1&&SW2)||(SW1&&SW3))!=0)        //LED B
	{
		PORTB |= (1<<PB3);    //set PB3 output as 1
	}
	else
	{
		PORTB &=~ (1<<PB3);   //set PB3 output as 0
	}
/* FAN1 control
*/	
	if (((SW1&&SW2)||(SW1&&(!SW3)))!=0)
	{
		PORTD |= (1<<PD1);    //set PD1 output as 1
	}
	else
	{
		PORTD &=~ (1<<PD1);   //set PD1 output as 0
	}
/* FAN2 control
*/	
	if (((SW1&&SW2)||(SW1&&SW3))!=0)
	{
		PORTD |= (1<<PD2);    //set PD2 output as 1
	}
	else
	{
		PORTD &=~ (1<<PD2);   //set PD2 output as 0
	}
/* FAN3 control
*/	
	if ((SW1&&SW3)!=0)
	{
		PORTD |= (1<<PD3);    //set PD3 output as 1
	}
	else
	{
		PORTD &=~ (1<<PD3);   //set PD3 output as 0
	}

	}
}

Device is powered from 5V stabilised power supply, as you can see, in PCB layout and schematic i have separated AVR Gnd, Fan Gnd and Led gnd and also i separated AVR Vcc, Led Vcc and Fan Vcc from each other to have smaller board and complete autorouting (if all GNDs and Vccs were connected it could not find solution) but in real all GNDs and Vccs are connected to one VCC and GND.

Could it be damged transistor (one responsible for turning on and off blue LED)?
 
Last edited:
Could it be damged transistor
Maybe. Replace it and see what happens. Worth checking for a dry joint in that area, too.
 
Hello,

A blue LED can have voltage drop about 3.3V. Use that to calculate resistor bearing in mind that you need at least 5mA for proper work (normal 10 to 20 mA).

If you use 1N4007 diode as free-wheel diode, that is not good. You have to use fast diode to avoid damage of MOSFETs. For example use BA159.

If you turn-on MOSFETs at some frequency, better put large resistor between gate and sourse for fast turning-of.

[MODNOTE]Deleted Spam link[/MODNOTE]

Greetings...
 
Last edited by a moderator:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top