Monday, April 22, 2019

More out put pins on Attiny13/85 Arduino and 74HC595

More out put pins on Attiny13/85 Arduino and 74HC595

Recently have to build a circuit to control a washing machine, that have no spare parts to rebuild its circuit. i decided to use a attiny85 MCU and a 74HC595 shift register.remember all this circuit does is on/off a relay circuit, so PWM out put work on this one.if one need to out put PWM using shift registers there is a shift registers built for that purposes like TLC5940.to me its ok to have no PWM, 74hc595 has a 8 out put pins , this can be controlled with Attiny85 using just 3 pins.

i have used usbasp programmer from ebay.

program Memory Size 8KB, 5PWM pins , 2nd and 3rd pins can be used as input pins, ADC works on both pins as well.


 
this chips from ebay , and nxp brand seems to be better than ones i have found in local market !

connection diagram as follows :

5v of power supply is needed operate this circuit.



  

PCB :

 
i have used multi-meter to test the out puts of the shift-register, its also possible to use 8 leds with some current limiting resistors.(only few mili-amps can be driven directly from the shift-register).

Arduino code :



int    DS_PIN = 0;//PB0,UC-PHY-PIN 5   || 14TH PIN ON 74HC595 //Serial data input
int SH_CP_PIN = 2;//PB2,UC-PHY-PIN 7   || 11TH PIN ON 74HC595 //Shift register clock pin
int ST_CP_PIN = 1;//PB1,UC-PHY-PIN 6   || 12TH PIN ON 74HC595 //Storage register clock pin (latch pin)
int SENSE_VOLATGE_PIN = A2;//PB4,UC-PHY- 3,ADC3

float SENSE_BATTARY_VOLTAGE;
float VOLTAGE;


void setup() {
  pinMode(DS_PIN, OUTPUT);
  pinMode(SH_CP_PIN, OUTPUT);
  pinMode(ST_CP_PIN, OUTPUT);
}

void loop() {
  write2Registers(B00000000);
  delay(10);
  write2Registers(B11111111);
  delay(10);
}

void write2Registers(byte patternA)
{
  // set latch low so output doesnt change whilst sending in data
  digitalWrite(ST_CP_PIN, LOW);
  // shift out the bits
  shiftOut(DS_PIN, SH_CP_PIN, MSBFIRST, patternA);
  // set latch high to send output
  digitalWrite(ST_CP_PIN, HIGH);
  // pause
  delay(100);

}

download files (includes eagle cad files and arduino sketch) : https://github.com/stark9000/Attiny13-85-74hc595-Arduino

No comments:

Post a Comment