EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / pls help PWM fan

pls help PWM fan

|

Microcontroller › 8051 › pls help PWM fan

  • This topic has 1 reply, 2 voices, and was last updated 13 years, 1 month ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 19, 2012 at 4:15 pm #4793
    Chan
    Participant

    i want to use two button to control the fan speed  (fast and slow)

     

    this is the code

     

     

    #include <reg52.h>

    unsigned char timer1;

    int time;

    sbit PWM=P1^2;

    void system_Ini()

    {

        TMOD = 0x10;

        TH1 = 0xfe;

        TL1 = 0x33;

        TR1 = 1;

        IE = 0x8A; 

    }

    /**************************************************

    Function: delay_us();

     

    /**************************************************/

    void delay_us(unsigned int x)

    {

        unsigned int i=0;

        for(i=0;i<x;i++)

        {;}

    }

     main()

    { time=50;

      system_Ini();

      while(1)

      {

        P2|=0xff;

        if(P2==0xfe&&time<100)

          {delay_us(1200);

          if(P2==0xfe)

          time+=1;}

        if(P2==0xfd&&time>0)

          {delay_us(1200);

          if(P2==0xfd)

          time-=1;}

        if(timer1>100)

        timer1=0;

        if(timer1<time)

        PWM=0;

        else

        PWM=1;

      }

    }

    /*************************************

     

    *************************************/

    void T1zd(void) interrupt 3    

    {

        TH1 = 0xfe; //11.0592

        TL1 = 0x33;

         timer1++;

    }

     

     i use the software to test 

     

     

     

     

    it shows the code is work?

     

    but will test in hardware

     

    all the thing is not work!! 

     

     

     I don’t know where is the problem can anyone help pls

    December 20, 2012 at 12:44 pm #8861
    AJISH ALFRED
    Participant

    Hi Chan,

    Kindly add appropriate comments to your code and post again keeping the proper intendation. You will surely get help, and you must help others to read and understand your logic which is done in your code.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Buffer design? February 9, 2026
  • ANOTHER OLD PROJECT REDO February 9, 2026
  • BPF February 9, 2026
  • To couple or decouple February 9, 2026
  • Op amp shock February 9, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise