Connect with us

Reading 74HC165 through parallel port? (schematic included)

Discussion in 'General Electronics' started by Bart T., Aug 3, 2004.

Scroll to continue with content
  1. Bart T.

    Bart T. Guest


    This problem is driving me nuts! I'm using a 74HC165 shift register
    and am simply unable to properly read the data using the parallel
    port. Writing data to it works smoothly but receiving the output isn't
    working and I believe it's something to do with the electrical
    characteristics of the parallel port status lines.

    My schematic is at:

    Here's the problem: When the connection between PAPER_OUT (the status
    pin I'm using to receive input) is broken, the circuit seems to work
    fine. The first 4 bits that are read back are the same as were

    However, if the connection is made, after the first 1 appears on the
    output pin, it seems to "stick" for the remaining output cycles
    (though sometimes it goes low for a cycle.) What could be wrong? I've
    tried a lot of things with no luck at all.

    Some examples:

    Wrote 0x5, read 0x7
    Wrote 0xA, read 0xF
    Wrote 0xC, read 0xD
    Wrote 0x8, read 0x9
    Wrote 0x4, read 0x3 (?!)

    Things I've tried to troubleshoot this:

    1. I tried breaking the connection when I knew the output should be 0
    (to see if the parallel port was driving it high somehow) but it
    remained at 1! I'm using a multimeter to test this. The voltage on the
    parallel port PAPER_OUT pin (when disconnected and left floating) is
    always 0, I've never seen it change. Even if I don't actually perform
    the read operation in my C code, the problem persists!

    2. I disconnected the 165's output from the parallel port and then,
    when the output was 0, I made a connection to +Vcc (+6V in my set up.)
    The voltage went high but as soon as I removed this new connection, it
    returned to its actual state as it should. This doesn't happen when
    connected to the parallel port.

    3. I've tried writing both 1 and 0 to the status port (in software)
    before sampling the input. It didn't have an effect.

    4. I've confirmed that the chip is not bad.

    In summary:

    The circuit does not work if Q7 of the 74HC165 is connected to any
    input pin on the parallel port. Removing this connection will not fix
    the problem until the 165 has new data written to it.

    Has anyone successfully used the parallel port to read back data from
    a circuit? I've seen one design that used transistors but I'm afraid I
    don't understand why they were necessary. I've seen some designs that
    don't do anything special and they work fine. I really think my design
    should be fine.
  2. Hello

    You need to use 5V as vcc because the parallel port is a 5V circuit.

  3. Hello

    You have to make sure that the parallel port is set to SPP mode in the

    What operating system are you using?

  4. At a first glance I see no flaw in your schematic, so I believe it is either
    the hardware of the printerport or the OS you're using that sets you up.
    Have a look at
    There's everthing you need to know about setting and programming the
    parallel printer port.

    petrus bitbyter
  5. Zorknob

    Zorknob Guest

    Is the ground of your circuit tied to the parallel port ground? They
    must be tied together for this to work.

    Change your VCC supply to +5V. Although the HC165 can handle +6V, it
    is at the high end of the spec. In addition, with a 6V VCC, the
    logic output high level is too high for TTL inputs.
  6. Bart T.

    Bart T. Guest

    It is set to SPP mode already (where the data register is used for
    output only and the status register is for the input.) I'm using an
    old Windows 95 machine.

    The actual voltage supplied by my 4 AAA battery setup is ~5.6V. This
    is still within the valid range of TTL so it should work, shouldn't
    it? The logic IC datasheets I've seen for various TTL 74 series chips
    show that 6V is acceptable.

    The circuit is grounded to the battery's negative terminal (the
    parallel port ground pins are grounded there too, otherwise the
    circuit won't work of course.)
  7. Bart T.

    Bart T. Guest

    Is the ground of your circuit tied to the parallel port ground? They
    Yes. The ground rail on my breadboard is connected to the parallel
    port ground as well as the negative terminal of my power supply (AAA
    ~5.6V is actually supplied -- is this really too high? The port seems
    to be able to read individual 1's and 0's this way (I poked around
    with other parts of the circuit.) If it was just a matter of it being
    too high, I would imagine that it would simply cause problems on the
    parallel port side. But as it is, the 74HC165's internal state seems
    to be corrupted (because removing the connection while shifting out
    bits does not ensure that the succeeding bits are correct.) How can
    out-of-range voltages cause this bizarre effect?

    I can try breaking down the voltage to 5V using resistors but that'll
    have to wait until tomorrow evening when I can get the supplies.

    Are there any other possible causes?

    One thing that came across my mind was that if a 1 appeared on the
    output pin, some interference would somehow cause the clock signal to
    pulse (even though they're physically not very close.) If you look at
    my schematic, I'm only writing the high nibble whereas the low nibble
    is always 0xF. An extra clock tick would cause 1's to be shifted in,
    hence 0x5 turns into 0x7 and 0xA to 0xF but it doesn't explain 0x4
    turning to 0x3 or 0xC to 0xD. I guess the only thing I can think of
    now is that the internal state of the 165 is somehow being corrupted
    by the interaction of the Q7 output pin going high and the parallel
    port (note that the parallel port itself is not forcing the line low
    or high, I've tried test that.)
  8. Yes. The ground rail on my breadboard is connected to the parallel
    Have you got adequate bypass caps on the chip? I have had somewhat
    similar problems with 'HC373s, which were caused by poor PCB layout.
    (I didn't believe this could POSSIBLY be the cause, given the low
    speeds... but it was).
  9. Bart T.

    Bart T. Guest

    When you say "bypass" caps, is that the same as decoupling capacitors
    connected between Vcc and Gnd of the IC? I use 0.1uF for that purpose.

    I don't doubt that these HC devices are very sensitive to interference
    on the clock lines and in general picky about things because I've
    heard several people say that, but I had an earlier circuit (of which
    this troublesome HC165 was the final output stage with the only
    connection to a parallel port status pin) consisting of 3 HC ICs (an
    HC164, an HC273, and the HC165) where the first 2 ICs worked
    perfectly. My current circuit works just fine if there is no
    connection from Q7 to the port. That's what seems so strange to me. If
    the connection is present when a high bit is sent out by the 165, it
    seems to ruin the internal state of the 165 (it persists after the
    connection is removed and the 165 has to be reloaded with new data.)

    Thanks a lot to everyone who has replied :) It's greatly appreciated.
  10. Have you checked the input rise and fall times with a CRO?
    74HC chips have a maximum rise/fall time spec, if you exceed it you
    can get all sorts of WEIRD problems.
    The capacitance of your connecting cable can cause problems like this.
    Keep your cable as short as possible and check the lines with a CRO.

    Dave :)
  11. Bart T.

    Bart T. Guest

    I don't have access to an oscope, unfortunately :( But I did make some
    progress today:

    I built a voltage divider out of 10K and 2.2K resistors I had handy to
    bring the Vcc down to just under 5V. However, as soon as the parallel
    port is connected, the voltage drops to 2.3V. I never experienced a
    noticable voltage drop when just using the full potential of the

    But on the plus side: The chip works! I didn't even have to add RC
    filters to the clock and parallel load lines, though future designs
    will use them.

    When I unplugged the batteries completely, the circuit still
    functioned! The 2.3V Vcc seems to be coming from the parallel port
    though I have no idea how. The outputs of the port are only connected
    to the clock line and the data lines and the only connections to the
    power rail are through data input lines (because I'm keeping them
    high.) It's as if the Vcc is being supplied by 4 of the 165's data
    inputs! I know the voltage divider idea isn't really suitable for a
    final design but I'm still wondering why it isn't working as it
    should. I'll try rebuilding the circuit from scratch tomorrow. I might
    just have to buy a 5V battery or use the PC as a power source for my

    Thanks for the help so far! I'll keep plugging away at it to see if I
    can make it work the way it ought to with external power.
  12. Chris

    Chris Guest

    Hash: SHA1
    You might also try using a 7805 (a voltage regulator) to get a perfect
    5V with up to 100mA (in the case of 7805) or 1A (in the case of
    78H05) available. Just chuck a couple of capacitors between Ground
    and Vout for filtering. Vin (according to the data in front of me)
    can be anywhere from 8V to 40V.

    Version: GnuPG v1.2.4 (GNU/Linux)

    -----END PGP SIGNATURE-----
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