Author Topic: Beginner Shift Register Implementation - TPIC6A595DWG4  (Read 1649 times)

0 Members and 1 Guest are viewing this topic.

Offline ryanmillsTopic starter

  • Supporter
  • ****
  • Posts: 74
  • Country: us
Beginner Shift Register Implementation - TPIC6A595DWG4
« on: March 10, 2022, 09:46:59 pm »
Datasheet: https://www.ti.com/lit/ds/symlink/tpic6a595.pdf?HQS=dis-dk-null-digikeymode-dsf-pf-null-wwe&ts=1646894679936

For 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 Code
Code: [Select]

int data = 2; //SERIAL TX
int clock = 3; //SCK
int latch = 4; //RCK PIN

void setup()
{
  pinMode(data, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(latch, OUTPUT);
}

void update(int data){
  digitalWrite(latch, LOW);     //Pulls RCK low
  shiftOut(data, clock, MSBFIRST, data); //Shifts out the 8 bits to the shift register
  digitalWrite(latch, HIGH);   //Pulls RCK PIN high, enabling the drains?
}

« Last Edit: March 10, 2022, 09:50:50 pm by ryanmills »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13119
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #1 on: March 10, 2022, 10:25:52 pm »
Its logic side interface is directly equivalent to and compatible with a 74HC595 (@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.
 
The following users thanked this post: ryanmills

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6257
  • Country: de
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #2 on: March 10, 2022, 10:34:06 pm »
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.
1435906-0

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 -> SRCK
MOSI -> SER IN
GPIOx -> RCK
GPIOy -> SRCLR (optional)

I don't know the Teensy SPI libraries on which GPIOs to use, but that's the basic connection.
« Last Edit: March 10, 2022, 10:39:35 pm by Benta »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13119
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #3 on: March 10, 2022, 10:48:51 pm »
What level shifters are you using?  The TPIC6A595's min. VIH threshold is 0.85*Vcc, and even at its min. operating Vcc of 4.5V that's greater than a 3.3V Teensy can output.
 
The following users thanked this post: edavid, ryanmills

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6254
  • Country: es
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #4 on: March 10, 2022, 10:57:34 pm »
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.
« Last Edit: March 10, 2022, 10:59:56 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: ryanmills

Offline ryanmillsTopic starter

  • Supporter
  • ****
  • Posts: 74
  • Country: us
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #5 on: March 10, 2022, 11:39:31 pm »
What level shifters are you using?  The TPIC6A595's min. VIH threshold is 0.85*Vcc, and even at its min. operating Vcc of 4.5V that's greater than a 3.3V Teensy can output.

I 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?
 


Offline Benta

  • Super Contributor
  • ***
  • Posts: 6257
  • Country: de
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #7 on: March 11, 2022, 12:15:59 am »
A 74HC14 will do the job. Simplest and cheapest option around.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6254
  • Country: es
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #8 on: March 11, 2022, 12:22:12 am »
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.
« Last Edit: March 11, 2022, 12:50:04 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6257
  • Country: de
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #9 on: March 11, 2022, 12:26:48 am »
It has a sister called ULN2803. Isn't '80s technology wonderful?
 

Offline ryanmillsTopic starter

  • Supporter
  • ****
  • Posts: 74
  • Country: us
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #10 on: March 11, 2022, 12:51:35 am »
What level shifters are you using?  The TPIC6A595's min. VIH threshold is 0.85*Vcc, and even at its min. operating Vcc of 4.5V that's greater than a 3.3V Teensy can output.

Do you need the high current capabilities of the TPIC?


This 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 board




This 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.



« Last Edit: March 11, 2022, 01:14:21 am by ryanmills »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6254
  • Country: es
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #11 on: March 11, 2022, 12:58:46 am »
Benta: Yes, I realised and I was editing the message when you posted that :D

Ryan, 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!
« Last Edit: March 11, 2022, 01:07:14 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13119
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #12 on: March 11, 2022, 01:06:52 am »
Just any 74HCT series 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.
« Last Edit: March 11, 2022, 01:22:18 am by Ian.M »
 
The following users thanked this post: edavid

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6254
  • Country: es
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #13 on: March 11, 2022, 01:38:50 am »
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.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline ryanmillsTopic starter

  • Supporter
  • ****
  • Posts: 74
  • Country: us
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #14 on: March 11, 2022, 01:41:39 am »
Just any 74HCT series 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.

This 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!
 

Offline ryanmillsTopic starter

  • Supporter
  • ****
  • Posts: 74
  • Country: us
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #15 on: March 11, 2022, 01:47:06 am »
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.

Routing 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.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6254
  • Country: es
Re: Beginner Shift Register Implementation - TPIC6A595DWG4
« Reply #16 on: March 11, 2022, 01:56:34 am »
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.
« Last Edit: March 11, 2022, 02:01:55 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: ryanmills


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf