Beginner Shift Register Implementation - TPIC6A595DWG4  - Page 1
Forum section: electronics / projects

author: ryanmills
author_rank: Unknown
timestamp: March 10, 2022, 09:46:59 pm
content: Datasheet:https://www.ti.com/lit/ds/symlink/tpic6a595.pdf?HQS=dis-dk-null-digikeymode-dsf-pf-null-wwe&ts=1646894679936For reference I'm connecting this to a Teensy 4.1. Trying to use a TPIC6A595DWG4 (datasheet above). I only need to write outputs and was thinking it would work the same as an old 74HC595 and I could get away with using only 3 wires. But the TPIC6A595DWG4 has some extra options and I'm a bit confused with the way its written in the datasheet. Below is how I think it's meant to be connected based on what I read. We have our serial clock going to SRCK, we have the Serial TX going to the SER IN. Then I get a little confused, I assume the RCK is basically a latch or write enable. Low to write, high enables the output drains (see the code example below). Then we have G and the datasheet says "When output enable (G) is held high, all data in the output buffers is held low and all drain outputs are off. When G is held low, data from the storage register is transparent to the output buffers.". Looking at the logic diagram if I just leave that low, when RCK goes high, the drains activate? Lastly there is SRCLR, but do I even need it? I'm not reading anything out, do I need to clear the registers before I write again or can I just leave that high? Not sure if when RCK goes low it always starts writing to the registers from zero or if I need to pulse SRCLR so it goes back to 0.Example CodeCode:int data = 2; //SERIAL TXint clock = 3; //SCKint latch = 4; //RCK PINvoid setup(){pinMode(data, OUTPUT);pinMode(clock, OUTPUT);pinMode(latch, OUTPUT);}void update(int data){digitalWrite(latch, LOW); //Pulls RCK lowshiftOut(data, clock, MSBFIRST, data); //Shifts out the 8 bits to the shift registerdigitalWrite(latch, HIGH); //Pulls RCK PIN high, enabling the drains?}

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2022, 10:25:52 pm
content: Its logic side interface is directly equivalent to and compatible with a74HC595(@5V Vcc) except for some minor timing differences, and that the output enable is called /G not /OE. Also its outputs are effectively inverting, as if a 74HC595's outputs were connected to a bunch of N-MOSFETs (with gate pull-down resistors to make /OE equivalent to /G).Generally you don't need to use /SRCLEAR, so tie it to Vcc. /G is more useful as you can PWM it to PWM all output pins that are set On simultaneously.

author: Benta
author_rank: Super Contributor
timestamp: March 10, 2022, 10:34:06 pm
content: First, you're doing yourself no favours by drawing a schematic like it's a PCB with thin tracks. There's a reason for the symbol in the TI datasheet: readability and understanding.There are lots of port options on the Teensy, but for SPI you basically need at least a MOSI + SCK + GPIO output, even better an additional GPIO output for resetting the shift register.SCK -> SRCKMOSI -> SER INGPIOx -> RCKGPIOy -> SRCLR (optional)I don't know the Teensy SPI libraries on which GPIOs to use, but that's the basic connection.

author: Ian.M
author_rank: Super Contributor
timestamp: March 10, 2022, 10:48:51 pm
content: What level shifters are you using? The TPIC6A595's min. VIHthreshold is 0.85*Vcc, and even at its min. operating Vcc of 4.5V that's greater than a 3.3V Teensy can output.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 10, 2022, 10:57:34 pm
content: Shift the data using SRCK (samples the data in the rising edge) and SER_IN.After done, send a positive pulse to RCK to update the output buffer.It's the edge what matters, not the state, the output won't update by keeping RCK high, needs go back to 0 first and updates in the next rising edge.If you don't use G and SERCLR, you got your 3-wire bus.

author: ryanmills
author_rank: Unknown
timestamp: March 10, 2022, 11:39:31 pm
content: Quote from: Ian.M on March 10, 2022, 10:48:51 pmI have not found a level shifter yet, I'm going thru options on digikey right now but open to suggestions. Is there a common solution for the 3.3 to 5v shift?

author: ryanmills
author_rank: Unknown
timestamp: March 10, 2022, 11:44:28 pm
content: Looking at this for the level shift: SN74LS243DDatasheet:https://www.ti.com/lit/ds/symlink/sn74ls243.pdf?HQS=dis-dk-null-digikeymode-dsf-pf-null-wwe&ts=1646955693404&ref_url=https%253A%252F%252Fwww.ti.com%252Fgeneral%252Fdocs%252Fsuppproductinfo.tsp%253FdistId%253D10%2526gotoUrl%253Dhttps%253A%252F%252Fwww.ti.com%252Flit%252Fgpn%252Fsn74ls243

