1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Single pin to control a shift register

Discussion in 'Embedded' started by Tomás Ó hÉilidhe, Mar 3, 2008.

  1. (I already posted this but it didn't show up after half an hour so I
    posted it again. If there's a duplicate thread, then please ignore
    THIS one and put all replies in the other thread.)

    I'm just a novice really in embedded systems, and I'm doing a college
    project. I've already gotten my board made and already stuffed it with
    components, so the time for backtracking the design has been and gone.
    My design might not be brilliant, but I hope it will work in the end.
    Here goes...

    I have an 8-Bit shift register chip, and at any time there will only
    be one HIGH on it. For instance:

    1000000
    0100000
    0010000
    0001000
    0000100
    0000010
    0000001

    Each shift-register pin will go to a single LED, and the HIGH will be
    used to power one LED at a time. The shift register will be clocked so
    fast that I'll have 8 LED's that will look like they're all on at the
    same time.

    Now I could have done this fairly easily using TWO pins from my
    microcontroller. The first pin would go to the actual shift register
    input, and the second pin would go to the clock input on the shift
    register. (An RC circuit would be put on the shift register's master
    reset to make sure that we start off with all zeroes). When the
    micrcontroller boots up, I would put a HIGH onto the input, clock it,
    then set the input low, then clock it a further six times, then set
    the input high again, clock it, set the input low, then clock it a
    further six times, ad infinitum.

    Being an ambitious, excited student tho and not really knowing better,
    I decided to achieve my goal using only one pin from the shift
    register. Here's how I designed it:

    On the input to the shift register, I put an OR gate. One input to the
    OR gate goes to an RC, and the other input to the OR gate is tied back
    to the last pin on the shift register. The idea is that I use the RC
    to provide a 1 to shift onto the shift register at the very beginning,
    and then just clock the shift register in an eternal loop, where the
    shift register's final 1 falls off the end, goes thru the OR gate and
    back onto the first pin of the shift register. Being more specific:

    1) Power is applied to the circuit

    Current state of shift register: 00000000

    2) While the RC circuit on the shift register's master reset hasn't de-
    asserted yet, the microcontroller powers up and sets all its pins in a
    known state.

    Current state of shift register: 00000000

    3) The master reset RC de-asserts.

    Current state of shift register: 00000000

    4) Before the RC that goes into the OR gate de-asserts, the
    micrcontroller clocks the 1 onto the shift register.

    Current state of shift register: 10000000

    5) The microcontroller waits for the RC input to the OR gate to de-
    assert.

    Current state of shift register: 10000000

    6) Now the microcontroller can clock the shift register as much as it
    wants, and the 1 will be moved around in an eternal loop. (Remember,
    the 8th pin on the shift register is tied back to the OR gate, meaning
    that the 1 will come back around to the beginning.)

    Firstly, I was warned that I shouldn't rely on the 1 being shifted
    around ad infinitum because a bit of static electricity could ruin
    everything, but of course being over-enthusiastic with my design, I
    ignored the advice. Thankfully I haven't come across any problems on
    this front yet tho, so fingers crossed.

    The problem I'm having is to do with the RC circuits. I need two RC's:
    One on the input to the shift register's master reset, and another on
    the input to the OR gate which goes into the shift-register's input.
    My idea for the timeline is something like as follows:

    1) Power is applied to the circuit.
    2) 20 milliseconds later, my microcontroller comes to life and
    executes its first instruction. The first intructions I give it are to
    set all the pins in a known state. The reason I do this is that I want
    the shift register clock to be low before the shift register master
    reset is de-asserted, because if it's high or if it's high impedence
    then I think I might get undefined behaviour (e.g. the SR might think
    there's a rising edge when really there isn't and it might actually
    start shifting).
    3) The SR's master reset de-asserts, so that I can actually control
    the SR.
    4) The microcontroller clocks the 1 onto the SR.
    5) The microcontroller waits for the SR input to go low.
    5) Now the microcontroller can clock the SR to its heart's content,
    flashing the LED's in an eternal loop.

    Now the current obstacle I need to get by is how to choose the values
    for the RC's. I wanted the master reset on the shift register to stay
    low for about 200 ms, and then go high (the master reset is active-
    low). At the moment in my circuit, I have for this: R = 22 kilo-ohms,
    C = 20 microfarrads. The product of these two yields a time constant
    of 220 milliseconds. Now, I understand that you don't get a "brick
    wall" effect with an RC, but I'd like to know how I should go about
    picking values. Let's say that I definitely want the RC to be asserted
    at 200 milliseconds, and that I want it to be deasserted before 800
    milliseconds, well what time constant would I want? And hence what
    component values? Do I want a time constant of 200 ms, or perhaps do I
    want a multiple of that?

    For the input to the OR gate, I want it to still be asserted at 1 s,
    but I want it to be de-asserted by 2 s. Again, how do I go about
    choosing values for the RC?

    Just another thing. The microcontroller I'm using is the PIC16F684.
    I've heard that it takes 20 ms to "boot up" but I haven't gotten any
    concrete evidence. Does anyone know exactly how long it takes? Also,
    how much space should I give myself to allow the PIC to boot up and to
    have all of its pins in a known state, I went with 200 ms to give
    myself plenty of room. Is this enough time, do you think?

    Again, as I said, the die is cast so there's not much point telling me
    what I should or shouldn't have done... what I'm trying to do is get
    the current design working. And I *do* think I can get it working.

    Thanks for reading!
     
    Tomás Ó hÉilidhe, Mar 3, 2008
    #1
    1. Advertisements

  2. Tomás Ó hÉilidhe

    CBFalconer Guest

    Usenet posts can take their time. One principle is: Never assume
    anyone has (or will) receive all posts, so make each message stand
    by itself. That's why there are quoting facilities.
    First point - look at the drive current available from the chip.
    Usually much more is available in the low state than the high. So
    you should reverse your logic (or use an inverter to drive the
    LED), i.e.

    01111111
    ...
    11111110
    Very iffy. You don't know the relationship between the RC circuit,
    the oscillator, and the gate thresholds. So avoid it all. In
    part, this depends on the available input signals to the SR. The
    idea is to get it into all 1's, and then feed in a single zero. If
    you use an inverter on the output pin you can use all 0's and feed
    in a single one. If you use a register within the microcontroller,
    you can set up just what you need. Then the 'shift code' can be:

    if (rh_bit == 0) next_state = 01111111b;
    else next_state = (old_state / 2) | 10000000b;

    which you perform on one clock edge. On the other clock edge you
    perform

    old_state = next_state;

    Good luck.
     
    CBFalconer, Mar 4, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.