Continue to Site

FSK comms between two microcontrollers

cupoftea

Advanced Member level 6
Advanced Member level 6
Joined
Jun 13, 2021
Messages
3,348
Helped
65
Reputation
132
Reaction score
154
Trophy points
63
Activity points
17,308
Hi,

We would like to do comms between 2 microcontrollers on two different boards. There is a comms wire between them. We wish to do FSK comms due to the sinusoidal signal having no “sharp edges” and so being EMC friendly. (if instead we did square_wave_pulse_type_comms then the “edges” may cause noise issues with surrounding electronics equipment.

Do you think that the attached setup (LTspice and PNG) would be OK?

The transmitting micro simply uses its DAC to put out a sinewave. It will be a bit “steppy “, but we could always put a high frequency filter there. The receiving micro would just use its ADC to read in the signal and decide what frequency it was. As you can see, there are some 10 or so periods in each “bit”. So the micro has plenty of time to work out the frequency.

One frequency is 2kHz and the other is 4kHz….we have aligned them so there is no discontinuity at the frequency change points. (So its less electrically noisy)

So, firstly is this possible?, and secondly, would the micro’s (Rx and Tx) require any specific functional blocks in order to be able to do this? ..Surely not?....Surely just a DAC (for the transmitter) and an ADC (for the receiver) would be required?

Given our FSK frequencies, what speed clocks would you think would be needed. (8kHz by Nyquist?).
 

Attachments

  • FSK between microcontrollers.png
    FSK between microcontrollers.png
    42.8 KB · Views: 35
  • FSK on 3v3 rail.zip
    1.2 KB · Views: 24
Of course we all know about knock offs in Asia and potential issues, and
tech support, failure analysis, all the proper product support there from
those distributor sources. Especially on analog / mixed signal parts....

Not to mention digipart page listing full of stock with "qualified" inquiry status.
Just guessing they are all vacuum packed with desiccant and leak free storage.
Excellence in material handling.....

Is the 74hc942 till in production ?

No Dana, its not.....
 
Last edited:
Using an ADC to measure a frequency is overkill when it can be done far easier without complex software.
Thanks, though we already have two microcontroller sin the system, so believe we may as well use them to "demodulate" the signal.

I fail to understand the need for a sine wave though.
Thanks, my apologies, that was my misleading top post that spoke of sines....we will do any waveform, as long as it doesnt cause electrical noise issues.

I do understand the problems of interference and EMC but filtering a square wave works equally well and is soooo much simpler.
Thanks, that sounds good.....and we can just shovel the filtered square wave into (one of ) the STM32L073 micro(s) and get the bits out of it (demodulate it).
As you possibly suggest, maybe we can shovel it into a on-micro comparator to square it up, then use a microcontroller timer to do the frequency finding and thus thence the demodulation.
 
Good!
I think you were 'over' inventing the wheel. To produce a sine through a DAC requires that you load each point of the waveform (256 for 8-bit resolution) at a 4KHz rate so the DAC needs loading with a new number 256 * 4,000 times per second, that ties up a lot of processor time at 1,024,000 writes/second. Presumably the MCU is doing other things as well so it would eat up a lot of processing time. If you produce the data by programming a timer to produce a square wave at an output pin you only have to do it once per bit and in some MCUs, even small PICs, you can use the signal modulator to switch frequency from the UART output so FSK comes directly out of the pin with no software used at all.

At the receiving end, it doesn't care what the waveform is, only the frequency matters so clean up the signal if necessary with a schmitt input (some MCUs have that facility on the input pin already), then use a timer to measure the frequency. With interrupts it only takes a few lines of code and almost no processing overhead.

Brian.
 
Of course there is no small number of processors out there that can do
a continuous DMA process to handle waveform generation in background.
Even ones with separate buss facilities that relieve main processor buss
of congestion for peripheral management.

On Rx side if you use reciprocal counter latency for freq measurement just
over 1 cycle, so allows higher modulation rates, if so needed or desired.
 
Last edited:


Write your reply...

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top