But I ran into a problem, I have 8 of these running closely together on a board and when I apply 220V to the relays the magnetic field creates A LOT of interferance with the and the relays begin the clicks very fast and If I move my hand close to the Relay board my actually hand makes the relays turn on and off.
I have 8 N2222 tranistor controlled by a 74HC595.
Here are a pic of the boards
I have a feeling that If I control the positive and not the negative to the coils it might solve this problem
could changing my configuration to this might help ?
I ask because I found the diagram of the 8 relay shield for the arduino ! which I am basically trying to clone, the thing is... I need 16 Amp relays and not 10Amps.
I have about 2 days to solve this problem Or I need to use the relay shield above because this project is due on the 23rd and I still have to program it write a report :o
Basically ! What transistors can I use to run the similar operating to the 8 relay Arduino Shield ?
It sounds like you have some sort of floating input at the Arduino end of things. Movement of you hand will induce interference in the wires going back to the Arduino and the floating input will trigger the relay.
We need to see the schematic of the Arduino end along with the code.
Several points,
That schematic is way too small to see correctly.
You have not enabled the outputs on that shift register, pin 13 should be ground.
You have no supply decoupling on that chip.
Why does it say "Arduino PWM" on the input to the transistor? There is no PWM in this circuit.
Otherwise that look OK are you sure that is what you have. There is nothing to suggest a hand proximity would affect that. What happens when there is no load being switched by the relay contacts?
So what are you switching? Is it inductive? Start off with one restive load like an incandescent lamp.
Still waiting to see what is on the Arduino end. We need to rule out something triggering a floating input on the Arduino that then triggers the dump into the shift register.
/*
Shift Register Example
Turning on the outputs of a 74HC595 using an array
Hardware:
* 74HC595 shift register
* LEDs attached to each of the outputs of the shift register
*/
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
//holders for infromation you're going to pass to shifting function
byte data;
byte dataArray[10];
void setup() {
//set pins to output because they are addressed in the main loop
pinMode(latchPin, OUTPUT);
Serial.begin(9600);
//Binary notation as comment
dataArray[0] = 0xFF; //0b11111111
dataArray[1] = 0xFE; //0b11111110
dataArray[2] = 0xFC; //0b11111100
dataArray[3] = 0xF8; //0b11111000
dataArray[4] = 0xF0; //0b11110000
dataArray[5] = 0xE0; //0b11100000
dataArray[6] = 0xC0; //0b11000000
dataArray[7] = 0x80; //0b10000000
dataArray[8] = 0x00; //0b00000000
dataArray[9] = 0xE0; //0b11100000
//function that blinks all the LEDs
//gets passed the number of blinks and the pause time
blinkAll_2Bytes(2,500);
}
void loop() {
for (int j = 0; j < 10; j++) {
//load the light sequence you want from array
data = dataArray[j];
//ground latchPin and hold low for as long as you are transmitting
digitalWrite(latchPin, 0);
//move 'em out
shiftOut(dataPin, clockPin, data);
//return the latch pin high to signal chip that it
//no longer needs to listen for information
digitalWrite(latchPin, 1);
delay(300);
}
}
// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
// This shifts 8 bits out MSB first,
//on the rising edge of the clock,
//clock idles low
//internal function setup
int i=0;
int pinState;
pinMode(myClockPin, OUTPUT);
pinMode(myDataPin, OUTPUT);
//clear everything out just in case to
//prepare shift register for bit shifting
digitalWrite(myDataPin, 0);
digitalWrite(myClockPin, 0);
//for each bit in the byte myDataOut�
//NOTICE THAT WE ARE COUNTING DOWN in our for loop
//This means that %00000001 or "1" will go through such
//that it will be pin Q0 that lights.
for (i=7; i>=0; i--) {
digitalWrite(myClockPin, 0);
//if the value passed to myDataOut and a bitmask result
// true then... so if we are at i=6 and our value is
// %11010100 it would the code compares it to %01000000
// and proceeds to set pinState to 1.
if ( myDataOut & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
//Sets the pin to HIGH or LOW depending on pinState
digitalWrite(myDataPin, pinState);
//register shifts bits on upstroke of clock pin
digitalWrite(myClockPin, 1);
//zero the data pin after shift to prevent bleed through
digitalWrite(myDataPin, 0);
}
//stop shifting
digitalWrite(myClockPin, 0);
}
//blinks the whole register based on the number of times you want to
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkAll_2Bytes(int n, int d) {
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);
digitalWrite(latchPin, 1);
delay(200);
for (int x = 0; x < n; x++) {
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 255);
shiftOut(dataPin, clockPin, 255);
digitalWrite(latchPin, 1);
delay(d);
digitalWrite(latchPin, 0);
shiftOut(dataPin, clockPin, 0);
shiftOut(dataPin, clockPin, 0);
digitalWrite(latchPin, 1);
delay(d);
}
}
Hi,
Can you post a closer picture of your relay board, component and copper side, and a picture likewise of your 74HC595 board please?
Why the 180R resistor in series with the relay coil?
There are also 120 Ohm resistors before the relays to limit the amount of current through the realy.
With a coil resistance of 220R, you will be almost halving the current to activate the coil with the 180R in circuit.
You do not need to limit the current to the coils?
They will work even BETTER without the 180R, in fact they will work as they are intended.
The 2N2222 will handle up to 500mA collector current.
@Tom I still have time for documentation but time is running super short now
Also ! When i run the Arduino of the 7805 of the problem is a lot more apparent then when I power it of USB !
I tried to put a .1uf cap in series with a 47ohm resistor between - and + of all the relays,
This does not help either.
I then put a scope between one of the realys coils (NOTE this is a crappy DIY scope from china) and I see I negative voltage just after I put 230VAC through relays ! and then the relays turn off.
I am using a 1n0007 diode for the flyback on each coil.
NOTE when I power the Arduinoo on the Project PSU (using a lm7805 regulators with a .33uf cap on the input and a .1uf cap on the output) the problem is A LOT more apparent !
when I power the Arduino off the USB problem shows up a lot LESS !
Am i using the wrong Diode here ?
I am going to quick try a RC configuration between the switch of the relay