PWM with a PIC


Closed Thread
Results 1 to 5 of 5

Thread: PWM with a PIC

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default PWM with a PIC

    Hi. I know PICs have some kind of built in PWM thing for a few pins but im trying to to PWM without using that (so it works on all pins). I have been told that i need a loop to turn an output pin on and off rapidly but aparently, if im dealing with mains circuits (eg a dimmer switch) then i need to sync it with the mains sine wave.

    Do i actually need to sync it?
    If so how?

    Is this the worst possible way of doing it and should i try something else? lol

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yes you'll need to synch it or you're going to see some weid blinky stuff. What you need is a spare input who will sense the AC main. Then each Zero Crossing, you refresh your dimmer outputs.

    For safety reason, you want to use an optoisolator between the MAIN and your circuit. Anything like LTV-814,PS2505 will work.

    If you decide to use Your power supply transformer, you may need to calibrate it in software to compensate the phase difference between the primary and secondary.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    Normally PWM is used when you want to dim a DC load. In your case you are trying to dim an AC load, this is done very differently. In short AC dimming requires a zero cross sense, and an interrupt timer.

    For more detail on how AC dimming works check out this website:
    http://www.dv-fansler.com/Computer%20Lights/dimmers.htm

    NOTE: You can't dim inductive loads with this method, only resistive loads like light bulbs.

  4. #4
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Thanks. ill have to check that link when i get home because its blocked at work.

    Ive been thinking about some LED lighting projects too. How would i dim those? I would assume its more or less the same idea but LEDs dont glow for a while after the power goes off like bulbs so wouldnt they just flash rapidly?

    Is it really complicated to dim things like transformers? Ive seen lighting controllers do it before

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Dimming theory is almost always the same, the driver circuit may need to be changed.

    Do a search for snubber, Inductive load dimmer (dimming/driving), snubberless Triacs.

    For LEDs... don't worry, you don't need any synch. Just a high enough frequency will work.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  2. how can i stop the pic from sending a PWM???
    By texas5 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th October 2008, 17:12
  3. using all pins of pwm in pic 18f2431
    By jorgequesada in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th May 2007, 21:43
  4. pic 18Fxx31 PWM module
    By dirace in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th May 2005, 19:51
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts