Shop OBEX P1 Docs P2 Docs Learn Events
Hook an antenna to your Propeller, and listen to the radio! (New shortwave prog - Page 4 — Parallax Forums

Hook an antenna to your Propeller, and listen to the radio! (New shortwave prog

1246789

Comments

  • SapiehaSapieha Posts: 2,964
    edited 2008-09-10 19:29
    Hi Ken Peterson.

    It is one of My idea to have fast fully programable IN/OUT to PIN UPP/DOWN multi function counters in PROP II



    Post Edited (Sapieha) : 9/10/2008 7:35:10 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-10 19:50
    Ken,

    One approach to demodulating FSK would be to adjust the tuning frequency above or below both FSK frequencies, essentially creating a BFO. The output will consists of FSK in the audio range, which can be bandpass-filtered in code to retrieve the 1s and 0s.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-11 04:18
    Attached is a set of traces that may help to explain what's going on in the receiver. (BTW, I'm the one who suggested to OBC that, despite the simplicity of the hardware, the underlying theory might not be a suitable beginner's topic. Also, beginner's projects need to have a high probability of success; otherwise, a neophyte is likely to become discouraged. This project, in particular, has sketchy prospects for a satisfying outcome, depending on where one lives. I nearly threw in the towel myself, when I was initially unable to pick up anything in my fringe reception area. It was only my confidence in the underlying theory that kept me going. But, all that notwithstanding, I've decided to try for a simpler explanation at least. Maybe the illustration will help.)

    In the top set of traces, there are two sinewaves: one in red, which is the audio signal, and one in gray, which is the RF carrier. When the audio signal is used to multiply the carrier, the product we end up with is an amplitude-modulated (AM) radio signal. This is shown in magenta. This is the waveform what leaves the antenna at the radio station and makes its way into our little radio via its own antenna. By that time, the peak amplitude can be measured in microvolts — millivolts, if we're lucky.

    This tiny signal is presented to pin A3 of the Propeller via a capacitor. Also connected to A3 is a 10 megohm resistor from A4. A counter is configured in feedback mode (normally used for sigma-delta ADC), which reads pin A3 and, at the next clock interval (12.5ns later) outputs the opposite signal (i.e. 0 -> 1 and 1 -> 0) to A4. This "negative feedback" will tend to keep the signal on A3 centered on Vdd/2, which is the Propeller's digital input threshold. But, becasue the feedback resistor is so large, and because there's residual capacitance between the Propeller's pins and ground, the effect of the A4 output on A3 won't be instantaneous. So if the signal coming in on A3 goes very high, it may take several clock periods for a low on A4 to bring it back down. So, the higher the signal on A3, the more 0s we'll see on A4; and the lower the signal on A3, the more 1s we'll see on A4.

    If we were using this counter as an ADC, we could set its FRQx to 1 and let it count the number of 1s it sees on A3 in a given interval. This count would be proportional to the average signal strength on A3 during that interval. But we're not going to do that. Instead, all we need is that string of 0s and 1s on pin A4. This is shown as signal "ADC" in the middle of the attached image, in magenta. If you squint your eyes, you can almost make out the sinusoids (inverted) from the modulated signal, even though, at each instant, A4 is either high or low.

    Two additional counters are used to form the square wave signals I and Q, shown in blue and green. These signals have the same frequency as the carrier, which is how we tune the radio. They are 90° out of phase from each other, though, and have an unknown phase relationship with the incoming carrier. Now, here's where the magic happens. We can take the ADC bitstream from A4 and /XOR (/XOR is the same as the equality function) it at every step with I & Q to produce two resultant bitstreams (shown above I and below Q on the graph). If the carrier happens to line up with I (i.e. if it's in phase with I), more high points than low of ADC will coincide with high points of I, resulting in an abundance of highs after the /XOR; and more low points than high of ADC will coincide with low points of I, again resulting in an abundance of highs after the /XOR. The opposite happens when the carrier and I are 180° out of phase. But in both cases, the number of highs and lows will be at an extreme from the norm, which is a 50% duty cycle.

    On the other hand, if I is 90° out of phase with the carrier, in either direction, the highs and lows will balance out, and their number will be about equal after the /XOR. The reason for having two "local oscillator" signals, I and Q, is so we don't have to rely on just one being in the right phase with the carrier. If one is nearly in phase or 180° out of phase, the other will be closer to 90° out of phase. Moreover, we can combine the outputs of the two /XORs in such a way that the result is completely independent of the carrier's phase.

    As a side note, in an analog direct-conversion receiver, the I and Q oscillators would be producing sine waves, not square waves. And these two signals would be multiplied by the incoming signal, not /XORed, to produce the instaneous Fourier sine and cosine components of the amplitude. Our use of square waves is a little shaky, since each is composed of a sine wave and its odd harmonics (see Wikipedia article) in diminishing amplitudes. For this reason, if we tuned our receiver to 550 KHz and there was a strong station at 1650 KHz (550 x 3), we might pick that up as well. A tuned antenna circuit, rather than just an inductor, would help to alleviate that possibility.

    The Propeller's counters have a logic look-up table mode, that allow them to count the ones from any two-input (i.e. from two pins) Boolean function. And that includes /XOR. So we don't need any external logic to perform this function. We just tell the counters to do it for us. Then all we have to do is sample the "ones" count in a given time interval, which the counters track for us, and record the result. The green and blue traces at the bottom of the illustration show these counts, obtained over the intervals between their changes in value.

    Once we have the sample counts from the /XORed I and Q, we subtract the average count (i.e. half the sampling interval) from each and square the result. Then, we add the squared values and take the square root of the sum to get the "root mean square" (RMS) amplitude of the incoming radio wave at the chosen frequency. This amplitude is a discrete sample (shown in red at the bottom of the illustration) of the original audio signal (shown in red at the top).

    I hope this helps. If not, let me know where things get fuzzy, and I'll try again. (By the way, these graphs were not contrived in any way for illustration purposes but, rather, represent the output from an actual computer simulation of the radio. The data were then imported to Excel to create the graphs.)

    -Phil

    Addendum: Changed the notation in the text and graph from "XOR" (^) to "/XOR" (=) to reflect the results shown in the graph. The program uses XOR, but both XOR and /XOR work equally well. /XOR actually makes a better example, since it more closely follows the multiplication used in analog direct conversion receivers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!

    Post Edited (Phil Pilgrim (PhiPi)) : 9/11/2008 5:56:22 PM GMT
    1161 x 629 - 31K
  • parskoparsko Posts: 501
    edited 2008-09-11 13:26
    Phil,

    EXCELLENT explanation. Of all these RF/RFID discussions and explanations, this one has been the easiest (and most laymen) for me to follow.

    One thing, please. Could you provide a snapshot of the picture that has a differenct timescale? I'm curious to see it "stretched" out so I can see the detail of the the bitstreams, and how their timing lines up with the carrier wave. I'm taking this from where you say: "We can take the ADC bitstream from A4 and XOR it at every step with I & Q to produce two resultant bitstreams (shown above I and below Q on the graph)."

    Also, as a side. It seems that your resultant discrete sample lags wrt the original audio signal (the two red lines). This MUST happen, in all demodulating setups, right? You can't read the signal unless you have time to read the signal. How much is the lag? Is it only 12.5ns? I've often thought about this "lag". You can see it, sometimes, when talking to a friend on the phone, who is watching the same program on TV. His TV sounds a bit behind yours, yet you are both conversing seemlessly.

    Thanks for the great explanation. This gem should be bookmarked (has been for me!).

    -Parsko
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-11 17:17
    Parsko: The lag from the TV's that you mention could be due to the speed of sound. Perhaps their TV is further away from the phone than yours is. In Phil's example, we're talking about a lag of just a few cycles at about 1 MHz so probably a couple of microseconds. I'm not sure the human ear can detect such a small lag.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • RaymanRayman Posts: 14,721
    edited 2008-09-11 17:22
    Thanks Phil for that picture!

    That really does explain it best, I think...

    PS:· Any chance the Prop2 could do FM this way?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-11 17:23
    parsko,

    Attached is the blowup you requested.

    The discrete sample lags the original because of the sample interval. The longer the sample interval, the more the lag and, also, the lower the audio frequency response. In the software I posted, the sample rate is 16 KHz. So the lag could be as much as 62.5 µsec.

    -Phil

    Addendum: I just noticed that the function reflected in the graphs is not XOR, but NOTXOR, in otherwords, equality. It doesn't really affect the outcome, though: both work equally well. I'll have to change the notation on the original graph...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!

    Post Edited (Phil Pilgrim (PhiPi)) : 9/11/2008 5:33:36 PM GMT
    1116 x 625 - 28K
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-11 17:30
    When I have time (I hope soon) I'm going to try to get one prop to talk to another wirelessly. Even if can get a few Kbaud that would be cool.

    Phil: I'm thinking if I use a carrier (Say 27 MHz) FSK modulated with a bit stream, and I tune just above and just below the carrier with two pairs of I&Q frequencies, and take the RMS value of each, then I can compare those RMS values. Or I can take the difference between each RMS value and a running average of each RMS value and compare the differences. Then I would determine the input to be a 1 or 0 based on which difference is higher.

    I'm just thinking that detecting a digital signal should be easier than an analog signal. I also think that FSK will be more resistant to noise than ASK.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-11 17:35
    Comparing the RMS values should work. I don't know how much luck you'll have at 27 MHz, though. Generating clean I and Q signals with an accurate phase relationship may prove difficult. You'll probably get the cleanest signals using the counters' PLL capability, but adjusting the relative phases will be tricky.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • parskoparsko Posts: 501
    edited 2008-09-11 18:53
    Phil,

    Sweet graph. That is exactly what I was askin for. It was kinda clear before what was going on, but being able to see that detail in the bitstream really helps me understand.

    I think I got it right with my guess on the lag. Enough lag and we could be hearing the news from yesterday, right? Luckily the prop is wicked fast.

    -Luke
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-11 19:16
    Phil Pilgrim (PhiPi) said...
    Comparing the RMS values should work. I don't know how much luck you'll have at 27 MHz, though. Generating clean I and Q signals with an accurate phase relationship may prove difficult. You'll probably get the cleanest signals using the counters' PLL capability, but adjusting the relative phases will be tricky.

    -Phil

    True:· Perhaps I can heterodyne it down to a lower IF and go from there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-11 19:32
    Ken,

    One additional note: For the sake of comparison, you can skip the square root. Comparing the sums of squares will yield the same result.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-11 19:35
    Phil: Yes, I was thinking that myself.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • rjo_rjo_ Posts: 1,825
    edited 2008-09-12 03:06
    Phil et al,

    My problem is that when I'm fresh enough to read, I'm in a place that I can't get at my computer. So, I decided to just print this thread out so that I can carry it with me... without associated graphics, it comes to about 14 pages of printed material per thread page.... you've got yourself a good chapter in someone's book.


    This thread is a classic... not a sticky... a classic. We don't have a category for classic threads, but when we do, this one belongs in it.

    Thanks to Phil and everyone that spent good time doing some serious thinking about how to make the inscrutable scrutable, to make the opaque clear... and to make the salty ... well... more salty[noparse]:)[/noparse]

    U no wat I meen.


    Rich

    ILMP
  • Nick McClickNick McClick Posts: 1,003
    edited 2008-09-12 20:00
    Truly. The whole point is to learn by doing, and I've learned a lot more about radio from this thread (& my new prop radio) than from studying for my amateur radio license.

    Good stuff, thanks for the knowledge share. I'd love to publish articles like this on my site once I'm done with all the launch stuff. Another great article is the RFID thread.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Concentrate on understanding the problem, not applying the tool

    Post Edited (Nick McClick) : 9/12/2008 8:09:34 PM GMT
  • Christof Eb.Christof Eb. Posts: 1,206
    edited 2009-01-15 19:36
    Hi Phil,
    ok, I am a little bit late. I just experimented with your program these days. This is very impressive!
    I did not want to solder on my board and to the propeller pins. Do not want to risk to kill the prop.....
    So I just built up the adc on the breadboard. - There was nothing to hear than some "am radio sound."
    Now I have included a transistor -see the circuit- and I am able to clearly hear and understand a radio station.
    The station is roundabout 50km from my home and broadcasts with 100kW Power.

    Many thanks!

    One question to the specialists: There is some ugly noise with 50 or 100Hz. There are some counters left. Can't they be used for filtering?

    Christof
    1667 x 1180 - 95K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-01-15 19:46
    Christof,

    Nicely done! Your transistor preamp is a valuable contribution to this thread, and I appreciate your taking the time to publish it here.

    As to the 50/100Hz noise, it sounds like you're getting some powerline interference. It should be easy enough to program a notch filter to eliminate it. Try Googling IIR notch filter or FIR notch filter for some ideas.

    -Phil
  • Clock LoopClock Loop Posts: 2,069
    edited 2009-09-02 05:46
    I MUST post here to get this thread bumped up to the top. This is an example of an AMAZING use of the propeller.
    Phil, you should REALLY consider putting a thread in the completed projects forum about this.

    Also, I was wondering if a transmitter could be made for the same band.

    Obviously transmission requires permission, but consider this...

    In worst case scenario, if our methods of communication were to fail, I often think about how people might communicate when they have no other way. Am radio seems to be a good method, and having a cheap, easy, low power method to get the word out to the masses would be ideal. Even more ideal is to make a USB receiver that gets AM data. Or even a USB transmitter. Obviously the amount of data is limited, but its better than nothing. Consider the BBS network before the internet. Messages came from around the world through a network of BBS systems.

    Anyone wanna touch on this? Something as simple as serial over AM?

    Post Edited (Clock Loop) : 9/2/2009 9:26:40 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-02 06:07
    You really need a lot of quality analog circuitry around Phil's circuit to do a decent job of reception of something that didn't come from the tens to hundreds of thousands of Watts of power fed into a very large antenna over a good ground plane typical for a commercial AM broadcasting station.

    You also need some high quality analog filtering to take the output of a Propeller counter and make a clean QRP (low power) signal out of it for transmission. You won't get much range with the amount of power (maybe 100mW) available except under very good conditions. You probably would need at least a couple of Watts of output power for any meaningful transmission range and that's with a very good antenna and fairly good conditions.

    There is an Amateur Radio band (160M - 1.8MHz to 2.0MHz) adjacent to the AM broadcast band that could be used for experimentation if you have a license.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2009-09-02 07:09
    @Beau Schwabe

    Could this same scheme be used to let the propeller listen in to
    and use the WWV signal at 2.5 MHz???????

    That would sure let a prop keep accurate time!


    Q: Are you in Oklahoma City, that station says it's in Ok City?
    I get up to Ok City about 6x/yr

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Some mornings I wake up cranky.....but usually I just let him sleep -

    Post Edited (HollyMinkowski) : 9/2/2009 7:15:07 AM GMT
  • heaterheater Posts: 3,370
    edited 2009-09-02 09:21
    You might have more luck with the huge amount of power pumped into WWVB time signals at 60KHz. tf.nist.gov/stations/wwvb.htm

    I've been pondering the German time signal DCF77 on 77.5Khz but it's a bit or a reach to my location (Helsinki).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Ken PetersonKen Peterson Posts: 806
    edited 2009-09-02 11:18
    Seems to me I remember reading about picking up WWVB on a Propeller or some other microcontroller. Now...where was that???? eyes.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-09-02 11:31
    Heater

    One of the reasons that the power levels appear to be so high is that the aerial @ 60KHz is so wavelenth·short and therefore so inefficient, it has to be thumped hard to get something out.

    Efficiency goes down at the square of the reduction

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • Ken PetersonKen Peterson Posts: 806
    edited 2009-09-02 11:57
    I think a WWVB receiver also has to have a fairly large antenna, so it's not something you can make really compact. You'd need a large inductive antenna with a ferrite bar.
  • heaterheater Posts: 3,370
    edited 2009-09-02 11:58
    Quite so. Actually I was just reading the DCF77 page. They mention 50KW. Which is not so huge given there are 1MW am transmitters around.

    DCF77 claims to deliver a useful signal over a radius of 2000Km which puts me just on the edge.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • he1957he1957 Posts: 58
    edited 2009-09-02 12:32
    Very impressive Phil - very creative, many thanks.

    Alas, its a shame such wonderful projects become "lost" in the sheer size and high levels of activity in such Forums. At least I am happy and glad that someone (thanks Clock Loop) has "revived" this and made it noticable. I was thinking about SDRs and how a Propeller might be useful - excellent work - thanks again!


    Cheers,

    Harry E.
  • dMajodMajo Posts: 855
    edited 2009-09-02 15:42
    Ken Peterson said...
    Seems to me I remember reading about picking up WWVB on a Propeller or some other microcontroller. Now...where was that???? eyes.gif

    http://forums.parallax.com/showthread.php?p=778790

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · Propeller Object Exchange (last Publications / Updates)
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-09-02 16:46
    Heater

    I seem to remember that the DCF77 signal is not far from the 4th harmonic of 15.625 line freq and so you have to filter very carefully (or not let anybody close, use glass monitors)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2009-09-02 21:00
    Toby said...
    One of the reasons that the power levels appear to be so high is that the aerial @ 60KHz is so wavelenth short and therefore so inefficient, it has to be thumped hard to get something out.

    50kw is not that much at that low frequency since the antennas are always too close to the ground for much signal to
    go out toward the horizon...the signal goes straight up and must bounce multiple times to reach anyone far away...each bounce weakens the
    signal. I have 1kw on 160 meters to a full size dipole at only 40' ... it's a very LONG antenna! Most of my signal goes straight up but that does
    have the advantage that there is no skip zone at all. Contacts are easy from 0 miles away to about 800 miles....much farther on CW. My antenna is
    strung up between 2 small crank-up towers my dad erected and the soil beneath is very dry sand.

    I mentioned the WWV signal at 2.5mhz because the prop would need a pretty large antenna to pick up that signal at 60khz...it seemed that such
    an elaborate antenna was impractical, but then my atomic clock picks that signal up well... no idea what the antenna inside looks like...maybe
    I will pop it open and see. If I do I will post the image of the antenna in this thread. I think those clocks only listen for WWVB for a few minutes
    during the night as they would have little luck on 60khz during the day.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Some mornings I wake up cranky.....but usually I just let him sleep -
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-09-02 21:26
    For 60KHz, the usual "antenna" is a ferrite "loopstick", and they can be quite small. DigiKey sells them for their time receiver modules. I could never get one to work though, since I'm outside the prime reception zone.

    -Phil
Sign In or Register to comment.