PWM Fan Speed Control

Do you have a question on how to do something.
Ask in here.
Post Reply
sjmusic2
Posts: 33
Joined: Sun Sep 25, 2011 8:25 pm

PWM Fan Speed Control

Post by sjmusic2 »

I am trying to associate a pwm duty cycle with my led array temps (on T2). I don't want to use the map function as I don't want the fan speed to be changing constantly...

My problem is that the RA displays 25 (%) regardless of the array temp, please help.

At the beginning I declare :
byte LEDTemp;
byte FANPWM=100; (I want the fans to start at full speed)
and use the following to display in Custom Main :
//display Fan PWM%
ReefAngel.LCD.DrawText(COLOR_MIDNIGHTBLUE,DefaultBGColor, 12, 83, "FAN% :");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetChannelValue(0), COLOR_MIDNIGHTBLUE,
50, 83, 1);
and this in void loop ()
    //Fan PWM Control on PWM Module Channel 0
    LEDTemp=(ReefAngel.Params.Temp[T2_PROBE]);
      if (LEDTemp < 680)
      {FANPWM=25;}
      else if
      (LEDTemp >= 680 && LEDTemp < 700)
      {FANPWM=35;}     
      else if
      (LEDTemp >= 700 && LEDTemp < 750)
      {FANPWM=50;}
      else if
      (LEDTemp >= 750 && LEDTemp < 780)
      {FANPWM=65;}
      else if
      (LEDTemp >= 780 && LEDTemp < 800)
      {FANPWM=85;}
      else if
      (LEDTemp >= 800)
      {FANPWM=100;}
    FANPWM=constrain(FANPWM,0,100);
    ReefAngel.PWM.SetChannel(0,FANPWM);
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PWM Fan Speed Control

Post by rimai »

LEDTemp need to be int and not byte.
Byte variables can only hold up to 255.
Roberto.
sjmusic2
Posts: 33
Joined: Sun Sep 25, 2011 8:25 pm

Re: PWM Fan Speed Control

Post by sjmusic2 »

It's always the obvious things !

Thanks :)
Post Reply