Continue to Site

FSK comms between two microcontrollers

cupoftea

Advanced Member level 6
Advanced Member level 6
Joined
Jun 13, 2021
Messages
3,351
Helped
65
Reputation
132
Reaction score
154
Trophy points
63
Activity points
17,331
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: 37
  • FSK on 3v3 rail.zip
    1.2 KB · Views: 25
It seems you are wanting to use something like telephony 120 to 1200 baud modem where higher bit rates use non-binary compression methods and various test signals for equalization amplitude and phase error correction.

First define the bit rate and latency you need in each direction.
Then decide on half duplex or full duplex with clock & data or use a clock recovery SERDES or PLL.
then the preferred physical channel , fibre, STP, UTP or coax.
- slew rated limited RS-232 & RS-485 has been around since 1960 and 1980
- it can be self-clocked with Async or Sync or use Bi-Phase
- it is pretty benign with a balanced terminated driver/receiver.
-then decide on a higher level protocols for flow control
 
I'm not sure I understand the relationship between FSK and 'no sharp edges'. FSK just means the frequency is modulated to carry the information rather than a voltage or amplitude, it can still be a square wave. I would have thought that slew rate limiting a normal serial link would be just as effective and far easier and cheaper to implement. Using a DAC to generate a sine wave and and ADC to analyze it is quite a complicated procedure and takes lots of clock cycles, To create a 8-bit sine wave at 4KHz needs the DAC to be loaded faster than 1MHz and each load will take several MCU cycles. I think you are confusing clock speed and bandwidth in your Nyquist calculation. I'm not sure it is really cost effective.

Some MCUs, mid-range PICs for example have numerical controlled oscillators and programmable logic blocks, both can be used to produce FSK with no extra hardware at all and if you really want to use FSK there are faster methods than using an ADC to convert a frequency back to digits.

Incidentally, I have just been developing a 1200 bauds FSK comms link for a water pumping station using a PIC at both ends and with a 0.5Km range on VHF. The sending end is solar powered with the whole thing, including PV in/on a box measuring 14 x 8 x 4 cm.

Brian.
 
I would have thought that slew rate limiting a normal serial link would be just as effective and far easier and cheaper to implement. Using a DAC to generate a sine wave and and ADC to analyze it is quite a complicated procedure and takes lots of clock cycles, To create a 8-bit sine wave at 4KHz needs the DAC to be loaded faster than 1MHz and each load will take several MCU cycles.
Thanks i believe you are right.....i must re-purpose the question. As such, forget nearly-perfect sine waves and just please consider a slew rate limited oscillation, ie, which will cause less noise than a square wave. (so eg like a "very steppy" sine wave , say)
So. Is it possible to do it with just the DAC from the transmitter and the ADC in the receiver?

Incidentally, I have just been developing a 1200 bauds FSK comms link for a water pumping station using a PIC at both ends and with a 0.5Km range on VHF. The sending end is solar powered with the whole thing, including PV in/on a box measuring 14 x 8 x 4 cm.
Thanks, this sounds great...and knowing of yourself i am absolutely convinced that it is a superb system! ...in our case we cant do any RF, it would be too costly, and also awkward from other viewpoints, eg, room for the antenna etc etc.
 
Last edited:
Single chip FSK ith sine generation. Just uses a small amount of chip resources.

1743944994439.png


Possible dual sine setup, # samples, period, all programmable :

1743945120770.png
 
Since you have not studied communication theory or design, let me suggest some assumptions to define before a question is asked;

  • Protocol: Choose the right one—e.g., UART (simple, point-to-point), I2C (multi-device, short-range), SPI (fast, full-duplex), or RS-485 (long-distance, noisy environments).
  • Speed: Match baud rate/data rate to your needs and MCU capabilities (e.g., 9600 bps for UART, up to 10 Mbps for RS-485).
  • Distance: Consider range—UART/I2C for inches, RS-485 for thousands of feet.
  • Wiring: Single-ended (UART) vs. differential (RS-485); account for noise, shielding, and termination.
  • Power: Ensure voltage levels align (e.g., 3.3V vs. 5V) or use level shifters; check current draw.
  • Data Format: Define bits, parity, stop bits, and packet structure (e.g., headers, checksums).
  • Synchronization: Clocked (SPI/I2C) or asynchronous (UART); handle timing mismatches.
  • Bus Topology: Point-to-point (UART), multi-drop (RS-485), or master-slave (I2C/SPI).
  • Interference: Mitigate EMI with proper grounding, twisted pairs, or filters.
  • Error Handling: Implement retries, CRC, or ACK/NACK for reliability.
  • Hardware: Check MCU pin support (e.g., UART TX/RX, I2C SDA/SCL) and need for transceivers.
  • Baseband modulation or carrier modulation: AM, FM, PM ,QPSK , high/low BW compression
  • Software: Keep code lightweight; manage buffers and interrupts efficiently.
  • Comm Path: UTP, TP, coax, fibre-optical, wireless; LASER-air, Ultrasound, RF, BT, BLE, LoRa etc
  • 1743946053312.png
 
