2023-05-26 02:55 AM
hi there. I have a stm32 microcontroller which is ran using HSE. the crystal is 11.0592MHz. the code is simple and is about reading some GPIO_Input and send and receive via UART.
so far good and simple.
this board is actually a relay card. it has 8 relays on it and each relay's NO-NC_COM are left for customer to connect and use.
relays are magnetized this way: a 24v is connected to one end of bobbin and the GND is ran by microcontroller.
in some scenarios it is reported that when a relay is connected to a heavy load, the UART is not working as promised. further research showed that connecting heavy load, causes noise on external crystal and although the UART is working but because of false clock produced by perturbed crystal the packet arrived has false bytes.
what I did was that I used internal crystal of microcontroller and this way the noise of heavy loads did not have any effect on UART.
but is there a way that any time that my external crystal is perturbed, I figure it out someway(maybe in a interrupt) and fix it in my code(maybe re-initialize HSE again)?
thanks for your help
2023-05-26 06:14 AM
You should make your design interference-proof so that you do not have to react to disturbances, but avoid them beforehand or fade them out.
However, I cannot clearly understand your description:
> the GND (of the relay) is ran by microcontroller
First you say: the crystal is 11.0592MHz, then you say: I used internal crystal of microcontroller
Since the STM32 does not have an internal crystal, you must have used either the HSE (together with the external crystal) or the HSI (which is an internal RC oscillator), right?
Regards
/Peter
2023-05-26 10:45 PM
there are images attached that shows how microcontroller controls relays. in the micro-side image you can see that when microcontroller sends a 3.3v on micro_outs label, collector of transistor is set to GND.
then in the relay-side image(attached in the next reply due to limitation of attaching one image at a time) you can see that when when OUT1 lebel is GND, because the relay already has its 24v, it is magnetized and the user can use COM,NO, and NC of relay on the connector
yes, as you can see in relay-side image, D2 is for that
I didn't understand this part
yes you're right I used HSI, I didn't delivered my words in a right way.
now there were my config, where is the problem? can you help?
2023-05-26 10:45 PM
2023-05-28 10:48 AM
Well, there are many reasons why UART communication can get out of step:
By "filtering measures" I meant precautions to prevent interference from e.g. inductive loads reaching the STM32.
Maybe you know someone in your local area who is familiar with driving inductive loads and knows how to design the layout and schematics?