Long shift register


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    well, I guess that you can only have bit arrays up to 256 elements, but I was thinking something like this..

    Code:
    bigarray 	var	  bit[256] 'Large array to hold data
    newdata	var	  bit   'newest bit to be shifted in
    index		var	  byte
    
    
    for 0 to 255
        bigarray[index] = bigarray[index +1] 
        next index
        
    bigarray[255] = newdata  'put the newest data bit into the array
    Maybe with 4 big arrays you could shift through 1024 steps?
    Or have I missed the point entirely...

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    18F parts let you have arrays as large as memory.
    Charles Linquist

  3. #3
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Byte_Butcher View Post
    well, I guess that you can only have bit arrays up to 256 elements, but I was thinking something like this..

    Code:
    bigarray 	var	  bit[256] 'Large array to hold data
    newdata	var	  bit   'newest bit to be shifted in
    index		var	  byte
    
    
    for 0 to 255
        bigarray[index] = bigarray[index +1] 
        next index
        
    bigarray[255] = newdata  'put the newest data bit into the array
    Maybe with 4 big arrays you could shift through 1024 steps?
    Or have I missed the point entirely...
    Byte_Butcher,

    I hadn't thought about a bit array. My thinking was stuck on word arrays, ">>" functions, and being able to get the bit that falls out the end of one word and automatically put it into the input of the next word in the array. In assembler. this is almost trivial.

    Your idea seems very doable, except that every bit has to be handled individually. I'm concerned about time, since I want to shift all 1000 bits in 100usec or less. Actually, I'd like to do 2000 bits in that time if I could.

    Joe

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe Rocci View Post
    Byte_Butcher,

    I hadn't thought about a bit array. My thinking was stuck on word arrays, ">>" functions, and being able to get the bit that falls out the end of one word and automatically put it into the input of the next word in the array. In assembler. this is almost trivial.

    Your idea seems very doable, except that every bit has to be handled individually. I'm concerned about time, since I want to shift all 1000 bits in 100usec or less. Actually, I'd like to do 2000 bits in that time if I could.

    Joe
    Perhaps if you gave a few more clearer details other than you want to make a 1000 byte long virtual bit array. Some explanation about how many of the bits you need to read, how often, if you need to skip any chunks (as in filtering and the application of maths series) It seems that you might not be clear enough answers because yoiur application isn't obvious.

    If you can do it in assembler you should, regardless of what esoteric reason you might have for not wanting to do it, life is too short sometimes !

  5. #5
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Chris Barron View Post
    Perhaps if you gave a few more clearer details other than you want to make a 1000 byte long virtual bit array. Some explanation about how many of the bits you need to read, how often, if you need to skip any chunks (as in filtering and the application of maths series) It seems that you might not be clear enough answers because yoiur application isn't obvious.
    -----------------

    Actually Chris......

    I really don't know what else I can proactively offer in the way of explanation, but if you'd like to help out, feel free to ask questions.

    If you re-read the thread, I think you'll find pretty clear explanations of what I'm trying to do:
    1) I need a 1000 tap shift register for a DSP-like application
    2) I need to be able to read the state of any or all bits
    3) I want to clock things into it at about a 10 khz rate
    4) I'm looking for one of the PBP experts in the group to tell me whether the "<<" shift operation results in setting any system variables that can be clocked into the next word in an array.

    BTW, I really got a kick out of this part:

    "If you can do it in assembler you should, regardless of what esoteric reason you might have for not wanting to do it, life is too short sometimes !" Sort reminds me of the old sales cliche that says "If you can find it cheaper somewhere else, buy it!" Oh yeah...uhhh, sure. Thanks

    Joe

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Pretty much anything you can do in assembler you can do with PBP, but a little more
    information of what you're trying to do really would help.

    I.E. are you loading a word var with a 16-bit value, then trying to shift this up x number of
    bits into your array, or are you 'clocking' bits into an I/O-pin, and trying to stash these into
    your array?

    I see a boat load of options for something like this, but I'm not getting a very clear picture
    of exactly what you need on this one.

    If you post the simple assembler example you have working, I'll bet we can come up with a
    simple PBP BASIC equivalent.

    I can't say if a PBP example can beat your assembler example without seeing your .asm
    version as for timing, but I suspect it would be easier to read...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Bruce,

    Here's a 'brute force' implementation of a long shift register in assembler for a 16F628A:

    ; Move shift register contents left one
    ;
    bcf STATUS,C ; Clear Carry bit to prevent any carry in
    rlf SR8,f ;
    rlf SR16,f ;
    rlf SR24,f ;
    rlf SR32,f ;
    rlf SR40,f ;
    rlf SR48,f ;
    rlf SR56,f ;
    rlf SR64,f ;
    rlf SR72,f ;
    rlf SR80,f ;
    rlf SR88,f
    rlf SR96,f
    rlf SR104,f
    rlf SR112,f
    rlf SR120,f
    rlf SR128,f
    rlf SR136,f
    rlf SR144,f
    rlf SR152,f
    rlf SR160,f
    rlf SR168,f
    rlf SR176,f
    rlf SR184,f
    rlf SR192,f
    rlf SR200,f
    rlf SR208,f
    rlf SR216,f
    rlf SR224,f
    rlf SR232,f
    rlf SR240,f
    rlf SR248,f
    rlf SR256,f
    rlf SR264,f
    rlf SR272,f
    rlf SR280,f
    rlf SR288,f
    rlf SR296,f
    rlf SR304,f
    rlf SR312,f
    rlf SR320,f
    rlf SR328,f
    rlf SR336,f
    rlf SR344,f
    rlf SR352,f
    rlf SR360,f
    rlf SR368,f
    rlf SR376,f
    rlf SR384,f
    rlf SR392,f
    rlf SR400,f
    rlf SR408,f
    rlf SR416,f
    rlf SR424,f
    rlf SR432,f
    rlf SR440,f
    rlf SR448,f
    rlf SR456,f
    rlf SR464,f
    rlf SR472,f
    rlf SR480,f ;
    rlf SR488,f ;
    rlf SR496,f ;
    rlf SR504,f ;

    Bank1 ; 65 Switch to next set of registers in Bank1

    ; btfsc STATUS,C
    ; bsf SR512,0
    rlf SR512,f ; 66
    rlf SR520,f
    rlf SR528,f
    rlf SR536,f
    rlf SR544,f
    rlf SR552,f
    rlf SR560,f
    rlf SR568,f
    rlf SR576,f
    rlf SR584,f
    rlf SR592,f
    rlf SR600,f
    rlf SR608,f
    rlf SR616,f
    rlf SR624,f
    rlf SR632,f
    rlf SR640,f
    rlf SR648,f
    rlf SR656,f
    rlf SR664,f
    rlf SR672,f
    rlf SR680,f
    rlf SR688,f
    rlf SR696,f
    rlf SR704,f
    rlf SR712,f
    rlf SR720,f
    rlf SR728,f
    rlf SR736,f
    rlf SR744,f
    rlf SR752,f
    rlf SR760,f
    rlf SR768,f
    rlf SR776,f
    rlf SR784,f
    rlf SR792,f
    rlf SR800,f
    rlf SR808,f
    rlf SR816,f
    rlf SR824,f
    rlf SR832,f
    rlf SR840,f
    rlf SR848,f
    rlf SR856,f
    rlf SR864,f
    rlf SR872,f
    rlf SR880,f
    rlf SR888,f
    rlf SR896,f
    rlf SR904,f
    rlf SR912,f
    rlf SR920,f
    rlf SR928,f
    rlf SR936,f
    rlf SR944,f
    rlf SR952,f
    rlf SR960,f
    rlf SR968,f
    rlf SR976,f
    rlf SR984,f ;
    rlf SR992,f ;
    rlf SR1000,f ;127
    Bank0 ;9 Back to Bank 0
    return ; Back to calling routine


    Thanks
    Joe

  8. #8
    Join Date
    Aug 2006
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    ....I should have explained that the routine is entered with the current input bit in SR8, bit 0.
    Joe

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 18:51
  3. Replacing shift register with PIC
    By TonyA in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 7th April 2008, 18:31
  4. Shift Register Woes, specifically the STP16DP05
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th November 2007, 23:22
  5. Replies: 15
    Last Post: - 30th January 2005, 03:58

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