Basic set-up for TPIC6B595 Shift Register with PWM

Hi all! I'm trying to control 8 LEDs (later up to 32) connected to a 12v source. I also want to be able to change their brightness. After some research, I decided to carry on with a TPIC6B595 Shift Register and PWM. The problem is that this is my very first project (I was just playing before with 74HC595), unlike for 74HC595, there are not many tutorials for TPIC6B595 and I can't figure out, where I make an error. I don't want anything complicated for the starters - just to light up a LED and be able to programmatically change its brightness. Could somebody please check if I have the circuit connected correctly and if my code is correct? Thank you very much!

// SRCRL of TPIC6B595
const int clearPin = 7;
// RCK of TPIC6B595
const int latchPin = 8;
// SRCK of TPIC6B595
const int clockPin = 6;
//// SER IN of TPIC6B595
const int dataPin = 9;
//// G of TPIC6B595
const int GPin = 12; 

const byte testDigit = B10101010;

void setup() {
  pinMode(clearPin, OUTPUT);
  pinMode(latchPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(GPin, OUTPUT);
  digitalWrite( clearPin, HIGH);
}



void loop() {
      analogWrite(GPin, 240);
      digitalWrite(latchPin, LOW);
      shiftOut(dataPin, clockPin, MSBFIRST, testDigit);
      digitalWrite(latchPin, HIGH);
      delay(1000);
}

Here is a diagram of my circuit

Here is a photo of my circuit

There is no power connection to the I.C.

Hi, @dworza
Welcome to the forum.

Thanks for using code tags.. :+1: :+1:

How do you aim to PWM through a shift register?
This would be better and easier to code.

There is also a Library for it.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Thanks for a quick response LarryD! If I'll connect the Vcc pin on the Shift Register to the 5V pin on my Arduino, then the intensity of the LED will never change and will always stay at the max. brightness. I thought that if I'd like to control the brightness through the PWM, I need to disconnect the Vcc and control it through the G pin. Or is this incorrect?

Connect the G’ pin to an Arduino PWM PIN.

My idea was to analogWrite to a G pin. I saw a similar example for 74HC595 and thought that it should also work here.

It might be easier but I already bought a bunch of TPIC6B595, which I believe I should also be able to achieve the same goal and it should be possible to change their brightness, if I'm not wrong.

Yes, connect the G’ pin to an Arduino PWM pin.

I connected G to pin 11 on Arduino, changed it in the code

const int GPin = 11; 

But the LEDs won't light up (unless I'd connect directly Vcc with 5v on Arudino). Is there a problem with the code maybe?

The chips Vcc pin needs to be connected to the Arduino 5v pin.

There should also be a decoupling capacitor on this pin to GND (0V).
100nF ceramic

It works! Thanks, @LarryD , you made my day! I honestly didn't know that not all the pins on Arduino can be used for PWM.

Hi, @dworza

Even with the 595, you can only change the state of any channel, one at a time.

So if you are say 50% PWM CH1, when you go to CH2 to PWM its output next, what will CH1 output be doing.

The only way I can see is to high frequency strobe the output channels, faster than the PWM frequency to keep the outputs independently updated "continuously".

To make it clear , you want to be able to give each output a different brightness level, or all the same?

If it is all LEDs the same brightness if you have them active, then the way you are going will work.

Tom.. :smiley: :+1: :coffee: :australia:

The pins with a tilde (3, 5, 6, 9, 10, 11) are hardware-capable PWM pins. See post #3:

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