
Shift Register Datasheet:
https://www.ti.com/lit/ds/symlink/tpic6a595.pdfNPN Datasheet:
https://www.diodes.com/assets/Datasheets/FZT1053A.pdfI have the above connect to a Teensy 4.1. Note there is a 1k current limiting resistor on the PWM pin. Everything works but the NPN (Q1) tied to all the PGND's does not seem to control the fan speed at all, they always run at 100%. In fact it seems to do nothing and now I'm wondering if I mis-read the Shift Register Datasheet? The logic diagram reads like all the output transistors go to PGND so if I put an NPN on the PGND I thought I could use it as a global speed control. Reading the datasheet again now I still don't see why this does not work and where the fans are pulling GND if the NPN is off. I scoped the PWM pin (Pin 4) and its working, duty cycles change as expected. I will include the rough class that drives it, but it's pretty light, basic shiftOut and analogWrite in case I missed something simple in the code. I swapped the NPN thinking maybe I blew it testing something else but even on a fresh one the fans always work 100% when on.
#include <Arduino.h>
#include "SolarPins.h"
#include "SolarOutputs.h"
void SolarOutputs::begin(){
Serial.println("SolarOutputs()");
pinMode(SR2_RCK, OUTPUT); //latchPin
pinMode(SR2_SRCK, OUTPUT); //clockPin
pinMode(SR2_DS, OUTPUT); //dataPin
pinMode(OUTPUT_POWER, OUTPUT);
analogWrite(OUTPUT_POWER, 0);
this->update();
}
void SolarOutputs::update(){
byte set_byte = 0b10000000;
for (int i = 0; i < 8; i++){
bitWrite(set_byte, i, this->outputs[i]);
}
digitalWrite(SR2_RCK, LOW);
delay(5);
shiftOut(SR2_DS, SR2_SRCK, MSBFIRST, set_byte);
delay(5);
digitalWrite(SR2_RCK, HIGH);
}
void SolarOutputs::set_power(int power){
double base = power;
double power_level = (base/100) * 255; // convert percent to double
int power_level_int = power_level; // double to int
analogWrite(OUTPUT_POWER, power_level_int);
}
void SolarOutputs::set_output(int bit, int value){
this->outputs[bit] = value;
this->update();
}
void SolarOutputs::kill(){
analogWrite(OUTPUT_POWER, LOW);
}