pulsout question


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default pulsout question

    HI,

    I am using a 20mzh crystal. from the pbp manual, it is a 2us period, is it possible to configure the chip so I get 100 000 hz or even 200 000hz pulses ?
    1/2us = 500000hz I guess, I am using pulsout portb.4, 40 and I am getting only 7.5 khz

    loop:
    pulsout portb.4 ,10
    goto loop
    end



    ken

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I am using a 20mzh crystal. from the pbp manual, it is a 2us period, is it possible to configure the chip so I get 100 000 hz or even 200 000hz pulses ?
    1/2us = 500000hz I guess, I am using pulsout portb.4, 40 and I am getting only 7.5 khz
    ken
    40 cycles @ 2us per cycle = 80us. 1/80us = 12.5Khz
    But then you have to add the extra few cycles that pulsout uses to set the TRIS register for the pin and set and reset the logic level for that pin. AND you have to add in the 2 cycles it takes to GOTO the beginning of the loop. Not to mention any WDT clearing instructions and/or any PBP 'ON INTERRUPT' handling instructions stuffed in there. Those extra instructions are probably slowing the loop down to 7.5Khz.

    Add:
    DEFINE NO_CLEARWDT 1
    to the top of your program whether you are using the WDT or not (but turn it off in the CONFIGs just in case)
    Also, add a
    DISABLE
    to take care of any PBP 'ON INTERRUPT' handling around that tight loop.

    That should speed up the loop a bit.

    But, IMO, using pulsout is just a bad way to get a train of pulses @ 100Khz because, for one thing, the duty cycle won't be constant, especially if you're doing anything else in the program.

    You might want to try to use some of the 'Instant Interrupts' and TMR0 with a high reload value (don't know what that value would be off the top of my head, maybe 232 with 1:1 prescale), then each time the interrupt fires, toggle the state of the pin.

    http://www.mister-e.org/pages/utilitiespag.html

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default resonator

    Hi,

    I am still working on my lowpass filter, I obtained the max7480 chip low pass filter. So for a cut off frequency of 2khz, I need the chip to clock at 200khz. I thought that maybe I could make a pic chip clock that speed. I also got into problems of making the chip clock to 64khz, but when I add to the clock input of the chip, the clocking would decrease by 100 fold...
    In the chip specification, it says we can add capacitors to the clock input, but that did not work for me. I made the schematic exactly as they say on their datasheet, but I am not getting the result.

    k

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Since when does a 20MHz clock make a 2uS period?

    If you're running at 20MHz... then why not try...

    TRISB.4=0
    Loop:
    Toggle PortB.4
    PauseUS 4
    Goto Loop

    PauseUS doesn't go down to 4uS at 4MHz but it just might work at 20MHz... at 4MHz you could try...

    TRISB.4=0
    Loop:
    Toggle PortB.4
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    Goto Loop

    Since each @ NOP will eat 1uS.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    So for a cut off frequency of 2khz, I need the chip to clock at 200khz.
    So all you really need is just a solid 200Khz square wave signal?



    Quote Originally Posted by Melanie View Post
    Since when does a 20MHz clock make a 2uS period?
    Well I know that! But the PBP manual says the PULSOUT period is 2us when clocked at 20Mhz.

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    hey , just following the manual,

    I got myself the 4047 chip this afternoon, we'll see how that works...

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I got myself the 4047 chip this afternoon, we'll see how that works...
    Well, heck, a 555 could've done that for ya!

  8. #8
    Join Date
    May 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    so can i know how to send the pulse continously?...when i try using for loop, the motor just move a seconds....

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by shirleyz View Post
    so can i know how to send the pulse continously?...when i try using for loop, the motor just move a seconds....
    What pulse?
    What loop?
    What motor?
    What code?

Similar Threads

  1. Question on IO ports
    By studysession in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th February 2009, 18:10
  2. help pulsout command?
    By ajak in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 7th September 2008, 07:11
  3. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  4. does this work?
    By igor@24 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 13th June 2005, 19:19
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 03:46

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