Last edited:
Thanks, i think ours is literally a kind of bit-bashing thing....we just need to get away from square wave comms pulses because of noise.
So for the stream of oscillations of different frequencies in the top post, do you think it can be mod/demodded with a 32 bit micro at either end (sender and receiver)?
 
Ref material for FSK :



Almost forgot, on Rx side chip can also do this :

1743947151203.png


1743947426369.png

--- Updated ---

Thanks, i think ours is literally a kind of bit-bashing thing....we just need to get away from square wave comms pulses because of noise.
So for the stream of oscillations of different frequencies in the top post, do you think it can be mod/demodded with a 32 bit micro at either end (sender and receiver)?
This question for who ?
 
Thanks, i think ours is literally a kind of bit-bashing thing....we just need to get away from square wave comms pulses because of noise.
So for the stream of oscillations of different frequencies in the top post, do you think it can be mod/demodded with a 32 bit micro at either end (sender and receiver)?
Your assumptions are vague (noise) and incorrect. When a signal is coupled to the inverted signal, balanced, and impedance matched, then EMI cancels. That's why RS-485 is so popular. Additional balancing or shielding may be required near areas of high EMI like industrial welding shops.
 
When a signal is coupled to the inverted signal, balanced, and impedance matched, then EMI cancels.
Thanks though thats too expensive for us...we just have the one signal , which will be kind of very steppy sinusoid, and ground.....as in the top post....thats what gets sent over the wire.

This question for who ?
Thanks, its for anyone that can answer it...from your own kind replies, i seem to believe that it is possible to do the sending and receiving from a 32 bit microcontroller, one on each end.? (sender using DAC and rx using ADC.)

To create a 8-bit sine wave at 4KHz needs the DAC to be loaded faster than 1MHz and each load will take several MCU cycles.
Thanks, so i think you are referring to a sine wave where each period is made of 2^8 pieces?....or you mean literally just eight points for each sine wave period?

I would have thought that slew rate limiting a normal serial link would be just as effective and far easier and cheaper to implement.
Thanks, though i there are not any 32 bit microcontrollers (eg STM32L073) that can do significant slew rate limiting of a square wave output?
 
Last edited:
Yes. This also might help if you go down the FSK path -



Note the part I have discussed, PSOC, has a lot more capability in it than what
you have discussed so far, like an ARM7 core in it, and the below, multiple copies
of resources shown :

1743957947462.png
 
Last edited:
I still think you have the theory wrong. What you propose will work but at the design work, hardware and costs are high when the task can be achieved equally well in a simpler system. FSK does not mean sine waves, it implies an alternating voltage at a modulated frequency but the waveform can be almost anything and it offers absolutely no reduction in EMC in itself. It is the waveform that determines the EMC risk, not the method of sending the data.

Slew limiting the transmitting end or adding an LPF will work just as well as generating sine waves and it can be done with maybe two components R & C.

If you use FSK, all the receiving end needs to know is the frequency, you can either measure it with a simple timer or use a PLL and lock detection. No need to use an ADC at all and you avoid the FFT to work out what the samples represent. The receiving end shouldn't produce EMC at all anyway.

If your budget runs to a three core cable or a two core if you know the grounds are similar at each end, using RS-485 as suggested earlier. The transmitter and receiver cost pennies and you can use cheap CAT-5 cable to get four independent data channels or use some of the wires for ground by sacrificing one or more of them. The balanced RS-485 signals eliminate radiation from and into the cable.

I've run RS-422 which is very similar to RS-485 along CAT-5 parallel to and only about 4 metres from an antenna pumping out 100W of RF without any data errors.

Brian.
 
Thanks, sorry but we cant use RS485 or any balanced signalling. We are limited to the setup in the top post (albeit that uses pure sines and we will cheap out and use very steppy sines instead) ....though there will actually be multiple receivers. We can only have a 2 core cable. Otherwise the installers will moan at connecting up too many ends. The system in the top post is what we are stuck with so to speak. We can of course simplify it by using very steppy sine waves instead of more pure sine waves. The receiver and transmitter both "know" what is the "1" frequency and what is the "0" frequency.

FSK does not mean sine waves, it implies an alternating voltage at a modulated frequency but the waveform can be almost anything and it offers absolutely no reduction in EMC in itself. It is the waveform that determines the EMC risk, not the method of sending the data.
Thanks yes we agree entirely with this.
 
The signalling of your choice is the same as telephony BW limited to 7kHz. Yet you can use STP shielded twisted pair to have >100 kHz/km BW is rejected without reasons. Why?
Thanks, we dont want any dedicated transceiver circuity as such...just a cheap micro either end (rx and tx).
I can assure that the general form has to be as in the top post, though cannot give much more away than that.
The signalling speed is fine for the application.
 
You might find this FSK design useful (even if you dont use this SOC, processor) -


