Synchronous pulses


Results 1 to 17 of 17

Threaded View

  1. #9
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    Hi Andrew,

    The disadvantage of this particular method is that you need a PIC with lots of RAM, something like an 18F2620, for the 1024 byte toggle array. If this is a one-off project then perhaps that may not be a big deal.

    The PrepArray() routine builds the following (abbreviated) toggle[] array from the pulse[] array values and the Output() routine uses those values to update LATB as shown below;

    Code:
     interval                                ^ LATB
    0000-usecs  toggle[   0] = 0b00001111  0b00001111  RB3..RB0 toggled on
    0001-usecs  toggle[   1] = 0b00000000  0b00001111
    ....
    0043-usecs  toggle[  43] = 0b00000000  0b00001111
    0044-usecs  toggle[  44] = 0b00000010  0b00001101  RB1 toggled off
    0045-usecs  toggle[  45] = 0b00000100  0b00001001  RB2 toggled off
    0046-usecs  toggle[  46] = 0b00000000  0b00001001
    ....
    0119-usecs  toggle[ 119] = 0b00000000  0b00001001
    0120-usecs  toggle[ 120] = 0b00000001  0b00001000  RB0 toggled off
    0121-usecs  toggle[ 121] = 0b00000000  0b00001000
    ....
    1000-usecs  toggle[1000] = 0b00000000  0b00001000
    1001-usecs  toggle[1001] = 0b00001000  0b00000000  RB3 toggled off
    ....


    The advantage of using a "toggle" data array and XOR'ing the values with LATB over using an "output" data array and simply writing the values to LATB is that the "toggle" array only requires inserting eight "toggle" bits into the array. An "output" data array would require inserting many many "output" bits into the array.

    The Do-While loop in the Output() routine compiles to the following 5-cycle instruction sequence (by the BoostC compiler) for perfect 1-usec intervals (with a 20-MHz clock);

    Code:
    loop:
            movf    _postinc0,W     ;
            xorwf   _latb,F         ;
            btfss   _fsr0h,3        ;
            bra     loop            ;
    In your program you would edit the pulse array values for the outputs and then call the PrepArray() routine to build the toggle array. Then I suspect you would wait for some "trigger" event before calling the Output() routine.

    Any of this make sense Sir? I'm rather pressed for time and that tends to make my rushed explanations rather useless to most people. Sorry...

    Regards, Mike
    Attached Images Attached Images  
    Last edited by Mike, K8LH; - 17th October 2009 at 01:04.

Similar Threads

  1. I Need Help.. I want to generate controlled pulses
    By alabbadi in forum PBP Wish List
    Replies: 7
    Last Post: - 18th November 2007, 10:42
  2. Count pulses between VARIABLE TIME
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 12:44
  3. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  4. Timed pulses on 2 pins
    By Danie Joubert in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th March 2004, 07:38
  5. Counting pulses
    By srspinho in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 19th November 2003, 00:54

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