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 sensor -PIC 16f877

Status
Not open for further replies.

delifadzli

Member level 2
Joined
Feb 5, 2010
Messages
50
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
malaysia
Activity points
1,774
Hi everyone,

First of all,I am newbie here. can u all give me an explanation regarding ADC things. The project is to develop an automatic fan based on temperature sensor. to interface PIC16f877 - conversion of ADC are really important matter to me (since i not quite good in programming). since the range of PIC is 0-5 v, i want make it in this way

if the sensor give 1v voltage = speed no 1 on (slow speed)
if the sensor give 2-3 vol = speed no 2 on ( medium speed)
if the sensor give 4-5 vol = speed no 3 on ( high speed)

the problem is to justify the input. How to make the PIC see it as digital input ( 1-5 only). I really confused in converting ac source ( temperature sensor) to PIC ( digital source).

Please everyone, can u help me??

sorry for my English
 

actually , i still doesn't know the actual temperature sensor need to be used (since in research session) . can u suggest one?? a lot of research have been made...but still, I'm clueless to choose
 

Hi,
For ease, a good choice would be LM35/LM335, but LM35/LM335 gives 10mV output per degree Celsius, ie, for 25'C you get 250mV, for 50'C, 500mV and so on up till 150'C down from -55'C. So, you won't get 2/3/4/5 v. So, change the algorithm. Instead of choosing range in voltage, choose in temperature, eg, if temp is between 20'C and 30'C, slow, between 31'C and 60'C medium, above 60'C to 150'C, quick.
Something like that.
Which language? I can help you if you use mikroBASIC.
Hope this helps.
Tahmid.
 
thanks for the info.it really a good suggestion. I'm planning to use PIC16f877 with c language...isn't OK?
 

Ok, which compiler? mikroC, CCS, Hi-Tech?
I recommend mikroC although the choice is very much upto you.
 

this project basically aim to control the traditional fan...so the temperature range...

actual temp = 26 cel

slow speed = 20-25 cel

medium speed = 26-29 cel

high speed = 38-50 cel


correct me if you though my idea is not good. appreciate it...
 

Seems okay.
By traditional fan, do you mean DC fan or AC wall fan?
For wall fan, programming is slightly more complicated, but way easier for a normal DC fan.
Tahmid.
 

just the normal DC fan...for this project

Added after 19 minutes:

to Tahmid, sorry for late response...just came back from electronic shop ( survey)....
 

Hi,
mikroC code:
Code:
#define slow 32 //Duty cycle set for slow
#define medium 96 //Duty cycle set for medium
#define fast 230 //Duty cycle for fast
#define cel20 41 //20'C
#define cel50 102 //50'C

//I set range as:
//Less than 20'C : speed is slow
//From 20'C to 50'C : speed is medium
//Greater than 50'C : speed is fast

int ADVal; //Variable to store ADC result
unsigned char duty;

void main(void){
     TRISC = 0;
     PORTC = 0;
     PWM_Init(5000); //5khz pwm
     PWM_Change_Duty(medium); //50% duty cycle
     PWM_Start(); //Start PWM
     while (1){
           ADVal = ADC_Read(0);
           if (ADVal < cel20){
              duty = slow;
           }
           if ( (ADVal > cel20) & (ADVal < cel50) ){
              duty = medium;
           }
           if (ADVal > cel50){
              duty = fast;
           }
           PWM_Change_Duty(duty); //Change duty cycle and adjust
           delay_ms(100); //Wait for adjusting (Optional and may be left out)
     }
}
I don't have a 16F877 in my possession, but I tested this with 18F452 and runs fine.
The PWM output will be at pin RC2(pin 17) and connect MCLR to 5v, use 4MHz crystal.
I hope you can set the config bits.

I changed the range slightly. Hope it doesn't pose a problem.

Hope this helps.
Tahmid.
 

    V

    Points: 2
    Helpful Answer Positive Rating
wow... thanks for the knowledge and info. I'm really pleased with this things. Really appreciate Ur work.....truly happy right know.. hopefully it will became a good guidance for the project..
 

slow = 32

medium = 96

fast = 230

how u change that...?

to be truth I'm not quite good in PWM...

i hope u can give a little explanation regarding this kind of things or some calculation.. .... wait for ur respond...
 

Hi,
The duty cycle is on a scale on 255. 255 = 100%
32 = 12.5%
96 = 38%
230 = 90%
Just, where I defined it, change the values. For say, 45%, your value should be (0.45 * 255) = 115
Hope you understood.
Tahmid.
 

i see in the pwm_init u set the pwm frequency as 5000. but u said that the duty cycle is 255? pls explain. thanks.
 

Hi,
I initialized as 5000. That means my frequency is 5kHz. Nothing to do with the duty cycle.
Now if I have duty cycle 25%, that is 64, (64/255 ~= 0.25), I will have a 100microsecond period with a 25 microsecond on time and 75 microsecond off time. But frequency will still be 5kHz.
Hope you understood.
Tahmid.
 

ok...thanks for the info...by the way,

isn't really difficult to use AC fan?.. huhu... My supervisor ask me to replace Dc fan with AC fan..

can still use the code?? or implement transformer or some relay toward ac fan?? ... hope for ur respond...

thanks...
 

Hi,
For AC fan, you need to use phase control with triac, or full-bridge with existing code(rather not do this, will result in noise from the fan and also not an easy job).
In the mikroElektronika forum, they have a topic on just this purpose, take a look at it. I can't seem to find it right now, but if you Google around a bit, you might find it.
Tahmid.
 

ooo...i see...so the situation right know, is to clear up with my supervisor ( since the marks are given by her)... i wanna ask... ceiling fan projects ...isn't OK i implement just DC motor for the prototype....??or AC motor... hope for Ur opinion...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top