2022-03-08 04:40 PM
Hello to everybody,
I have a problem I can't solve with an STM32 H7 board.
I wrote a little app to command a solenoid valve (24V, 200 mA). It's very simple, I have two software buttons for opening and closing it, using a relay module.
Testing it, everything worked well, but when I connected the valve, I noticed a strange behavior: it worked one or two times, then the valve stopped to follow the commands.
So I reset the board, but it restarted in the same way (one or two cycles, then buttons stop working). I suspected bad contacts, for wrong code cycles... but I understood it was caused by the USB connection. When the valve is active, I lost (sometimes immediately, sometimes after some cycles) the communication with my PC!
This is the scheme:
3.3V to relay module Vcc
5V to JD-Vcc
Common ground to GND
GPO to Input signal
So I start some tests:
1) Power (+24) was connected to relay, Ground (-) is direct to the valve, both from an external power supply.
2) I connected the +24V to NO poles, ground to the valve, and I checked if there was any current to signal (GPO) pin, I measured 0V
3) I placed an open/close loop in firmware, to check the USB port: valve works perfectly, but the USB communication broke in a brief time.
4)I connected Ground to relay, and +24 directly to the valve
5)I placed some ferrites
6)I connected the valve ground valve to the main electric ground.
no result in any way. I noticed that the USB disconnected above all each time the relay is opened. I think it's caused by noise/EMI disturbs, but someone can suggest me a possible solution to solve this problem?
2022-03-08 10:02 PM
Any diodes for protection?
https://www.st.com/resource/en/application_note/an319-relay-drive-protection-stmicroelectronics.pdf
2022-03-09 12:59 AM
The valve coil causes a very strong EMP pulse when switched off. I recommend using a separate, galvanically isolated source for the valve, a relay as close to the valve as possible, an MCU as far away from the valve as possible. The clamp diodes at the relay and the valve are a matter of course.
2022-03-09 11:58 AM
Thanks for your reply.
I used an external 24V for the valve, and I supposed that the usual Arduino relay module can give galvanic insulation as it's based on an optoisolator between the control board and relais. Unfortunately, reading some users' opinions, these modules aren't good enough, and the result is sometimes very poor. So I thought to try a quick (and dirty) solution placing an N5402 diode in parallel with the valve, to reduce the EMP effects. Tomorrow some diodes will be delivered, and I should have waited for them... but I wanted to do another test simply placing the valve at some meters from MCU... I lost again the communication, but this time is forever... Bye-bye STM32, I tortured you too hard!
Tomorrow I'll try with an Arduino (its behavior was the same), placing the diode, and trying also to test using the Arduino relay module to trigger another solid-state relay (MRD-060D2) [probably this is a silly solution...].
Thank again to you for your suggestions!