74HC595 in practice ?

Just want to hang out with other Makers and chat about stuff? This is the place to do it.
Post Reply
triaco
Posts: 19
Joined: Fri Jan 31, 2014 5:05 am

74HC595 in practice ?

Post by triaco » Sat Feb 01, 2014 3:53 am

Hello

I have a question regarding the use of two 74HC595 shift registers.

I've found out that it can be achieved through SPI by passing the pattern stored in a variable.
And there is I2C interface as well that could deal with it accordingly to tronixstuff.com

Which method should I choose, some says that SPI is hardware accelerated therefore It must be faster.

How would it work in practice when at the end are D latches that control the lights in my house that are already deployed.
I am worry about some short flashes that might occur.

Suggestions would be much appreciated before I dive in.

Thank's in advance folks

cef
Freetronics Staff
Freetronics Staff
Posts: 106
Joined: Wed Nov 09, 2011 12:53 am

Re: 74HC595 in practice ?

Post by cef » Sat Feb 01, 2014 7:01 pm

Here's a spec sheet for the 74HC595: http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf

Note there are 4 input pins apart from the serial data (DS):
MR
SHCP
STCP
OE

Note that MR and OE are active low, so they need to be tied low (0V) to be used, and are otherwise high.

You feed in data via DS, and clock each bit into the shift register using the clock SHCP. If you need to, you can reset the shift register using the MR.

Once you have the value you want, you clock the STCP line ONCE. This pushes the value into "storage" and presents it at the outputs. This ensures you have only "one" change to your outputs - when you clock the STCP line.

Note: If you want to daisychain more than one 74HC595, take the Q7S output on the first 74HC595, and run it to DS on the second 74HC595 (keep MR, SHCP, STCP and OE common between both chips). The Q7S output is "before" the storage part of the chip for just this reason. With 2 chips you'll get a 16 bit shift register rather than just 8 bit. You can keep chaining them this way to make even bigger shift registers.

triaco
Posts: 19
Joined: Fri Jan 31, 2014 5:05 am

Re: 74HC595 in practice ?

Post by triaco » Mon Feb 03, 2014 5:19 am

Thank you.
Happy to see my very first project working, the LATCH got triggerd.
But there's one issue: if inputPin =13 , the D13 LED turns ON.
I've bought 2 EtherTen boards ( 1 for production and 2nd for learning), so I must cut a trace or de-solder that thing on 1st board. Will it effect the EtherTen in any way?

Code: Select all

const byte SER_Pin = 8;
const byte RCLK_Pin = 9;
const byte SRCLK_Pin = 10;

const byte inputPin =13;


#define number_of_74hc595s 2 

//do not touch
#define numOfRegisterPins number_of_74hc595s * 8

boolean registers[numOfRegisterPins];

//-----------------------------
void setup()
{
  pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);
  
  pinMode(inputPin, INPUT);

  clearRegisters();
  writeRegisters();
}               
//-----------------------------
void clearRegisters()
{
  for(int i = numOfRegisterPins - 1; i >=  0; i--)
  {
     registers[i] = 0;
  }
} 
//-----------------------------
//Only call AFTER all values are set
void writeRegisters(){

  digitalWrite(RCLK_Pin, 0);

  for(int i = numOfRegisterPins - 1; i >=  0; i--){
    digitalWrite(SRCLK_Pin, 0);

    int val = registers[i];

    digitalWrite(SER_Pin, val);
    digitalWrite(SRCLK_Pin, 1);

  }
  digitalWrite(RCLK_Pin, 1);

}
//-----------------------------
//set an individual pin
void setRegisterPin(int index, int value)
{
  registers[index] = value;
}
//-----------------------------
void checkIns()
{
// for testing purpose only 
  int val = digitalRead(inputPin);
  if (val == 1)
  {
    setRegisterPin(8, 1);
    writeRegisters();
  }
  else
  {
    setRegisterPin(8, 0);
    writeRegisters();
  }
}
//-----------------------------
void loop()
{
  checkIns();
}

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: 74HC595 in practice ?

Post by angusgr » Mon Feb 03, 2014 9:09 pm

triaco wrote: But there's one issue: if inputPin =13 , the D13 LED turns ON.
I've bought 2 EtherTen boards ( 1 for production and 2nd for learning), so I must cut a trace or de-solder that thing on 1st board. Will it effect the EtherTen in any way?
Glad to hear you got your project up and running.

Pin 13 is connected to the LED, but on the EtherTen (and also the Eleven and our other boards) it drives the LED via a FET, so it shouldn't influence the normal electrical operation of that pin - it's just a visual indictation of the state of the input.

If the LED is on all the time then this indicates the input pin is being driven (or floating) "HIGH" all the time (or being driven HIGH/LOW at a high frequency that your eye can't perceive.)

If the actual visual indicator is causing a problem then you can certainly desolder it or cut a trace. A simpler and less permanent solution, that I've done in a few of my projects, is to just put a scrap of black electrical tape over it.

Regards,


Angus

triaco
Posts: 19
Joined: Fri Jan 31, 2014 5:05 am

Re: 74HC595 in practice ?

Post by triaco » Tue Feb 04, 2014 6:10 am

Glad to hear you got your project up and running.
This was a test only, a successful attempt to make EtherTen influence my lights.
Without Communities I would never achieve it.
I still have a lot to learn.
If the actual visual indicator is causing a problem then you can certainly desolder it or cut a trace. A simpler and less permanent solution, that I've done in a few of my projects, is to just put a scrap of black electrical tape over it.
I better leave this LED for now if FET is driving it.

Post Reply