cancel
Showing results for 
Search instead for 
Did you mean: 

external crystal being perturbed

Ala
Senior

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

4 REPLIES 4
Peter BENSCH
ST Employee

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

  • How exactly do you control the relay from the STM32?
  • What is the layout there?
  • How is the layout of the power supply realised?
  • Have you thought of the free-wheeling diode in parallel with the relay winding?
  • Have you provided filtering measures?

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
  • How exactly do you control the relay from the STM32?

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

  • Have you thought of the free-wheeling diode in parallel with the relay winding?

yes, as you can see in relay-side image, D2 is for that

  • >Have you provided filtering measures?

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?

 

Well, there are many reasons why UART communication can get out of step:

  • You haven't mentioned which of the current 3775 different order options of the STM32 you are using, because the HSI parameters sometimes differ significantly between the families.
  • If you have not calibrated the HSI, it is possible that it accidentally goes out of tolerance for successful UART communication.
  • Interference pulses from the relay coils that reach the STM32 via the layout can also be responsible for this.
  • etc, etc

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?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.