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: 000000002) 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: 000000003) The master reset RC de-asserts.
Current state of shift register: 000000004) 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: 100000005) The microcontroller waits for the RC input to the OR gate to de- assert.
Current state of shift register: 100000006) 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!