I'm trying to engage the coils of more than 2 or 3 relays at the same time. This is the schematic I'm using when breadboarding:
EDIT: I'm using OMRON G5V-2 relays, which have a coil current of 100mA.
When I engage them individually, you hear each coil click. However, if I engage them one by one (additively), you don't hear any coil clicks for the 3rd or 4th.
My EE knowledge is lacking, but I assume this is a power/current issue. I did try using an LM7805 (TO-220 package), but that didn't seem to help.
AddressableLatch.cpp (taken/modified from AddressableLatch/AddressableLatch.cpp at master · brunnels/AddressableLatch · GitHub):
#include "AddressableLatch.h"
const uint8_t AddressableLatch::_digitLatchMap[8] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 };
AddressableLatch::AddressableLatch() {
pinMode(HC259_LE, OUTPUT);
pinMode(HC259_A, OUTPUT);
pinMode(HC259_B, OUTPUT);
pinMode(HC259_C, OUTPUT);
pinMode(HC259_D, OUTPUT);
setOutputs(LOW);
}
/**
Output value should be 1 through 8
*/
void AddressableLatch::setOutput(uint8_t output, bool value) {
digitalWrite(HC259_LE, HIGH);
digitalWrite(HC259_D, value);
_setLatch(output - 1);
digitalWrite(HC259_LE, LOW);
digitalWrite(HC259_LE, HIGH);
digitalWrite(HC259_D, HIGH);
}
void AddressableLatch::setOutputs(uint8_t values) {
digitalWrite(HC259_LE, HIGH);
for (uint8_t i = 0; i <= 7; i++) {
digitalWrite(HC259_D, bitRead(values, i));
_setLatch(i);
digitalWrite(HC259_LE, LOW);
digitalWrite(HC259_LE, HIGH);
digitalWrite(HC259_D, HIGH);
}
}
void AddressableLatch::_setLatch(uint8_t latch) {
digitalWrite(HC259_A, bitRead(_digitLatchMap[latch], 0));
digitalWrite(HC259_B, bitRead(_digitLatchMap[latch], 1));
digitalWrite(HC259_C, bitRead(_digitLatchMap[latch], 2));
}
Please note that I had to change the pin mappings for some reason. I also had to invert the value of digitalWrite(HC259_D, !value); I also am not sure why I had to do that.
Snippet from my .ino:
AddressableLatch relayLatch;
byte idx;
for (idx = 1; idx <= 4; idx++) {
relayLatch.setOutput(idx, HIGH);
delay(1000);
}
relayLatch.setOutputs(LOW);
delay(2000);
for (idx = 1; idx <= 4; idx++) {
relayLatch.setOutputs(LOW);
relayLatch.setOutput(idx, HIGH);
delay(1000);
}
relayLatch.setOutputs(0xff);
delay(2000);
relayLatch.setOutputs(LOW);
delay(2000);
I'm sure it's something so simple, but I'm totally overlooking it.
Thank you in advance for your consideration and help.
Kyle