Zero crossing output with HWPM


Closed Thread
Results 1 to 5 of 5
  1. #1

    Question Zero crossing output with HWPM

    I will be using the HWPM command on my PIC18F8722 and I need to pulse an output on the zero crossing of the sine wave, and also at the max value of the sine wave to synchronize an external device to it. How do I do this?

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Need a little bit more detail

    Hi,

    As you mentioned you need a pulse does that mean you need to modulate your hardware PWM. If the criteria is limited to a pulse only then you may not need the Hardware PWM cause depending on the PWM frequency and duty cycle your PIC would be throwing a series of pulses while you start or stop your PWM.

    One approach could be :

    1. Measure the width (time period) of your input sinewave using a 16 bit timer
    2. Using the same timer in the next cycle (or consecutive cycle) to run upto half the value captured and fire an ouput (using the CCP module compare feature)
    3. Using the sine zero cross on an External INT to deal with the pulse output you need.
    Regards

    Sougata

  3. #3


    Did you find this post helpful? Yes | No

    Default Additional output with PWM

    The PWM will be normal but I want to fire separate digital outputs at zero crossing and max to sync up an external device.

    Is there a way to access the PWM registers directly, so I can fire these outputs based on their value?

  4. #4
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Yes of course

    Hi,

    In PBP all (almost) the registers of the PIC MCU are accessible. The 2 LSB of the PWM are in the CCPCON(CCP1CON/CCP2CON) bit 5,4. The MSBs are directly accessible using the CCPR1L and CCPR2L.
    Regards

    Sougata

  5. #5


    Did you find this post helpful? Yes | No

    Smile Thank you

    Exactly what I was looking for. Thank you

Similar Threads

  1. Bit Banging input to output on PIC16F876A
    By Bronurstomp in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th June 2008, 19:50
  2. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  3. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19
  4. HSEROUT Newbie question/problem
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 11th July 2006, 14:44
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

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