Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

FSK detection using Microcontroller - precise clock required

Status
Not open for further replies.

Yasserbn

New Member
I am receiving an FSK signal to a microcontroller and I need to demodulate this signal.

The signal I am receiving is similar to the orange one depicted in my figure but it is a sine wave not a square wave.
View attachment 68637

I need to convert this signal to zeros and ones. I know a basic method that measures the period using a zero crossing comparator and then calculate the frequency. That's fine.

I know that the high frequency is 15Khz and low frequency is 10khz and data rate is 1KHZ. My question is when should I sample the signal?

A clear answer is every 1ms. I can use a timer and for every 1ms I have to measure the period. but what if the timer has an error, let's say +-1us, then after 1000 bits, I may have an error. My timer (clock) may have an accumulated error and I might read faster or slower than it should be?

What can I do to adjust my timer (clock)?
 
My question is when should I sample the signal?
Does your micro have a capture/compare function? Or an interrupt-on-change function? What is the micro clock frequency?
 
I am using an AVR Atmega8 and this micro has a compare function and an interrupt-on-change.
The frequency of the micro clock is 1MHZ.

But I did not understand what to do with them. Do you suggest to reset the timer (clock) when there is a change from 1 to 0 or from 0 to 1. What if there is a big chain of zeros or ones.
 
But I did not understand what to do with them
Carefully read the datasheet for your particular micro. It will explain the operation of the capture/compare and interrupt functions. Then look for code examples relating to those functions on the web.
 
I know what the capture/compare and interrupt functions are.
But what is the answer for my question. When should I sample the signal to measure the period. If I use a timer to measure the period every 1ms, after a while (1000 samples), the timer has errors and it may read values faster or slower than it should be, right? Is my question clear.
 
I know what the capture/compare and interrupt functions are.
But what is the answer for my question. When should I sample the signal to measure the period. If I use a timer to measure the period every 1ms, after a while (1000 samples), the timer has errors and it may read values faster or slower than it should be, right? Is my question clear.
 
Use the interrupt-on-change function to detect successive zero-crossings. In the interrupt handler note the count of a counter clocked at 1MHz and determine the difference between that count and a previous count. The difference has a resolution of 1us.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top