Validation and PCB Editor errors

I’m doing a bit of cleanup and want to throw in another screenshot:

image

Schematics are easier to read if you keep to the convention of Higher voltages on top, lower voltages on the bottom and signal flow from left to right.

Also, what is a value of “R1000”?

image

The Capital R is regularly used as a placeholder of a value multiplier of 1, and this would make it a 0.1 Ohm resistor, while it’s probably meant to be an 1k resistor.

After a bit more cleanup, I put all the power stuff together:

I usually just group the decoupling capacitors, and assume the person who does the PCB layout (me) is smart enough to know why these capacitors exist and how to use them. Putting the power stuff together, also reminded me to add a bigger buffer cap in addition to the decoupling capacitors for the IC’s.
I also put the PWR_FLAG symbols near to the power input connector as an indication that is where the power comes from.

I also just put the connectors directly on the shift registers. I would probably not have named the wires at all, but that is mostly a personal thing. I left the ~{Q} outputs open.

For the control signals, I just used local labels instead of a bus. Using a bus for them may have a slight advantage.

Sometimes the complexity of buses is needed to draw a schematic, but if it can be avoided then that is usually a better option.

The serial data now goes from right to left, which is contradictory to common convention, but for these shift registers the all the inputs weigh in more heavily, and I prefer to have these on the left side of the symbol.

Last, by mirroring one of the power connectors, pin 1 is now on the top of both and by putting them close to each other it’s easier to see they are a straight through connection, except for the data.

2023-02-06_shift-registers-export.zip (12.9 KB)

1 Like

Yeah, that’s how it’s done Paul!

Though I am pretty sure the Q7-not (pin-7) of the first chip feeds to the shift-reg-in (pin-10) of the second chip.

I used these years ago, in conjunction with hc595 for the opposite ser-to-par direction. It was four of each, which became a nice serial loop providing 32-bits in and 32-bits out from a three-wire interface that can be bit-banged or connect to an spi port. Write the driver for any number of num-bytes your gizmo provides (one 165 and one 595 for a one-byte loop, two of each for a two-byte loop…).

Could be.
I mostly concentrated on style. I did not look carefully at the 74165 datasheet and I have not used this chip myself, nor did I check the correctness of the schematic.

1 Like

Hmm, in looking closer at the datasheet I see an extra inversion on the ser-in, so I may have had that backwards and it needs to go to Q. In any event, this is a perfect project to breadboard before doing a pcb as they are available in dip for a quick test.

I do the same, but add a text label above each cap to show where it belongs (eg, U1, U2, U3…).

No. The signal flow in '165 and '595 (and other) registers is straightforward. No inversions.

When chaining the 595 (a SIPO), the next shift register is driven by ~QH, not QH. I don’t know about the 165.

Edit: Ah ok, it’s QH’ and the ’ is not inversion. I thought that was strange, but didn’t look deeper.

Actually it makes perfect sense when I think of it. The chaining has to be from the register before the latch, so that the serial data can propagate even without latching. Then a single strobe signal to all the chips will cause the latched outputs to change in unison.

No it’s not.
It’s a QH’ (with an apostrophe at the end). This output pin (nr 9) is not inverted, it just bypasses the output latches. The datasheet from Ti has the internal schematic of the 74HC595

Note that the output of the register is inverted, but it goes though an inverting buffer again before it’s being output. If the output itself was inverted, then you’d have to invert half the data bytes while daisy chaining these things.

Wouldn’t that technically mean inverting every other byte?

Hey @paulvdh,

thank you so much for the guidance!!! It has taught me a lot and indeed made the schematic easier to read.

By solving all the warnings and errors I am now able to open the PCB editor, which is to say that it’s such a bad UX to have that cryptic error message from Kicad… It’d be way way easier for me if it simply said “Resolve your Electrical Rules check before proceeding”.

I’ve deviated from your suggestion in two points:

  1. I’ve positioned the shift registers as they were and drew the connecting line between them, my OCD couldn’t stand them being opposite against convention.

  2. I’ve retained the noise reduction caps next to the shift-registers (vs the power section) so it’s explicit that these are noise reductions and must be positioned as close to the ICs as possible

I will now set this up on a breadboard and test as it’s not clear what’s going on there with the ~Q (Pin 7) and to generally verify the schematic.

Thank you again for your help!

