WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Turning the Raspberry Pi Into an FM Transmitter  (Read 15682 times)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #1 on: February 15, 2013, 05:17:28 PM »
Hi bmarkus
That's pretty slick. But I imagine you'll also be transmitting on the odd harmonics of the carrier with that setup.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #2 on: February 16, 2013, 12:45:03 AM »
Yes, for sure. If you really want it for real use (don't think so) you can add a simple filer or even better a power amplifier. What is erally great is the C source code which helps a lot to learn Pi hardware.

Anyhow, it's a great fun :)
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #3 on: March 17, 2013, 05:20:54 AM »
Hi bmarkus

That is a nice trick using the IO pins to generate a carrier and some modulation.
Not having a Raspberry Pi, I'm wondering what the maximum "carrier" frequency would be?
There are of course other possible applications like a CW transmitter for the HF bands
or even a OOK data transmitter for the lower bands and even up to 400MHZ or so using an external upconverter
but this would involve extra hardware.


Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #4 on: March 17, 2013, 06:30:39 AM »
According to upstream docs it works between 1-250MHz. As in Hungary we got the 70MHz HAM radio band in December 2012 I tried it in the 4m band. Origially it is generating Wide Band FM so I changed it to get NBFM 2-3 kHz deviation. A fellow HAM, HA5PT is located in next street in 500m dstance so my first QSO in the 4m band was made using this setup for transmit with pre-recoded voice messages. For reception I used an old portable broadcast receiver; we had so called OIRT band in the past in 64-73 MHz. It was working :)

He also confirmed, that unmodulated carrier is clean enough to use for CW mode, so it will be the next project. I'm planning a Python module to support CW operation. Also you can use it for HELLSCREIBER transmission as it is simple OOK, and another HAM friend, HA5FLT already developed a HELLSCREIBER TX/RX written in Python and Qt.

It is a fun.

You can listen how music is received in 500m distance using narrow band fm, sent on 70MHz, recorded by HA5PT:

http://www.xham.org/files/HA5DI_HA5PT_4m_S9plusz20dB.mp3
« Last Edit: March 17, 2013, 06:35:27 AM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #5 on: March 17, 2013, 07:23:34 AM »
Hi bmarkus

1-250MHz is a very useful range indeed.
I'm not a HAM myself but do tinker with RF projects and there are a few free-bands
in that range I could experiment on.
You have convinced me to order my Raspberry Pi as projects like this are lots of fun as you rightly said
and Linux is a perfect O.S. for this kind of experimentation.

I listened to the recording and must say that the quality is pretty good.
What did you use as the antennae? Simple quarter wave ground plane, yagis ?
I assume you didn't use an amp or did you buffer the logic level to a lower impedance to better match the antenna?

It's a pity that the Raspberry Pi does not have audio in otherwise this technique could be used as a L.O. feeding a mixer for a SDR and the
resulting low I.F. further processed by the Pi itself.

« Last Edit: March 17, 2013, 07:28:08 AM by Paulo »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #6 on: March 17, 2013, 08:37:10 AM »
Quote
I listened to the recording and must say that the quality is pretty good.

Yes, I was supprized too.

Quote
What did you use as the antennae? Simple quarter wave ground plane, yagis ?

Just 20cm wire :) Station I talked to equipped with professianal radios, rotating yagis, etc. It was just an experiment to see how it works. Of cource you may need some L-C filters and and probably an RF power amp just to protect Pi. However it is a 3.3V output pin which means a high level. Impedance matching is not so important at the moment :)

Quote
It's a pity that the Raspberry Pi does not have audio in otherwise this technique could be used as a L.O. feeding a mixer for a SDR and the resulting low I.F. further processed by the Pi itself.

Yes, it is one of the most important limitation. You need audio input working with SDR radios, communication decoders or VoIP. There are USB sound cards you can use or an USB WEB cam with microphone if stereo is not neeed.

Anyhow, Pi is a nice to play with.

Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #7 on: March 17, 2013, 11:55:52 AM »
Hi Paulo
Quote
It's a pity that the Raspberry Pi does not have audio in ...
If you really want to get down and dirty, you could build a pulse width modulator and connect it to one of the GPIO
pins. Then use the measured duty cycle to control the frequency deviation of the carrier. That presumes you can
get reasonable timing measurements.


Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #8 on: March 17, 2013, 12:04:16 PM »
Hi all

I got pretty excited about using the RPI as a transmitter and decided to design and simulate a buffer and filter.
The design is for the FM broadcast band (88-108MHz) as per the original project.
If anyone needs a redesign for other frequencies, let me know.

I must stress that this is only a preliminary design and simulation and I have not physically built the circuit but it can serve as a starting point.
I have created two zip files (due to size limitations on this forum for attachments) which contain the circuit diagram, the simulation response (narrow band 60-130MHz),
another simulation result (wide band 10-400MHz) all in jpeg format and also a list of the S-parameters in S2p format (plain text).

You will notice that the filter calls for some non standard capacitor and inductor values.
This is not a problem as the inductors can be made variable then adjusted in-circuit for best response and the cap values can be made up with combinations of caps.

It is highly recommended the circuit be built on a proper PCB employing good RF practices.

Finally, if anyone decides to build and use the circuit, please respect your local laws concerning transmitting/broadcasting and you use the circuit entirely at your own risk.

Happy experimenting.
« Last Edit: March 17, 2013, 02:12:24 PM by Paulo »

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #9 on: March 17, 2013, 12:07:06 PM »
Hi Rich

Quote
If you really want to get down and dirty, you could build a pulse width modulator and connect it to one of the GPIO
pins. Then use the measured duty cycle to control the frequency deviation of the carrier. That presumes you can
get reasonable timing measurements.

Not a bad idea that, just wondering what timing accuracies one could get as the kernel is not real time so results
might vary depending on what it's doing at a given time.
« Last Edit: March 17, 2013, 12:41:31 PM by Paulo »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #10 on: March 17, 2013, 12:56:33 PM »
Hi Paulo
I imagine that the transmit frequency gets updated at a periodic rate, so it would probably make sense to measure
the duty cycle during that time. By using a reasonably high frequency for the PWM, say 100Khz, you could poll
the GPIO pin to make the measurement. At that frequency, a measurement would take 15uS. worst case. You
would need to disable interrupts during that time, and have a way to abort the measurement and re-enable the
interrupts should the PWM stop running.

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #11 on: March 17, 2013, 01:10:08 PM »
Hi Rich

Quote
You would need to disable interrupts during that time, and have a way to abort the measurement and re-enable the
interrupts should the PWM stop running.

How does one do this with Linux?
Plus if one had to disable interrupts in one app, would the kernel honour that system wide?
The last time I messed with interrupts was using ASM in a pure dos environment.
I don't mind using X86 ASM, but the ARM instruction set is still new to me.


Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #12 on: March 17, 2013, 01:41:11 PM »
Hi Paulo
For a possible example for Pi, check out:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=7696
He posts the source code here:
https://github.com/richardghirst/Panalyzer
The  pandriver.c  file shows him using  local_irq_disable()  and  local_irq_enable().
« Last Edit: March 17, 2013, 01:58:30 PM by Rich »

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #13 on: March 17, 2013, 01:50:02 PM »
Nice find, thanks Rich.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #14 on: March 17, 2013, 02:14:36 PM »
Hi Paulo
You are welcome.

 @bmarkus: Do you feel we are getting off topic here? If so, Paulo can start a new thread with further questions.
« Last Edit: March 17, 2013, 02:24:07 PM by Rich »