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 / GENERATING VARIABLE PWM

GENERATING VARIABLE PWM

|

Microcontroller › 8051 › GENERATING VARIABLE PWM

  • This topic has 17 replies, 4 voices, and was last updated 14 years, 1 month ago by AJISH ALFRED.
Viewing 3 posts - 16 through 18 (of 18 total)
← 1 2
  • Author
    Posts
  • August 10, 2012 at 6:02 pm #8438
    AJISH ALFRED
    Participant

     

    Try the code and update the result,

     

     

    #include <reg51.h>
    sbit INCREASE = P2^6;
    sbit DECREASE = P2^7;
    sbit MTR = P1^0;
    void MSDelay(int value);
    void main()
    {
    unsigned int on,off;
    on=20;                                                                                             //initial value of ON time delay
    off=0;                                                                                              //initial value of OFF time delay
     
    while (1)
    {
        while(ONE==1 && TWO==1)                                                  //when both keys are open
        {

            //—-generating PWM


    //
            MTR=1;
            MSDelay(on);                                                                        //applying ON time delay
                                                                        
            MTR=0;
            MSDelay(off);                                                                        //applying OFF time delay
            //


    //
        }

     

        //—when any of the key is down, exit from while loop and check which key is down–//
      

      if(INCREASE==0 && on<20)                                                 //if key increase is down check whether it has max value or not
        {

            on++;
            off–;                                                                                     //—-increment ON time delay if it is not maximum–//

           //


    //
        }
        else if (TWO==0 && on>0)                                                     // if key decrease is down check whether it ON time delay >0//
        {

            on–;
            off++;                                                                                  //—-decrement ON time delay if it is not zero—-//

            //


    //

     

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

    //ADD DELAY HERE

     

    MSDelay(1000);

     

        }
    }

    }
    void MSDelay(int value)                                                               // Delay function //
    {
    int x;
    for(x=0;x<=value;x++);
    } 

    August 18, 2012 at 8:29 am #8476
    Varun Srivastava
    Participant

    Hii,

     

    Ajish

     

    sry fr d delay…!!!

     

    Iwould lyk to let u knw dat the problem is resolved on hardware by considering switch debounce into account.

     

    I would also lyk to give you more overview of wat i m doing.

     

    I am using this GENERATED PWM for driving the GATE of a MOSFET which infact is controlling the current in my LOAD and wid all our previous efforts we are able to vary the DUTY CYCLE of the PWM.

     

     

    Now the next problem which is faced is that the LOAD is taking HICCUPS due to discontinuity of the GATE driving voltage wen i change the PWM DUTY CYCLE as there is no voltage present at that duration of time when the switch is pressed and the DUTY CYCLE changes.

     

    As per my knowledge, I think that this is happening bcoz dere is no HOLDING CURRENT to sufficiently keep the MOSFET on during that period of SWITCH press.

     

    I would lyk to know about ur suggestion over this thing and whether you have any other possible explanation that why this is happening, also if u cn provide any information how to maintain this HOLDING CURRENT in MOSFET.

     

     

    Expecting to hear frm u soon.

     

    Thnx

    August 19, 2012 at 6:22 pm #8484
    AJISH ALFRED
    Participant

    Hi Varun,

    Power electronics a field in which I’ve little knowledge. Hence I dont think it would be appropriate to make any comment on the issue you are facing right now.

    Anyway try hard and learn more. All the best.

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

RSS feed: Recent Posts Recent Posts

  • PWM Dimming for 24V LED Strips: What Should I Consider? October 14, 2026
  • Portable charger for my mate's new leg October 14, 2026
  • Funny Images Thread! October 14, 2026
  • Semi-automatic battery handler October 14, 2026
  • Looking for help with wiring PJ Bass (Series/Parallel blend bypass) October 14, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly 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 Arrowfly
Privacy Policy | Advertising

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