Shop OBEX P1 Docs P2 Docs Learn Events
BS2 and shift registers — Parallax Forums

BS2 and shift registers

JomsJoms Posts: 279
edited 2008-02-29 16:01 in BASIC Stamp
I am working on a little more advanced project and having problems on where to start with the code.· Basically what I am trying to do is intercept signal that is going between two sets of shift registers (one an in and the other an out).· There are three signals that go between the shift registers, data, clock, and clear.· In this system there are three 8-bit input shift registers and three 8-bit output shift registers for a total of 24 bits of data.

What I am trying to accomplish is tie into the data, clock, and/or clear lines and store that information in a variable on the stamp.· I have found a document in the nuts and volts section about using shift registers on the input, but that is using the stamp to create the clock signal.· In this application I need the stamp to actually follow the clock signal but not produce it.

If you have any ideas on where I need to start with the code or can point me in the right direction to more information about this problem I would greatly appreciate it.· I am not going to give up on this project... Thanks in advance...

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-02-28 03:41
    You need a 'fifo' chip, with an FPGA or two to run the state machine.

    What you need to do is tie in to the clock and clear signals, so that the FPGA sends an 8-bit 'snapshot' into a 2K fifo from the parallel outputs of the shift register, every 8 bits.

    Once the data is in there, you can use 8 data pins of the BS2, and a 'read' signal, to read the data from the FIFO chip and send it via RS-232 wherever you need it to go.

    Otherwise, you're right -- the BS2 makes a lousy 'slave' SPI device.

    In any event, the BS2 is going to be a little speed limited for this application -- it'll only do 2000 Basic Instructions Per Second (up to 10,000 for some BS2 'flavors').
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2008-02-28 09:16
    Since the Propeller COGs operate independently, I suspect that you could have each of the 3 lines use and individual COG and be completely independent of the status of the other 2 lines. With 28 empty I/O pins available, there is more than enough room to handle the 6 shift registers involved. Add it is really a speed demon at 160mps. Of course you don't really need to use all 32 bits of each word, just the lower 8.

    I kind of think of using FPGAs as 'FPGA hell' If there is anything lower than programing in machine code, it is constructing a program from FPGA modules. It is interesting, but can be a whole new subject that is far beyond BasicStamps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PLEASE CONSIDER the following:

    Do you want a quickly operational black box solution or the knowledge included therein?······
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 2/28/2008 5:00:47 PM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-02-28 14:17
    VERY good point, Kramer. The Propeller would make a MUCH better SPI 'slave' device.
  • JomsJoms Posts: 279
    edited 2008-02-28 21:16
    Thanks for the help guys. OK, now I have a new idea still dealing with them. I found out that I really only need 13 pins. I really need to capture 12 input pins or bits, so I connected them to pins 0 thru 11. On pin 12 I hooked an "take" input which when that input goes low I want the stamp to record whatever is on the 12 input pins to a bit that is 12 charactors long. I have started programing this by making a 12 bit variable but running into problems on how to capture that data or if I have to do each bit individually....
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-02-29 16:01
    Typically you'd read all 16 bits at the same time with "MyWord = INS". Only the bits that are actually set as inputs will be correctly read -- any bits set as output you'll get the 'output latch' value.

    So then you have to 'mask' off the bits that are NOT in the 12 you wanted to read. Shift the result up or down, and there's your 12 bit value (in a 16 bit Word).
Sign In or Register to comment.