FSK demodulator in firmware


+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,619

    Default FSK demodulator in firmware

    I have what looks to be a 1.6/3.2kHz FSK signal that I'd like to demodulate to a bitstream using a suitable PIC.
    It's a two wire system with bursts of the FSK signal riding on top of the DC supply, so no carrier like with radio.

    Never dealt with FSK signal before so asking if anyone has done anything like this using PBP?


    I'm thinking of using the ZeroCrossingDetector peripheral together with a timer or two. Either just polling the ZCD Out bit and start/stop the timer(s) or possibly tie it in to the timer gate or go the interrupt route. Being such a low frequency signal I think polling will be more than adequate to get started.

    The goal, for now, is "just" to get the signal into a digital bitstream that I can then capture with a logic analyzer. I know this is analog domain stuff, PLL's and such but when all you've got is a hammer (PBP in this case)....

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,169


    Did you find this post helpful? Yes | No

    Default Re: FSK demodulator in firmware

    Although it is a low frequency, still a zero cross happens every 156.2 usec for the 3.2KHz signal.

    Will the pic be fast enough to process that signal? I am sure ZCD and timers will be enough, but then you have to do some work in less than that period.

    Ioannis

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,619


    Did you find this post helpful? Yes | No

    Default Re: FSK demodulator in firmware

    Plenty fast, I'd say.
    At 32MHz an instruction cycle is 125ns. That's ~1250 cycles between zero crossings.

    I'm not trying to interpret/decode the data, just demodulate the signal.
    Every other zero crossing, grab timer value, do some comparison, flip a bit (or not), reset/restart timer. My gut feeling says we should be able to do that in less than 100 instructions - even with PBP compiled code but we'll see.

    What's "bothering me" is the fact the line is idle for extended periods of time meaning there's no zero crossing and timer will overflow/wrap around. I'll need to detect that.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,677


    Did you find this post helpful? Yes | No

    Default Re: FSK demodulator in firmware

    there are some good ideas here
    https://www.romanblack.com/DTMF/DTMF_alg.htm
    Warning I'm not a teacher

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,619


    Did you find this post helpful? Yes | No

    Default Re: FSK demodulator in firmware

    Thanks Richard,
    I had actually read Romans article but, thankfully, my signal never shows two simultanouse tones - it's always one or the other which makes it easier.

    I started with ZCD module but due to the nature of the signal I could not get reliable results (worked fine with waveform generator feeding it a symetric signal but I was unsucessfull in removing the DC-bias from the actual signal so had to abandon ZCD). Once again goes to show that simulations or even half-assed hardware tests doesn't (always) cut it.

    Currently using a comparator with FVR at 2.048V to one input and the signal to the other. Comparator output drives TMR1 gate. TMR1 gate interrupt flag is used to signal "end of measurement". Pushing TMR1 values into an array, resetting TMR0 each time. When TMR0 overflows the line has been idle for 4ms which is my end of frame indicator.

    /Henrik.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,677


    Did you find this post helpful? Yes | No

    Default Re: FSK demodulator in firmware

    i have zero experience with zcd module but reading the blurb it seems to bias the pin to about 0.7 ish volts. the signal is applied through a suitable R, so that when the signal goes negative the bias is removed and a crossing is detected. if your input never goes negative its not going to work afaics. the comparator is the next best choice. you also might be able to drive the timer gate directly through a voltage divider if the modulation is deep enough
    Warning I'm not a teacher

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,619


    Did you find this post helpful? Yes | No

    Default Re: FSK demodulator in firmware

    Yeah, never used ZCD before either, looked to be the perfect solution for this and a good excuse to play with it.

    Problem with the ZCD and my signal is that the bus idles at 35VDC for "long" periods of time and swings +0/-6V from there, not +/-3V around 35VDC.

    I figured I'd just slap a capacitor in series to remove the DC-bias and that did put "idle" at GND but then the resulting signal swings between GND and -6V instead of +/-3V so still no zero crossing. Adding a pullup outside of the series resistor sort of helped but made the zero crossing drift "upwards" during the "message". All in all it just didn't work relaibly.

    Posted on EEVBlog on how to properly remove the DC-bias and was shot down in flames for selecting the ZCD for this application - which I guess was in order since it did in fact not work :-)

    Comparator solution seems to work fine at the moment (these things now even has switchable hysteresis built in) but it has the drawback of being absolute level. For now it'll have to do, this is just an experiment at the moment.

    Unfortunately I don't have the device providing the REAL signal so I kind of have to emulate/test as best as I can.

    Thanks!

Similar Threads

  1. RF transmission and FSK modules
    By boban in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 07:19
  2. Replies: 3
    Last Post: - 27th October 2008, 15:08
  3. Firmware only USB (16F84A)
    By shahidali55 in forum General
    Replies: 3
    Last Post: - 23rd September 2008, 12:44
  4. supply FSK COB modules and FSK modules
    By Elsa zhang in forum Adverts
    Replies: 0
    Last Post: - 8th August 2006, 06:40
  5. PicBasic Pro FSK Modem
    By mikep in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th October 2003, 14:21

Members who have read this thread : 5

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts