2020-08-28 08:01 AM
I am using STM32G030K8 and driving 3 DC motors with relays in the circuit. Also I am controlling voltage of motors with MOSFET. Most of the time its working well but sometimes when I change the direction of motor with relays MCU stops working. I am using buttons for controlling motors. If relay pins were set when it happens, pins stay set and motors still working, it is becoming dangerous. Timer or GPIO interrupts stop working. 10% of times it goes hardfault_handler, %90 of times it stops working without going hardfault_handler. What causes this? and how can I solve this problem?
Thank you.
Solved! Go to Solution.
2021-03-19 06:33 AM
@TDK @Community member @MM..1 @Dvorak.Peter @Laurent Ca...
Thank you for all your answers. After long time I turned back to this project again. I had same problem with totally new design and pcb. Then I started to use CubeIde instead of Keil. I saw its going to HardFault_Handler every time, Keil cant catch it most of the time. In debug console I saw this:then we searched for SIGTRAP. In https://github.com/stm32duino/Arduino_Core_STM32/issues/1206 this link I saw "For the clock issue, it seems your board have an issue with the HSE Bypass (clock provided by the STLink).". My problem was valid all the time not only during debugging process. Also I saw something about HSI in errata. So we decided to change clock configurations. I was using 64 MHz with PLL, I changed it like 16 MHz with HSI. Now I have no problem. Everything is working fine. What I dont understand is this if I use 64 MHz and PLL and run MOTORS its going to hard fault but if I run LEDS or just switch relays without any load its working fine. So drawing high current damages PLL and it makes this error?
2020-08-28 10:19 AM
Examine the SCB registers to determine the source of the error.
Sounds like a power issue when motors switch directions. Measure the rails during an event.
2020-08-28 01:02 PM
I will examine SCB registers and let you know on Monday. Thank you.
2020-08-28 03:17 PM
How do you switch the relay? Do you have freewheeling diode, snubbers? Post relevant portion of schematics.
JW
2020-08-28 08:19 PM
RE : when I change the direction of motor with relays MCU stops working.
I suspect relay contact arcing coupling to the controller
PCB layout is critical
2020-08-29 01:57 AM
Our switch circuit is totally same with the circuit in the picture. Its my bad to ask question on Friday evening, I cant access the circiut or documents until Monday.
2020-08-29 02:02 AM
If the problem is this, how can we prevent this? Is there any circuitry sample to prevent this? Then we can try that solution.
2020-08-29 03:25 AM
Disconnect the motor. Make the relay switch fast, like 3Hz. Still problems?
If no,it's on the swiching (motor) side. As Peter said, switching inductive loads results in high voltage spikes even arcing. This is a group of problems which don't have a single simple solution, so you have to read and decide yourself; using a suitable snubber network may be a starting point.
JW
2020-08-29 05:32 AM
Okay, I will try and let you know the results. Thank you all.
2020-09-06 03:05 PM
Hello @kb24 ,
Please share the way that solved your problem, it may be helpful for other community users.
Then, please select the post of user which is "Best Answer" or mark your post as answered the question.
Best Regards,
Imen