I've got a 8-bit shift register 74HC595 connected to 8 opto-isolators.
But before arduino boots, the shift register turns on the opto-isolators in a random state.
Also, I have a long 5-wire connection from the arduino to the shift register, so if not absolutely necessary, I would prefer to keep only 5 wires.
Instead of putting another wire for the "enable output" pin, can I just plug the shift register's vcc to an arduino pin? This way it all would be turned off, before arduino boots and I set the "vcc" pin to HIGH.
Is it OK to power up a shift register by a arduino IO pin?
The power up state of a shift register is in itself random. Their is a pin on the shift register, that if you pulse it low it sets the shift register to a known state. That pin is known as the MR or master reset pin.
You can use this pin by putting a capacitor from the MR pin to ground and a resistor from the MR pin to 5V. Then when to power is applied, the capacitor keeps the MR pin low for a short time before the capacitor charges up through the resistor. This in effect gives the chip a reset pulse on power up and acheaves the known state you are looking for.
can I just plug the shift register's vcc to an arduino pin?
Bad idea, the supply you get from a logic pin is not very well regulated and the current from that pin is limited. What you can do is to use a PNP transistor as a top switch to apply power to the chip and drive that transistor from an Arduino's output pin through a resistor.
i don't know, I've made the exact same circut, connecting the capacitator/diode/resistor to the !SRCLR pin (!MR), while the arduino boots, the 74HC595 output is it's last state (I want to have the state 00000000).
What if I just power the 74HC595 through an opto-isolator?
I've made the exact same circut, connecting the capacitator/diode/resistor to the !SRCLR pin (!MR), while the arduino boots, the 74HC595 output is it's last state (I want to have the state 00000000).
With the same values?
Try making the capacitor 1uF or bigger.
What if I just power the 74HC595 through an opto-isolator?
You can't power anything through an opto isolator.
in the circuit above, initial state is always all low values?
you said that on power up the register goes to a "a known state". What is a known state? I want to achieve that before I do anything, the shift register has all low values on output (00000000).
What is the solution you used to prevent the shift register to start at a random state?
Wire the master reset pin on the shift register to your Arduino reset.
If your shift register needs the opposite polarity signal then invert the reset from the Arduino with a transistor.