Hi mates,
I have been working on a medium power switching application for the last few months. The evolution is not too bad but I need your help very much.
I have to control a few DC coils and AC coils (contactors) by Arduino. I use an original Arduino UNO board.
I am using MOSFET transistor to control the DC coils and solid state relay to control the AC coils. I have drawn the schematic!
The problem is that Arduino sometimes freezes. This happens randomly by activating outputs.
Here the list of the components I use:
Optoisolators: PC817.
MOSFET n-channel: IRF3710.
MOSFET p-channel: IRF9532.
Solid State Relay: Input. 3-32 VDC | Output. 90-480 VAC. 8A. (http://www.ebay.com/itm/1PCS-ZG3M-308B-Solid-State-Relay-8A-Output-90-480VAC-/271159416771?pt=LH_DefaultDomain_0&hash=item3f225c57c3).
SL1, SL2, SL3: 36 VDC coils. 500mA.
K1, K2: 230 VAC contactors.
And here the Arduino code:
#include <Wire.h>
#include <i2ckeypad.h>
#include <LiquidCrystal_I2C.h>
const byte defNum[6] = {7, 6, 5, 4, 3, 2}, Q2=0, Q4=1, Q6=2, Q8=3, SSR1=4, SSR2=5;
byte state=0;
i2ckeypad keypad = i2ckeypad(0x3F, 4, 4);
LiquidCrystal_I2C lcd(0x20, 16, 2);
void setup() {
Serial.begin(9600);
Wire.begin(); keypad.init(); lcd.init(); lcd.backlight(); lcd.home();
for(int i=0; i<6; i++) {pinMode(defNum[i], OUTPUT); digitalWrite(defNum[i], false);} lcd.print(state, BIN);
}
void loop() {
char key = keypad.get_key();
if(key != '\0') {
switch(key) {
case '1': update(Q2); break; case '2': update(Q4); break; case '3': update(Q6); break;
case '4': update(Q8); break; case '5': update(SSR1); break; case '6': update(SSR2); break;
}
}
}
void update(byte n) {
digitalWrite(defNum[n], bitRead(state, n));
bitWrite(state, n, !bitRead(state, n));
lcd.home(); lcd.print(state, BIN);
}
Note.- Although the control of SL1 and SL2 may seems stupid (mosfet at the top for each), it must be in this way because of hardware limitations.
Hope you all can help me. Thanks.