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.

I'm not able to switch my transistor to stop dc fan when temp rises

Status
Not open for further replies.

priyanka pew

Newbie level 4
Joined
Sep 16, 2014
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
40

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
 
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
 
char display[16];
void Move_delay()
{
   delay_ms(500);
}
  void main()
  {
  unsigned int result;
  int volt,temp;
  trisb=0;
  portb=0;
  trisc.f3=0;
 portc.f3=0;
  trisa=0b11111111;
  adcon1=0b10000000;
  lcd_init();
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_Cmd(_LCD_CURSOR_OFF);
  while(1)
    {
    result=ADC_READ(1);
    volt=result*4.88;
    temp=volt/10;
    Lcd_out(1,1,"temp=");
    inttostr(temp,display);
    Lcd_out(1,6,display);
    Lcd_out_cp("c");
if(temp>=32)
  {
  portc.f3=0;
  }
  else if(temp<32)
  {
  portc.f3=1;
  }
  }
  }

 
Last edited by a moderator:

hi,
Is the LCD display showing the correct temperature.?
Code:
     result=ADC_READ(1);
    volt=result*4.88;
    temp=volt/10;
    Lcd_out(1,1,"temp=");
    inttostr(temp,display);
    Lcd_out(1,6,display);
    Lcd_out_cp("c");
You have set ADCON1 for right justify, so result is a WORD integer.
Assume result = 1000 counts, so times 4.88 [ which is fractional] would give 4880, then you divide by 10, so thats 488Cdeg.??? [ or integer 400 Cdeg]
E
 

hello,

it seems you measure mV and divide by 10..
so your sensor must be like a LM335 ? 10mV/°C
is it a true model 0°C -> 0mv 100°C ->1000mV ?
so will give 320mV at 32°C


Be carrefull ,because some device are referenced as °K
and gives an output of 2730mV at Zero °C !


you can also change your test as

Code:
if(temp>=320)
  {
  portc.f3=0;
  }
  else 
  {
  portc.f3=1;
  }
 

Why do you want to stop the fan when temp rises. The fan has to run when temp rises and stop when temp decreases.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
 
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
 
 
double temp = 0.0, prevVal = 0.0;
char display[17];
 
void main()
{
  
  TRISB = 0;
  PORTB = 0;
  TRISC = 0x00;
  PORTC = 0x00;
 
  TRISA = 0xFF;
  ADCON1 = 0x80;
  CMCON = 0x07;
 
  LCD_Init();
  Lcd_Cmd(_LCD_CURSOR_OFF);
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_out(1,1,"Temp = ");
  Lcd_out(1,14,"C");
 
 
  while(1)
  {
    temp = ADC_READ(1) * 0.4888;
    
    if(prevVal != temp)
    {
 
        FloatToStr(temp,display);
        Lcd_out(1,8,display);
    
        if(temp >= 32.0)
        { 
            PORTC.F3 = 1;
        } 
        else if(temp < 32.0)
        {
            PORTC.F3 = 0;
        }
 
    prevVal = temp;
   
    }
  }
}

 
Last edited:

hello milan.

I agree with your remark ,
but We don't know how he drives his Fan..(hardware point of vue)
if in positive safety situation for example..
output drive the relay and if using N.C. contact instead of N.O. contact
the Fan is running with a command=0 and stop with command=1
and also the Fan continue to run if PIC Power is OFF.
(if we suppose the fan is powered by another souce as 12v)
 

paulfjujo the title of the thread is "not able to switch my transistor to stop dc fan when temp rises"
why shd you stop dc fan when temperature rises, might be mistake or might be temperature of the fan rises..
 

i understund the tittle of this thread like this :
Put the FAN ON when temperature is over 32°C !
.. for cooling

... is it ?

:-? it seems ,i am wrong..but it is an unsual use of a fan..

waiting priyanka.pew feedback ..

but the main problem was on the Temp value itself..

after we never see the hardware schematic , how the transistor drives the fan
if PNP intsead of NPN ?
or if he adds a relay , and what kind of contact is used ...

Logical output of the PIC could be reversed by the hardware connected on it.
 
Last edited:

i worked on it sorry for late reply...........when i use dc motor i m able to control motor with temperature increases or decreases but not able to control fan dc fan.

my sensor is lm35
 

a DC Fan could be a brushless motor, (not a Classic DC motor with inductor coil and magnet.)
It's need special driving..
 

i knew it i i simulate that in proteus...........
 

if I may suggest another solution, the LM35 is 10mV/'C , you could use a variable threshold and comparator to drive a high or low side FET to drive the Fan.

With a little negative feedback you can control the fan speed from 0 to full speed over a 10'C range such as 40~50'C.

Of course you do this in software but with appropriate driver voltage with RdsOn to power Fans starting from 1 W. Even a thermistor bridge could work with a precision Comparator or Op Amp.and a regulated voltage.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top