You can look at attached project using PSOC Creator -


It can be run on the low cost board, CY8CKIT-059

In the archive folder after extraction double click the AN60594.cywrk file

1744110752658.png


Then double click TopDesign file left hand window. You will see resources used on chip. Note
there are 3 tabs at bottom of window of other onchip resources/schematics used. To see the
correlator and BPF solutions for design as well. Note the - - - line stuff is offchip.

1744111705219.png


Right hand window shows chip resources used/of total available, in this case most resources available
for other tasks.

Note in above window you can dbl click the PGA (almost any onchip resource) to see how its configed...
and of course there are code APIs to change in code as well when in runtime if needed.

1744111494905.png
 

Attachments

  • AN60594.cywrk.Archive01.zip
    4.6 MB · Views: 20
Last edited:
This question still begs an answer as to why you must choose a communication method to old telephony standards when DSL's can achieve a thousand times more without being "steppy". It's like ignoring the last 50 yrs of evolution in communication. The query is quite narrow yet ignoring the broader scope.

. Otherwise the installers will moan at connecting up too many ends. sounds kind of lame for a shared balanced bus of UTP or STP.

FSK communication can be a trivial application with well defined attributes that depend on assumptions. None of which you have defined, like Baud rate, Error rate, distance, SNR, interference sources, Spectral BW, levels, and cable type.
 
Last edited:
chatGPT on FSK :

Yes, there are several distinct advantages to using Frequency Shift Keying (FSK) for data communication, particularly in specific contexts. Here are some key benefits:


1. Noise Immunity


  • FSK is known for its robustness against noise, especially compared to other modulation schemes like Amplitude Modulation (AM). Since the information is encoded in frequency shifts, FSK is less susceptible to noise and interference that may affect signal amplitude, making it ideal for environments with high noise or in situations where reliable communication is critical.

2. Simple Implementation


  • FSK can be relatively easy to implement, both in hardware and software, especially when compared to more complex schemes like Quadrature Amplitude Modulation (QAM) or Phase Shift Keying (PSK). It requires simpler demodulation and encoding techniques, which can be beneficial in low-power or cost-sensitive applications.

3. Bandwidth Efficiency (for certain applications)


  • FSK can be a good trade-off between performance and bandwidth efficiency. The amount of bandwidth required for FSK is relatively narrow, making it suitable for low-data-rate communications. In cases where spectrum conservation is important, it can be an effective choice.

4. Resistance to Doppler Shifts


  • FSK is more resistant to Doppler shifts (changes in frequency due to motion) than other modulation techniques like PSK or AM. This makes it a better option for mobile communication systems where users or transmitters/receivers may be in motion, such as in satellite communications or mobile radio.

5. Spectral Efficiency in Low Power Applications


  • FSK is widely used in low-power, low-data-rate applications such as RFID systems, pager systems, and some forms of wireless sensor networks. Its efficiency in these scenarios allows for extended battery life, making it ideal for devices that need to operate for long periods on a single power source.

6. Secure Communication


  • FSK can offer a degree of security over some other schemes because the frequency shifts can make it more difficult to intercept and decode the signal without the proper receiver, compared to simpler modulation schemes.

7. Resistance to Multi-path Interference


  • FSK has some inherent advantages in environments where there is multi-path interference, such as urban environments with many reflective surfaces (e.g., buildings). Multi-path signals can cause problems for phase-sensitive modulation schemes, but FSK, being frequency-based, can be less affected.

Use Cases:​


  • FSK is commonly used in modem technologies, radio communications, wireless data transmission, signaling in digital radios, paging systems, and RFID systems, where its advantages in noise immunity, simplicity, and power efficiency are highly valuable.

Overall, FSK is often preferred in situations where robustness to noise and interference, simple implementation, and low-power consumption are critical, especially for low-data-rate applications.
 
FSK is good but I don't think the implementation is efficient.

Transmitting can be greatly simplified with the same end result. Even if a sine wave has to be produced, a single transistor oscillator can be digitally shifted and it would have no 'steps' at all.

Using an ADC to measure a frequency is overkill when it can be done far easier without complex software. Even a simple monostable can do the job although I would suggest a timer to measure the period between 'squared up' cycles is probably more reliable.

I fail to understand the need for a sine wave though. I do understand the problems of interference and EMC but filtering a square wave works equally well and is soooo much simpler.

Brian.
 
The secrecy behind the specs, makes the question have absurd assumptions and conclusions.

Baseband would be trivial with addressable slave targets on any number on the 2 wire bus over many km away limited only by kHz-km wire Baud limitations.

If one was concerned about the edgy things a tight Raised Cosine LPF to avoid ISI is possible but likely unnecessary.
The most common protocol might be BiPhase which is somewhat like FSK with 1f 2f spectrum where harmonics can be filtered and clock can be derived from the data.

But if one wants a Bell 102 modem, here is a schematic.

1744147822462.png
 
Last edited:


Write your reply...

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top