WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline bmarkus

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

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

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6421
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #1 on: February 15, 2013, 02: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: 6995
    • My Community Forum
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #2 on: February 15, 2013, 09:45:03 PM »
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, 02: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: 6995
    • My Community Forum
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #4 on: March 17, 2013, 03: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, 03: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, 04: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, 04:28:08 AM by Paulo »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 6995
    • My Community Forum
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #6 on: March 17, 2013, 05: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

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6421
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #7 on: March 17, 2013, 08: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, 09:04:16 AM »
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, 11:12:24 AM by Paulo »

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #9 on: March 17, 2013, 09:07:06 AM »
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, 09:41:31 AM by Paulo »

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6421
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #10 on: March 17, 2013, 09:56:33 AM »
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, 10:10:08 AM »
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

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6421
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #12 on: March 17, 2013, 10:41:11 AM »
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, 10:58:30 AM by Rich »

Offline Paulo

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

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 6421
Re: Turning the Raspberry Pi Into an FM Transmitter
« Reply #14 on: March 17, 2013, 11:14:36 AM »
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, 11:24:07 AM by Rich »