Connect with us

Confused about circuit and shift register

Discussion in 'General Electronics Discussion' started by woodworker82, Dec 21, 2011.

Scroll to continue with content
  1. woodworker82

    woodworker82

    4
    0
    Dec 21, 2011
    Hello,

    I'm working on a project and hoping to expand my basic understanding of electronics. I've written a program that interfaces with the printer port. I can send a byte to the data lines, and change some of the control registers around. I used a breadboard with some led's to verify and test the logic.

    My next step was to hook this up to an 8 bit shift register (SN74HC164N), and drive some led's. Understand that the shift registers cannot drive a lot of current, so I hooked the 8 led's up in parallel and tied them to ground with a 1k ohm resistor. I wired up the clock and clear pins to the strobe and init lines of the parallel port. Lastly I combined the A & B inputs on the shift register with the D0 data line.

    I wrote a small program that would set the clear pin high, while sending data to D0 and cycling the clock on and off. Unfortunately the results were not as expected.

    the output led's from the shift register all cycle on and off. I was expecting them to cascade as data was shifted down to each paralell output. I'm a bit stumpted at the moment. It's basically flip flopping all 8 led's.

    The data I'm sending through is a series of 1's and 0's. Sometimes I'll pass just 0 through and it still cycles. I'm not sure if the shift register is bad or if I wired the circuit wrong. I tried from scratch twice and still got the same results.

    Lastly I tried skipping the parallel port altogether and tested the shift registers with three momentary pushbuttons simulating data, clock and clear. This got really interesting because the led's would seem to light up any time my fingers got near the shift register or the data / clock jumpers. It seemed to be picking up static electricity or capacitance from my hands? I found that annoying. When I tried to manually use the shift register the LED's would blink in an irregular sequence.. differently from the computer driving it, but not in an expected manner.

    Any suggestions on how to troubleshoot would be appreciated. The circuit is pretty simple but I can attach a diagram if needed. Ultimately I'm not looking to drive LED's but I wanted to test with them.
     
  2. jackorocko

    jackorocko

    1,284
    1
    Apr 4, 2010
    This makes it sound like you hooked them all up to one output of the shift register, this is wrong I believe. Do you have a schematic of how you wired it? Or even a picture clearly of the breadboard?
     
  3. bonedoc

    bonedoc

    122
    0
    Dec 21, 2011
    I sounds like you hooked up something wrong. When this happens and the pin floats around, your bodies capacitance will cause changes in the registers.

    I would attach a picture.

    Also, one thing I was confused about when I first used them is that the clock and storage pins are "recorded" when they TRANSITION. So, you should clear the clock, set/clear data, then set the clock. Repeat as long as you want. To display, set and clear the storage pin. The code below would illuminate every other led on the register. Hope this helps. Ian

    Code:
    bcf		Clock				;clear clock to set up
    
    	bcf		DataPin				;0
    	bsf		Clock
    	bcf		Clock
    
    	bsf		DataPin				;1
    	bsf		Clock
    	bcf		Clock
    
    	bcf		DataPin				;0
    	bsf		Clock
    	bcf		Clock
    
    	bsf		DataPin				;1
    	bsf		Clock
    	bcf		Clock
    
    	bcf		DataPin				;0
    	bsf		Clock
    	bcf		Clock
    
    	bsf		DataPin				;1
    	bsf		Clock
    	bcf		Clock
    
    	bcf		DataPin				;0
    	bsf		Clock
    	bcf		Clock
    
    	bsf		DataPin				;1
    	bsf		Clock
    	bcf		Clock
    	
    	bsf		StoragePin			;set
    	bcf		StoragePin			;display
     
  4. woodworker82

    woodworker82

    4
    0
    Dec 21, 2011
    Sure, here's a schematic showing what the design looks like. VCC and ground on the SN74HC164N are wired to an external 5v power supply.

    [​IMG]


    I tried changing the D0 and D0 (data LED) lines around a bit. First I got rid of the LED, then I tried tying A high and wiring D0 directly to B, but none of these changes seemed to affect the behavior of the circuit.

    Here's a bit of pseudo code that explains what the program is doing

    Code:
    SET INIT LO // hardware inverted line positive when low
    SET D0 HI  // D0 data line
    SET STROBE HI
    WAIT 100 // (in milliseconds)
    SET STROBE LO
    SET D0 LO
    WAIT 100 // (in milliseconds)
    SET STROBE HI
    WAIT 100 // (in milliseconds)
    SET STROBE LO
    
    Running this code both the D0 led blinks once (when set hi) and the 8 output LED's blink twice in unison.

    I'll post an image of the breadboard as soon as my phone is charged.
     
    Last edited: Dec 21, 2011
  5. bonedoc

    bonedoc

    122
    0
    Dec 21, 2011
    Let me look at the datasheet. I usually use the 595 shift register. Three things to consider though:

    -If I recall, there are a couple pins that must be held high while using the register. There may even be 2 pins that are to be held low. Let me look.

    -Also..I think you need to convert your signal levels. Maybe this register you are using is made for serial data. But, computer serial data has different logic levels than many of these chips. If you do not know about this, look at the maxim 232.

    -I think, from what you posted, that you are possibly clocking in the signal and then not setting the output latch?
     
  6. bonedoc

    bonedoc

    122
    0
    Dec 21, 2011
    Hmm...this chip is a lot different than what I used. I dont think there is a storage pin. Sorry about that.

    However, it does look like you are supposed to hold the MR pin high for it to work. I would try that.

    Also, I wonder about the logic levels.
     
  7. woodworker82

    woodworker82

    4
    0
    Dec 21, 2011
    No problem, yeah this isn't a latching shift register. The MR pin is held hi when the INIT pin is set to low (inverted). I tested yesterday with the MR (clear) pin set low and it wouldn't do anything.

    As for the logic levels, I checked the spec sheet and it seems to allow for up to 6 volts, but I could be interpreting it incorrectly.


    Here's a schematic that I'm trying to replicate. The 595 you mentioned does look more robust, but I'm not sure if I can easily daisy chain 595 shift registers?

    www.jilsoft.com/jp3.pdf

    The schematic is for a 2865 EEPROM programmer.
     
  8. bonedoc

    bonedoc

    122
    0
    Dec 21, 2011
    The 74hc595 has always been very good to me. But, I am sure there is a reason they used the register you have, I just dont know the reason.

    The 595 is easy to use, and it has some nice feature....like reset and storage features. You can daisy chain them together. Its easy.

    I dont think you will need a converter. Here is why I mentioned it:

    http://www.allaboutcircuits.com/vol_4/chpt_3/10.html

    You would probably know if there was a problem, because you would be getting all 0s or all 1s. I should have told you, I used the serial port of my computer and talked directly to the USART of a chip. The chip did its thing, and then used 3 lines to communicated to the chained shift registers. So, I needed the maxim chips to convert the computers levels to the USART levels.

    I was using 6 chained together.

    I transmitted serial data by writing a windows program. It was to design and transmit images to a LED matrix.
     
  9. TedA

    TedA

    156
    16
    Sep 26, 2011
    Some quick thoughts about this project:

    The parallel printer port ( "Centronics"), uses TTL logic levels. Newer ones may put out 5V CMOS logic levels, which still work well with the older TTL parts. There is nothing RS232 about this port. Woodworker82 is creating a serial bit stream in software and applying it to one bit of the parallel data at the printer port. The computer port signals are already what he needs for the 74164. No logic level conversion required.

    There is a slight chance that older parallel port hardware might work better driving an HC part, if some pull-up resistors are added to +5V. 4.7k might work well. If you can look at the signals with a scope, you can see if you have logic levels that match the needs of the chip you are driving.

    You might want to use a shift register with an output latch, so first a new pattern can be shifted in, then all the outputs changed at once. I think the 74HC595 already suggested does this.

    An ordinary red LED connected from a TTL logic line to ground will prevent the line going high enough for a good logic 1. The LED? on the D0 line may cause trouble. Two in series might be OK, though.

    The 74164 shown on the schematic is a TTL part. The outputs sink far more current than they source. So your LEDs need to be turned the other way round, with the cathodes toward the chip. A 74HC164 has symmetrical output drive, but lower than the TTL part's sink current. We see 5.2 mA output currents on the data sheet for the HC part.

    Unless only one LED is to be on at once, each will need its own resistor. About 560 or 680 ohm value would light up your LEDs a little better.

    The schematic does not show a connection between the computer ground and the 74164 circuit ground.

    The IBM PC style printer port has fairly confusing control line logic. Some signals are inverted by the hardware, some are not. I don't have time now to find a reference document for this; there must be one online somewhere. Be sure you are feeding the intended polarity signal to the CLK and CLR pins.

    Another consideration is what happens when the computer is powered-up, and what happens when Windows boots. Some of the control lines go up and down during these activities. You may need to add hardware to prevent bad things happening. You will need to observe what your particular system does as it starts.

    And out of curiosity, what computer hardware and software are you using? All this was easier back in the DOS era.

    Good luck getting this working.

    Ted
     
  10. woodworker82

    woodworker82

    4
    0
    Dec 21, 2011
    Thanks for the responses.

    I rewired the manual switch inputs for the shift register circuit. The last time I had left the clock disconnected when unswitched instead of low as it should have been. After fixing this mistake I was able to confirm the line level logic works fine (the power supply is 5 volts). The random capacitance noise does not occur if the reset and clock lines are properly switched/tied high or low.

    I read Ted's repsonse and noticed that I indeed had not tied the ground on the parallel cable to the power supply. Once I did this the shift register was functioning properly from the printer port.

    Yes there are some Hardware inverted lines on the parallel port and I'm taking account for those.

    I don't have an O-scope, but I was using a simple voltmeter to try to verify matching logic levels.

    The 595 looks interesting, but I think for this project I'd have to access another hardware line to latch the output. If I run into any more trouble with the 164 I'll probably switch, but for now I'm able to write the 21 bits (serially) and see them on the io lines. The next step is to wire up the 2865A EEProm for programming.

    Thanks again!
     
  11. TedA

    TedA

    156
    16
    Sep 26, 2011
    Woodworker82,

    Glad you are making progress.

    It's hard to work without a 'scope. If you are going to do much of this, try to find one you can beg or borrow. Or a PC based module might be a good bet for you. ( If you have a second PC to use!)

    Remember, with the '194 shift register, all of those bits go shifting-by on the outputs as you shift in the data. This may be OK in your application, or very not.

    If you decide to look into different devices, there are 28 - 40 pin serial-in parallel-out chips with more bits in one package. Some of these are marketed as LED segment drivers, but can drive CMOS logic OK.

    I'm still very curious to hear what hardware & software you are using to access the parallel port. This has become a real problem, as Windows attempts to build a wall between the user and the hardware.

    Ted
     
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.
Electronics Point Logo
Continue to site
Quote of the day

-