geraldubuntu
Hi all!

I have this project that uses Arduino Mega as the microcontroller for the PLC and utilizes 8-channel relay modules to control the magnetic contactors for switching and a buzzer for alarm. My problem is after several switching, the PLC is disabled and RX TX LEDs of the Arduino stops blinking (can be only RX blinking or both LEDs just lights up indefinitely). I used a different 8-channel relay module for the switching and another for the alarm. I don't think it is because of the contactors or buzzer because when the 220V is powered off, the latching of the 8-channel relay modules still work. I hope it is not because of the Arduino because we can't afford a buy a new set of Arduino Megas (we use three). 

Thanks in advance!
Reply 0 0
thiagoralves
It would be helpful if you can post the OpenPLC logs in here, specially after you notice that it hanged. Are you connecting your arduinos to a computer or to a Raspberry Pi? Usually, when dealing with high currents and high voltages require some precautions on the electronics side. Switching 220V can cause a big impact on the line that feeds your arduinos. Those fluctuations might be causing a reset on your arduino or even causing it to hang. It is wise to use some form of isolation, like optocouplers, when dealing with this kind of situation. You can try to leave the system running with no load to see if this is the case. If the system keeps failing even when there is no load, then the problem can be something else
Reply 0 0
geraldubuntu
I am this kind of relay module:  https://www.sainsmart.com/products/8-channel-5v-relay-module. Don't these modules already equipped with optocouplers? I am using the Arduino with a laptop. It seems that it only happens when the buzzer turns on. But when it is only used to control magnetic contactors, it rarely hangs. 
Reply 0 0
thiagoralves
It’s hard to tell from the picture if there are optocouplers in place. The page doesn’t say anything about it. Also, one other thing that occurred to me is, how are you feeding these boards? Are you taking the 5V power directly from the arduino? This could be another problem, since the arduino can not provide much current on its own. The ideal situation is to have a separate 5V power supply to feed the modules (and even the arduino if possible)
Reply 0 0
geraldubuntu
We're using an external 5V supply for these boards. We were able to solve the buzzer problem and was able to conduct several switching and alarms in our testing. However just now, one Arduino when uploaded with the PLC program, its RX/TX LEDs don't blink like they used to. The usual alternate lighting up of the L and RX/TX LEDs during uploading is still there but the continuous blinking of RX/TX LEDs isn't there anymore, they're not lighting up anymore.
Reply 0 0
geraldubuntu
The log says "error binding socket: Address already in use". This message hasn't shown until just now and we didn't change anything.
Reply 0 0
thiagoralves
This happens when the socket is not properly closed after stopping OpenPLC runtime. Just reboot your computer (or Raspberry Pi or whatever device you’re running OpenPLC on) and you should be good.
Reply 0 0
Reply