PWM, a few questions (PIC)

Discussion in 'Embedded Systems and Microcontrollers' started by KansaiRobot, Jul 7, 2015.

  1. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    Hello and thanks always.

    Some time ago, I finished and you helped me finishing a project dealing with PWM.

    Now I would like to ask something related to this.

    We all know the theory of PWM, that through changing the duty cycle we can provide something akin a analog value through only digital outputs. For example I changed the brightness of a LED by connecting it to a digital pin outputing PWM and controlling its duty cycle. So far so good

    But what happens if I change the other parameter: the period of the PWM signal??? What effect will it have on the load??

    ----------------------------------

    (I ask this because I was using the internal oscillator with Fosc = 1MHz . But now I am going to use a crystal and through several postscalers the Fosc=48MHz.

    Now, PWM Period= [(PR2+1)].4.Tosc.(Tmr2prescale) so PWM is gonna change too...
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    As long as it is still "fast enough" there is no change.

    As illustration, you PWM a LED to change the brightness, but if you go too slow you loose the illusion of constantly on and just get a blinkie light.
     
    KansaiRobot likes this.
  3. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    What if I get "too fast"?

    (I am going from 1MHz to 16 or 48MHz).
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    To answer you will first have to reveal the secret element you are controlling.
     
  5. AllVol

    AAC Fanatic!

    Nov 22, 2005
    55
    2
    Don't mean to sound flippant or impertinent, Kansi, but try it and see for yourself. Answering "what if" questions by trial and error is a good way to learn, especially with low voltage and micro projects.
     
  6. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    Well yes I will but I dont want to burn or explote anything....
    Take into account I am a software guy... this hardware world scares me :D (half joking)
    Anyway I found a way to reduce the frequency by software and I am going to try it and see thanks
     
  7. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    Oh it is no secret:cool:
    it is all written in the following thread
    http://forum.allaboutcircuits.com/threads/pwm-through-a-transistor.110529/

    Basically it is a strip of LEDs that needs 12V, therefore needing a transistor instead of just connecting it directly to the pin with the PWM.
     
  8. Ancel UnfetteredOne

    Member

    Jul 3, 2015
    36
    14
    If you have the same DC % with a shorter period for LEDs, you shouldn't encounter a problem. Nothing will burn or fail.
     
  9. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    Well I ve tried it and it seems everything is ok. Obviously watching it with an oscilloscope the period is decreased from 1024μs to 21μs but the LED strip seems to work so far...
    This increase in frequency won't increase the temperature in the PIC or the transistor, will it??

    Thanks for all the help
     
  10. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    762
    For sure it will increase power consumption (micro) but, vis-a-vis the LEDs' seems irrelevant.
     
Loading...