edit: The PCB editor crash was not resolved due to solving the electrical checklist, I just opened it directly from the editor and the schematic was not connected (thus I could not import). The problem persists, but I have found a relevant issue on gitlab that I am following and trying to solve my local problem: Cannot open PCB Editor - Mac OS - Error Loading (Errno 34) (#12224) · Issues · KiCad / KiCad Source Code / kicad · GitLab

You’ve swapped some things and are making it difficult for yourself. Do the following:
Label U1(10) Data_In
Connect U1(9) to U2(10)
Label U2(9) Data_Out.

Done.

yes, thank you, you’re right, SC is input and Q is output.

I’ve also pulled down all inputs as suggested by @teletypeguy

That looks like it’ll work.
As you’ve tied the two PL signals together, you can only read all 16 inputs in one go. For more flexibility, you could also control the two PL inputs separately, allowing you to read the two 8-bit inputs individually.

Nice. Your pulldowns are kinda low at 1k as your source needs to provide 5mA (at 5V). 10k or so might be gentler. Also, with HC parts, your source signals need to be 5V logic. Alternatively, you can use HCT parts and allow it to work with either 5V or 3.3V input signals.

Actually I was talking about adding a series resistor to provide some esd protection since you are running these signals off on wires somewhere, but yes, pullup or down is needed as well as you cannot have a floating cmos input. It seems like a lot of extra parts but you don’t want to zap the chip. Static zaps are common here so I am a bit sensitive to it. You can add other protective devices, but the simple series resistor (in conjunction with the protection diodes inside the chip) helps limit current when there is a transient spike that exceeds the rails. I have used a series resistor from say 1k to 47k – the cmos input is very hi-z so it does not affect normal operation.

From a nexperia hc guide:

Also, you don’t really care what you shift into the data-in as you are just shifting 16 times to read the input data.

If you later add a 595 or two then you need to properly set/clear bits at the correct point in the shifting, and another signal to load the output regs. A fun little project.

Speaking of 595s:
sprig’s led gizmo

So, what you are suggesting is to have one more array of resistors between the input and the Shiftregister?

In the above schematic, have a 1k (?) resistor between J1 ports and U1 ports?

I am a bit confused with the screenshot you pasted from the nexperia HC guide, could you link the reference? So is this diagram included in the chip or should be “outside” the chip before the input is fed to the shift register?

I am fairly new to electronics engineering, so excuse my noobness, just trying to understand what you meant and what I need to do.

In a more general approach, are the HC165 shift-registers the way to go for reducing multiple inputs (buttons) into a few pins for the microcontroler to handle or there are better practices?

Also, a clarification on the HC vs HCT parts, you said:

I chose to do my PCB on JLCPCB, mostly because their website looks less intimidating than others (better UX)…

From their parts list, I located this PISO SR: 74HCT165D,653 | Nexperia | Registers | JLCPCB

Which has this datasheet: https://datasheet.lcsc.com/lcsc/1912111437_Nexperia-74HCT165D-653_C456131.pdf

Which has this table:

If I am reading this table correctly, the “HC” type accepts input voltage ranging from 2v to 6v, while the HCT model accepts voltage from 4.5 to 5.5, so what I see here is in reverse from what you’re stating…

Can you clarify / enlighten me as to what’s going on here?

Seems nobody mentoned using the MCP23017 port expander to increase the I/O pins of your microcontroller. An advantage is that I2C is often supported by the silicon in the microcontroller so you don’t have to bit-bang shift register control lines. And the I/O pins are bidirectional so you can support both reading and writing the lines. The disadvantage is that the MCP23017 costs more than simple shiift registers. You can even buy expansion boards using hte MCP23017 off the shelf but then you miss out on fun with KiCad and ordering from fabs.

2 Likes

Well the HC family, which often runs on a VCC of 5V, can be powered from 2 to 6V (it is quite happy running at 3.3V). On the other hand the HCT family is only designed to run at 5V and it provides TTL-compatible input thresholds. It was designed to provide a way to interface to the many LS and other ttl families of the day – this feature can be exploited to convert a 3.3V signal (common today) to a 5V signal (getting less common).

If your circuit is powered by 5V you can use either part, so what is the difference? The input thresholds. Standard cmos inputs like HC require a low input (VIL) to be below about 30% of vcc and a high input (VIH) to be above about 70%, while the HCT part has a lower VIH, allowing to be driven from 3.3V signals.

At VCC=5V:
HC: VIL=1.5V, VIH=3.5V (cannot be driven by a 3.3V signal)
HCT: VIL=0.8V, VIH=2.0V (CAN be driven by a 3.3V signal)

So it really depends to what you connect.

1 Like

The HC and HCT inputs have input protection diodes to the rails. So when an input transient goes above vcc by a diode drop it gets clamped. Likewise, if it goes below ground by a diode drop it gets clamped. It has a small effective series resistor of about 100 ohms. For a more robust design (when you are running inputs off-board on some cable), you can add a series resistor at the chip input (not at the connector, where it forms a voltage divider with your pull-down). Probably not needed for your proto application – just something to consider. I live in the desert and can see blue sparks when I touch a light switch, so I am always thinking about esd zapping a circuit I design. The nexperia doc:
https://assets.nexperia.com/documents/user-manual/HCT_USER_GUIDE.pdf
Note that AHC/AHCT is a different family from HC/HCT.

It gets deeper if you want to learn more. There are many logic families.
ti logic family info

For 3.3V applications, LV-A is a nice family, and it is “5V-tolerant” on the inputs – they remove that upper clamp diode on the input for that. So that is a nice way to convert a 5V signal to a 3.3V signal. However, LV-A can also run at 5V.

LVC and LCX are also nice families but cannot run at 5V.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.