author: Benta
author_rank: Super Contributor
timestamp: March 11, 2022, 12:15:59 am
content: A 74HC14 will do the job. Simplest and cheapest option around.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 11, 2022, 12:22:12 am
content: The 74HC series have a high logic level input threshold voltage dangerously close to 3.3V at 5Vcc. Better go with 74LS series (about 2V).Do you need the high current capabilities of the TPIC?Otherwise just use a 74HC595 at 3.3Vcc?Another option would be to attach a ULN2003 (7 channels) or ULN2803 (8 channels) to the 595 outputs, and will behave exactly the same as the TPIC.The ULN is a Darlington array with integrated base resistors, extremely common and cheap.Plus, the 595+ULN pair will probably be cheaper that a a single TPIC.

author: Benta
author_rank: Super Contributor
timestamp: March 11, 2022, 12:26:48 am
content: It has a sister called ULN2803. Isn't '80s technology wonderful?

author: ryanmills
author_rank: Unknown
timestamp: March 11, 2022, 12:51:35 am
content: Quote from: Ian.M on March 10, 2022, 10:48:51 pmQuote from: DavidAlfa on March 11, 2022, 12:22:12 amThis is the whole board. The goal is to drive eight 5V outputs via serial using 3 wires (out of pins on the teensy). The outputs drive motors/fans that draw 250ma max each. The TPIC6A595DWG4 can drain 350ma saving me a bunch of transistors footprints. Serial source is a separate controller board that has a teensy 4.1 on it, so 3.3V logic. It connects to this board with a basic pin header feeding the serial ports, and rails for GND, 3.3V and 5V. I think this is the final working version, assuming I did not make any mistakes with the level shift. There is also a complementing input board below that handles inputs in the same fashion to the main controller.Disclaimer for those who find this in the future, I'm self taught, there are probably better ways to do this.The "maybe" finished output boardThis is the complimenting input board, its also connects via the same pin header, but takes basic button inputs into a parallel to serial shift register. I assume there is a better way to deal with the array of pull down resistors but I fried my brain on the above output board today.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 11, 2022, 12:58:46 am
content: Benta: Yes, I realised and I was editing the message when you posted thatRyan, compare costs of the 74LS243+TPIC6A595 and the 74HC595+ULN2803 combos.I think you can save quite a bit there!The latter are much more common, about $1.5!

author: Ian.M
author_rank: Super Contributor
timestamp: March 11, 2022, 01:06:52 am
content: Just any 74HCTseries non-inverting gate or buffer, powered from 5V will do for the upwards level shifter. Unlike the 74HC series, the 74HCT series has TTL compatible input thresholds, which do very well for accepting signals from 3.3V CMOS logic. Also, like 74HC, its outputs swing rail to rail, so there's no problem reaching VOH(min)of other 5V CMOS chips. Note that 74HCT logic isn't suitable for downwards level conversion, though it can of course drive a passive potential divider or series resistor and clamp to do that.Benta's suggestion of a 74HC14 hex inverter wont work unless you power it from a carefully chosen intermediate voltage between 3.3V and 5V as it has standard CMOS thresholds. The TTL compatible 74HCT14 would be preferable. Also, as its inverting you'd either need to cascade two of its gates for each signal, or modify your software to invert the clock, data and latch signals.Also the outputs of 74LS or other bipolar TTL logic aren't generally reliably CMOS compatible without a pullup resistor as the Totem Pole output circuit cant drive higher than two diode Vf drops below Vcc.Although a 3.3V 74HC595 + ULN2803 combo would be significantly cheaper, the ULN2803 has much higher dissipation due to its Darlington BJT outputs, which typically drop about one volt when on. It also doesn't have any current limiting so is not well suited to loads with high inrush current.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 11, 2022, 01:38:50 am
content: Unless really required, that could be easily done with extremely cheap discretes.Routing 8 transistors is not hard... Plus you can actually get better performance.

author: ryanmills
author_rank: Unknown
timestamp: March 11, 2022, 01:41:39 am
content: Quote from: Ian.M on March 11, 2022, 01:06:52 amThis really highlights the difference between experienced and someone like myself who is still learning. The TPIC seemed like the best choice to keep my component count down, I have to assemble these by hand, so I'm always trying to keep it as minimal as I can but cost still matters. There are also so many little things to factor in when trying to pick just the right part. I really appreciate everyone taking a few moments to share knowledge with me!

author: ryanmills
author_rank: Unknown
timestamp: March 11, 2022, 01:47:06 am
content: Quote from: DavidAlfa on March 11, 2022, 01:38:50 amRouting I'm not worried about, its the assembly time and foot print size. A lot of what I make is small volume, built when ordered. I can hand solder some 06 components but its so much slower than slapping down a 2010. In this case I would rather have correct signal logic and skip the transistor array. Plus some things are common across other boards, that TPIC I will get use out in other projects as well.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 11, 2022, 01:56:34 am
content: Oh, I didn't see it had the current limiting! That's definitely a good feature.You gotta try smd reflow soldering!Order your stencil, apply solder paste, place the parts, put the pcbs in the oven and wait 5 minutes.You don't really need any fancy stuff, these cheap, small pizza ovens work pretty well, just make some measurements first to make sure it doesn't overshoot like crazy.You could make a whole batch this way in a morning!Even a small hot air station will make it much faster.