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.

temperature controlled fan

Status
Not open for further replies.

Amith Jose

Newbie level 4
Newbie level 4
Joined
Aug 12, 2013
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
50
hey am a newbie , trying to make a temp controlled fan using a pic16f877a.
i hope to vary the rpm using PWM .
i made a design and code but unfortunately smething's wrong with it..

i have like zero experience when it comes to PWM, so i doubt the problem is with my code.
I used an 'lm35' to sense the temp and a 'l293d' as the driver circuit to run the fan ..

please help me out .

//code



#include <16F877A.h>
#device adc=8

#FUSES NOWDT,HS
#use delay(clock=20000000)
#include <lcd.c>

void main()
{
int x;

lcd_init();
setup_adc(ADC_CLOCK_DIV_32);
setup_adc_ports(ALL_ANALOG);
setup_timer_2(T2_DIV_BY_4,255,1);
setup_ccp1(CCP_PWM);
delay_ms(500);
while(1)
{
set_adc_channel(0);
x=read_adc();
delay_ms(5);

lcd_putc('\f');
lcd_gotoxy(1,1);
lcd_putc("Temp");

printf(lcd_putc,"%u\n",2*x);
delay_ms(20);



if(x<40)
{ set_pwm1_duty(3*x);
OUTPUT_HIGH(PIN_C6);
OUTPUT_LOW(PIN_C7);

}
else if(x>40)
{set_pwm1_duty(255);
OUTPUT_HIGH(PIN_C6);
OUTPUT_LOW(PIN_c7);
}
else
{OUTPUT_LOW(PIN_C6);
OUTPUT_LOW(PIN_C7);
set_pwm1_duty(0);
}
}
}
 
Last edited:

Hello there,
i made a design and code but unfortunately smething's wrong with it..

what is the problem are you facing???

Best regards,
 

Attachments

  • 04_A2D.zip
    101.2 KB · Views: 65
  • 08_PWM.zip
    103.9 KB · Views: 56

the problem i am facing is that the fan rotates at times, sometimes it rotates for a while and then slows down and stops,
temp detecting part is ok, but cant control the fan speed..
 

Hello there,

Code:
f(x<40)
{ set_pwm1_duty(3*x);
OUTPUT_HIGH(PIN_C6);
OUTPUT_LOW(PIN_C7);

}
else if(x>40)
{set_pwm1_duty(255);
OUTPUT_HIGH(PIN_C6);
OUTPUT_LOW(PIN_c7);
}
else
{OUTPUT_LOW(PIN_C6);
OUTPUT_LOW(PIN_C7);
set_pwm1_duty(0);
}
}
}


Code:
x=read_adc();

Can you check whether X is constant value or not?? it might be the problem from adc read .. ADC values may varying and it enters the if -else loop randomly ..Check your hardware connection and analog voltage strength?? is there any noisy signal on analog input pin??

Update me.

Best regards,

- - - Updated - - -

Try these too

Code:
[B]set_adc_channel(0);[/B]
while(1)
{

x=read_adc();
delay_ms(5);

lcd_putc('\f');
lcd_gotoxy(1,1);
lcd_putc("Temp");

printf(lcd_putc,"%u\n",2*x);
delay_ms(20);



if(x<40)
{ set_pwm1_duty(3*x);
OUTPUT_HIGH(PIN_C6);
OUTPUT_LOW(PIN_C7);

}
else if(x>40)
{set_pwm1_duty(255);
OUTPUT_HIGH(PIN_C6);
OUTPUT_LOW(PIN_c7);
}
else
{OUTPUT_LOW(PIN_C6);
OUTPUT_LOW(PIN_C7);
set_pwm1_duty(0);
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top