synchronize pic18f4550 pwm with external signal

Discussion in 'Embedded Systems and Microcontrollers' started by isolete_m, Jun 12, 2016.

  1. isolete_m

    Thread Starter New Member

    Jun 12, 2016

    I want to control the trigger angle of a triac connected to AC power (60Hz). My guess is that I can do it by changing the duty cycle of a 120Hz pwm generated by the PIC.

    I have a zero crossing detector circuit that generates a pulse on every semicycle start, but I can't figure how am I supposed to synchronize it with the pwm. Since I can't generate exactly 120Hz (closest I got was 122Hz), I have to reset (restart) the PWM period everytime I receive the zerocrossing pulse, but I don't really get how to do it.. Any help would be appreciated.

    I'm using PIC18f4550 with XC8 compiler on MPLAB IDE.

  2. John P

    AAC Fanatic!

    Oct 14, 2008
    I don't see why you need a PWM signal. I've had to do this, to operate a vibrating conveyor that ran off the power line, and I just set up a trigger that operated from a zero crossing (an optoisolator, as I recall) and then generated a time interval from that, to produce the "on" time for the power control element. No PWM needed, because each cycle was individually triggered and timed.
  3. dannyf

    Well-Known Member

    Sep 13, 2015
    Your guess would be completely wrong.