Generate a 120Khz signal using the pic16F877a


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    i've come out with manually pwm generator coding.this is my code:

    DEFINE OSC 8
    TRISC.2=0
    PWM_STATUS VAR PORTC.2

    MAIN:
    HIGH PWM_STATUS
    PAUSEUS 4
    LOW PWM_STATUS
    PAUSEUS 4
    GOTO MAIN

    END

    total time per cycle=4u+4u=8us...so...f=125khz...i hope this will work.i will tested it today...

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by texas5 View Post
    DEFINE OSC 8
    TRISC.2=0
    PWM_STATUS VAR PORTC.2
    MAIN:
    HIGH PWM_STATUS
    PAUSEUS 4
    LOW PWM_STATUS
    PAUSEUS 4
    GOTO MAIN
    END
    total time per cycle=4u+4u=8us...so...f=125khz...i hope this will work.i will tested it today...
    Except that it'll take at least one cycle to set the pin high (probably 2), one cycle to set the pin low (probably 2), 2 cycles to execute the GOTO MAIN...
    And if you'd read your PBP manual, you'd notice that pauseus has a minimum delay of 12us vs. the 4us you want.
    Therefore, you're code will probably output a 50% duty cycle square wave at about 66.6Khz...give or take...

    And do you want actual PWM or just a 120Khz pulse? 2 totally different things you know...
    Last edited by skimask; - 10th September 2008 at 23:33.

  3. #3
    Join Date
    Aug 2008
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    just 120khz pulse only one time use.actually,i want to inject the pulse when the zero-crossing interrupt occur to couple with the 50hz ac power line.the zero-crossing interrupt has be discuss before in this forum.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Looks like you're well on your way over here http://forum.microchip.com/tm.aspx?m=364475

  5. #5
    Join Date
    Aug 2008
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    oh no.my x-10 receiver circuit cannot detect 100khz-120khz pwm frequency.i've tested today and you know what, it need a 1Mhz pwm frequency.how can i generate it.oh nooo.

Similar Threads

  1. Measuring p-p of a 1.5v to 12v ac signal?
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th October 2009, 16:22
  2. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 18:51
  3. PIC16F877A for application in mobile robot...
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th January 2009, 14:47
  4. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 14:19
  5. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36

Members who have read this thread : 0

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