Hey Guys, I'm a newbie here. First, y'all are awesome. There is so much good info here and I have been using this site for a few weeks (I'm too new to provide any value additional info).
I'm a Mechanical Engineer with a masters in Systems Engineering. I'm trying to get into circuit design and mechatronics. I'm installing a new router at home. In my control panel, I have manual switches to turn certain items on and off. The CNC will also have the ability to do the same. Originally I was just going to use some simple on-off-on switches but figured this would be a great side project to do some circuit designing....
I have a Arduino Mega 2560 and I need more digital inputs and outputs than offered (adding a touch screen and that uses a lot of them). So, after done some searching/learning, I think adding a 74HC166N shift register(s), would give me the additional inputs I need. Then I was going to pair that with a 595 shift register to control the outputs. Currently I have 595 sending signals to a ALD210808PCL Mosfet.
It took me quite a while to get everything "working." (By working I mean that I switch on and off any of the 8 switches [inputs to the 166] and the Mosfet turns on the right solid state relay.) Now that I have started putting a load to the SSR's, the SSR's are loosing their signal or something. The LED on them slowly fades until the circuit is broken, then it comes right back.
I don't know enough to know if I picked the wrong components or not. I also, have not hooked up a meter to monitor the signal strengths (don't know where to start probing).
Here is a list of the components I'm using:
SSR: Kerwinn KG1-1DA25
Mean Well: IRM-45-12ST
Input Shift Register: SN74HC166N
Output Shift Register: SN74HC595N
Mosfit(s): ALD210808PCL
Arduino Mega 2560
75 watt light bulb
Diagram:
Code: (Its mostly the Element 14 Learning Circuit 77 and 78 code)
////////////////////////////////
// Identify pins on Arduino Mega that are being used
////////////////////////////////
int ioSelect = 2; // SR Pin 15.
int clockPulse = 3; //SR Pin 7.
int dataOut = 4; //SR Pin 13.
int clearPin = 5; //Arduino pin 5 connected to Pin 10, SRCLR(Clear/Reset) of 74HC595
int serialData = 6; //Arduino pin 6 connected to Pin 14, SER(serial input) of 74HC595 --- Serial in
int shiftClock = 7; //Arduino pin 7 connected to Pin 11, SRCLK(shift clock) of 74HC595 -- this lets the register know when to accept a new input
int latchClock = 8; //Arduino pin 8 connected to Pin 12, RCLK(storage/latch clock) of 74HC595 -- high pulse shifts data from rgister to latch
/////////////////////////////////
/// Identify variables
////////////////////////////////
int j; //used in a for loop to declare which bit is set to 1
int value; //stores the digital read value of the data pin
//(0 if no button is pressed, 1 if a button is pressed)
byte switchVar = 0; //stores a byte array to show which button was pressed
void setup() {
//////////////////////////////////
// Identify how pins are used //
/////////////////////////////////
pinMode(ioSelect, OUTPUT);
pinMode(clockPulse, OUTPUT);
pinMode(dataOut, INPUT);
pinMode(clearPin, OUTPUT);
pinMode(shiftClock, OUTPUT);
pinMode(latchClock, OUTPUT);
pinMode(serialData, OUTPUT);
///////////////
// clears old data on register. good for start up
digitalWrite(clearPin, LOW); //Pin is active-low, this clears the shift register
digitalWrite(clearPin, HIGH); //Clear pin is inactive
//////////////
//////////////
// Set baud rate
/////////////
Serial.begin(9600); //setting baud rate
}
void loop() {
byte dataIn = 0; //Swap out byte for uint16_t or uint32_t
digitalWrite(ioSelect, 0); // enables parallel inputs
digitalWrite(clockPulse, 0); // start clock pin low
digitalWrite(clockPulse, 1); // set clock pin high, data loaded into SR
digitalWrite(ioSelect, 1); // disable parallel inputs and enable serial output
for(j = 0; j < 8; j++) { //sets integer to values 0 through 7 for all 8 bits
value = digitalRead(dataOut); //reads data from SR serial data out pin
if (value) {
int a = (1 << j); // shifts bit to its proper place in sequence.
/*for more information see Arduino "BitShift" */
dataIn = dataIn | a; //combines data from shifted bits to form a single 8-bit number
/*for more information see Arduino "Bitwise operators" */
}
digitalWrite(clockPulse, LOW); //after each bit is logged,
digitalWrite(clockPulse, HIGH); //pulses clock to get next bit
}
/////////////////////
// Transfer data to 595
/////////////////////
digitalWrite(latchClock, LOW); // take the latchClock low so
shiftOut(serialData, shiftClock, MSBFIRST, dataIn); //shift out the bits
digitalWrite(latchClock, HIGH); // take the latch pin high so the LEDs will light up
// delay(5000); //short delay added for debugging
}







