Вы находитесь на странице: 1из 39

If anyone here considers themselves elite when it comes to hardware hackery, I

challenge you to either:

1. Get this working with stereo. This will involve manufacturing the stereo
pilot tone and difference signal, and then combining it with the mono audio,
and finding some way to output samples fast enough to keep all your new info
below the nyquist rate. Hence you'll need to output this stuff at around
100KHz.

2. Get this working with CPU use < 10%. This will probably involve serious
hackery of the DMA hardware. Your choice if you try to do that (in an unsafe
way) from the existing userspace program, or if you're going to make a kernel
mode driver so you can pin buffers in memory and use interrupts. When you
have the DMA working, you have the (possibly unsolvable) challenge of
trying to find a way to rate-limit DMA transfers to get your audio playback at
the correct rate.

If you understood all that without clicking any links, you are my target audience. If
not, click the links and become wiser!

perma-lien

embed

[]PraiseBeToScience 2 points il y a 4 ans

Sampling rate would have to be above 100kHz, closer to 120-150kHz. Stereo signals
contain audio up to about 57kHz, and any roll off of the audio more than 0.3dB or
phase shift greater than 3o will start degrading your stereo separation at that frequency.
In fact, the highest theoretical stereo separation you can achieve with just one of those
numbers is 30dB, which is pretty good actually, but harder to realize than expected.

Also the 19k pilot tone must be in phase with the 38kHz DSB-SC used to modulate
the differential signal, otherwise you could get nothing but mono at the receiver at
worst, or severely degraded stereo separation at best. If your right and left audio
become reversed it's because the 19k is 180o out of phase with the 38k carrier.

Finally, you need to make sure the audio is band-limited to about 16kHz before stereo
modulation, otherwise your audio could interfere with the 19k pilot, which would
collapse the stereo signal into mono at the RX - possibly even mute the RX depending
now the RX handles loss of pilot.

TL;DR: There's a lot of pitfalls with stereo modulation. Given the low resolution of
audio (9-bit) and sampling rates required, I'm not confident you'll get anything you
could reliably call stereo transmission without external hardware.

perma-lien
embed

parent

[]martinmarinov 8 points il y a 3 ans

https://dl.dropboxusercontent.com/u/24106229/raspb_transmit_stereo_wav.zip

Ok, guys. I kind of got stereo to work :) I've modified the code a bit - optimized the
main loop and removed deemphasis so that I can pull this off. Just unzip it on the Pi
and follow the instructions on how to run it. Invoke the command only from the
command line - don't have anything else running on the PI, running at 192 kHz eats
70% of the CPU even with the optimizations. The wav is 1 minute long and
demonstrates the stereo separation (at some point it starts looping from left to right
and back).

The key is in the wav file - it was generated using


http://www.diffusionsoftware.com/airomate.php . It is 192 kHz 16bit mono file of
stereo encoded signal recorded on Windows with Virtual Audio Cable. I was able to
get the stereo to decode with perfect separation on the sound systems I have (my
phone never decoded the stereo signal, though). I couldn't get RDS working, it could
be that there's something more to it like the wav was not properly recorded in
Windows.

The next step would be to build the stereo encoder inside the app itself. This will be
quite challenging considering the CPU usage but should be doable.

perma-lien

embed

parent

[]londons_explorer[S] 2 points il y a 3 ans

Wow! Really good. I'm very impressed with this.

I really didn't think this was possible, so really well done for doing it.

Do post it on hackaday.com or another reddit post so more people can learn about it -
for something like this you deserve recognition!

I reckon the reason for the RDS not working might be a very slightly wrong sampling
frequency. I found numerous things affecting my sample rate, ranging from drift in the
actual clock crystal by ~40ppm to error caused by "overclocking" the clock generator
which caused it to miscount different amounts depending on temperature. (the clock
generator we are using is supposed to only go up to 25 Mhz according to the
datasheet, but we are running it at 100Mhz). There is also a delay due to the whole
CPU (including the DMA engine and peripherals) being periodically "paused" by the
GPU while it does something todo with refreshing DRAM.

perma-lien

embed

parent

[]londons_explorer[S] 1 point il y a 4 ans

It wouldn't be a challenge if it were easy!

If the software writer is smart enough, you basicly have a 500Mhz 1 bit DAC to
generate your signal.

To see if what we want is possible, we should take an ideal stereo FM modulated


signal, sample it in time to 500Mhz, and quantize it to 1 bit. Now try to decode that
signal and see what quality you get.

Next you have to give that bitstream to the software guys and see if they can coax the
on-chip clock generator to make such a signal, or something very similar to it, which
seems easily possible if you can get rid of linux and run baremetal - more of a
challange if you still need to run an OS.

perma-lien

embed

parent

[]Hansmuh 1 point il y a 4 ans

Are anywhere else people talking about this, maybe in that community? (this thread
will be dead in short time :/ )

perma-lien

embed

parent

[]londons_explorer[S] 3 points il y a 4 ans

"That community" is Imperial College Robotics Society. We are a mostly face-to-face


society, and hence most of the thoughts and discussion so far have been offline. If a
few people are interested in this enough to try things out and write code, we could
switch to making better use of a forum/github/wiki etc.
It seems with the principle we have verified here, there is a good chance you will be
able to transmit on nearly any frequency <200Mhz FM. FSK or on-off keying should
also work easily. AM looks probably do-able. Phase shift keying or QAM may be
possible, but unlikley unless we can really get into the guts of linux to get cycle
accurate timing. OFDM probably isn't possible.

perma-lien

embed

parent

[]PraiseBeToScience 2 points il y a 4 ans

I've never seen a good QAM radio that wasn't implemented on an FPGA or ASIC
because of the timing requirements. Most digital communication of any appreciable
speed I've seen is implemented in hardware of some kind.

perma-lien

embed

parent

[]londons_explorer[S] 2 points il y a 4 ans

Luckily with DMA on most new processors we can alleviate the timing requirements,
because the processor can generate the data at any old inconsistent rate, and DMA
will copy the data to the output at a consistent rate.

For real-world products, using hardware is still better from a power consumption and
cost point of view, but for us hackers, the "software radio without any hardware"
approach is very nice!

perma-lien

embed

parent

[]Poromenos 2 points il y a 4 ans

Hah, there's a project to transmit at 433.something using the third harmonic, I


managed to control some remote-controlled wall sockets with it:

https://github.com/s7mx1/pihat

I'm now trying to open my garage door, unfortunately I don't have an oscilloscope to
see what my remote is doing (or even what frequency it's on)...
perma-lien

embed

parent

[]parkerlreed 1 point il y a 4 ans

This is so great. Very nicely done.

perma-lien

embed

parent

[]shodanx 1 point il y a 4 ans

so essentially you could turn a Pi into a SDR transmitter for any mode any frequency
below 100mhz ?

try sending some HF !

perma-lien

embed

parent

[][deleted] 1 point il y a 4 ans

Note that due to the technique, it can only do FM / FSK

perma-lien

embed

parent

[]londons_explorer[S] 2 points il y a 4 ans

If you were happy to get rid of linux and do baremetal, you could transmit basicly
anything - you wouldn't be limited to fm/fsk.

perma-lien

embed
parent

[]jfedor 12 points il y a 4 ans

Awesome.

Reminds me of Tempest for Eliza.

perma-lien

embed

[]londons_explorer[S] 5 points il y a 4 ans

You sir, deserve a boatload of upvotes...

perma-lien

embed

parent

[]Pendor 11 points il y a 4 ans*

Just tried it.

Freaking awesome.

EDIT: Quick test video for anyone interested. (yes, it does say 4 AM, reddit does not
help the insomniac at all)

perma-lien

embed

[]Beegee773012/06/2012 Arrival 8 points il y a 4 ans

Is there a way to change the frequency it broadcasts on? I haven't checked the source
yet, but in the UK at least 100-101 is reserved for Classical Radio almost everywhere.

perma-lien

embed

[]londons_explorer[S] 6 points il y a 4 ans

maybe
In pifm.c, see line 106.

The "5a" number here is a hardware specific password - ignore it (see the datasheet
for specifics).

The "0x5000" is the carrier frequency. m is the added audio modulation. It should be
interpreted as 5.000 (in hex). This chooses how the 500Mhz system clock is divided
down to produce the 100Mhz FM carrier. Hence if you wanted a 99.0Mhz carrier, you
would divide by 5.050505 (decimal), which in hex is 5.0CF.

Hence if you changed the number on that line to 0x50CF you should be able to get a
99.0Mhz FM signal.

perma-lien

embed

parent

[]Hansmuh 2 points il y a 4 ans

Yes, thats it. I tried it with 0x58CC and now i've got the signal on 90Mhz.

perma-lien

embed

parent

[]londons_explorer[S] 4 points il y a 4 ans

0x58E3 is the correct value for 90.0Mhz. Using the wrong value makes some more
strict FM radios stop working, and reduces the range significantly. The "center"
frequency should be a multiple of 0.1Mhz for most radios.

Due to a quirk of the way FM works, if the center frequency is off, you may find quiet
sounds work fine, but loud sounds in the audio cause fuzz on the receiver.

perma-lien

embed

parent

[]Hansmuh 1 point il y a 4 ans

You're right. Thanks for the hint.


perma-lien

embed

parent

[]MattRichardson 2 points il y a 4 ans

First of all, thanks for this. I'd like to change the frequency, but I'm having trouble
following the math (admittedly, not my strong suit). I'm good, up until where
5.050505 becomes 5.0CF. I'm fine with making decimal ints into hex, and I've tried a
few ways to convert the dec float to hex, but I can't match your conversion on my
side. Can anyone lend some help? I'd like to transmit up in the 2m amateur band. So,
perhaps one of these frequencies.

perma-lien

embed

parent

[]londons_explorer[S] 3 points il y a 4 ans

Here is how to calculate it:

http://www.wolframalpha.com/input/?i=%28500%2F99.0%29+in+hex

Round to 3 decimal places. If the number is 8 or above, round up, and if the number is
7 or below, round down.

perma-lien

embed

parent

[]MattRichardson 1 point il y a 4 ans

Brilliant, thanks!

perma-lien

embed

parent

[]londons_explorer[S] 1 point il y a 4 ans


Note the "25.0" number in the source code probably wants to be revised downwards
for the 2m band. The "25" represents the bandwidth\sound volume (same thing in
FM!). You probably want more like 5.

perma-lien

embed

parent

[]Beegee773012/06/2012 Arrival 1 point il y a 4 ans

Thanks a lot!

perma-lien

embed

parent

[]Hansmuh 2 points il y a 4 ans

I try to understand the source code. But i dont now where i can chance it yet.

perma-lien

embed

parent

[]londons_explorer[S] 1 point il y a 4 ans

My apologies for the source code. It really was hacked together. about 70% of it does
nothing or is commented out.

I would like to fix it, but don't have a Raspberry Pi handy right now, and wouldn't
want to break it. Messy is better than broken!

perma-lien

embed

parent

[]rgrasell 2 points il y a 4 ans

I modified the program and put some information in a comment:


http://www.reddit.com/r/raspberry_pi/comments/14k5o3/raspberry_pi_fm_transmitter
_with_no_additional/c7efamt

perma-lien

embed

parent

[]aaa801 1 point il y a 4 ans

Yep classic FM and kiss 100

perma-lien

embed

parent

[+][deleted] nombre de points du commentaire sous la limite (9 enfants)

[]rgrasell 6 points il y a 4 ans*

I've modified the program to accept another argument on the command line that a
alters the frequency that it broadcasts on. It's as hacky as possible, but it works. If
anyone is interested, here's the source: be warned, it does no error or safety checking,
so you run this at your own risk, etc.

It makes a clicking noise right as the program starts, I'm not sure why yet.

usage: pifm wavefile.wav frequency

example: pifm sound.wav 100.1

link: http://pastebin.com/CU2w3Ad1

(if there is a better way to share this file, or a problem with it, please tell me)

perma-lien

embed

[]MattRichardson 3 points il y a 4 ans

Thank you so much; I got this working with no problem at all. Do you think it would
be very difficult to have it stop transmitting the carrier when it's done playing the
sound?

perma-lien
embed

parent

[]rgrasell 2 points il y a 4 ans

I'll look into it! As of now, if you just run the program with no parameters it should do
what you want (e.g. "./pifm")

perma-lien

embed

parent

[]MattRichardson 1 point il y a 4 ans

Ah! Thank again, this is fantastic work.

perma-lien

embed

parent

[]parkerlreed 2 points il y a 4 ans

What format does it accept the frequency in? 100 for 100mhz? And also if it is in
another format, is it possible to do something like 100.1? My car stereo only does odd
tenth's place.

Edit: Spelling.

perma-lien

embed

parent

[]rgrasell 2 points il y a 4 ans

Sorry for the confusion!

It accepts numbers with or without a decimal, don't add "mhz".

perma-lien

embed
parent

[]parkerlreed 2 points il y a 4 ans

Sweet! Working great. Nice hacky mod to already hacky code. :)

perma-lien

embed

parent

[]rgrasell 2 points il y a 4 ans

Gotta make winter break productive somehow!

perma-lien

embed

parent

[]londons_explorer[S] 1 point il y a 4 ans

Thank you for this!

The number "25.0" on line 127 of your code is the "bandwidth/volume" of the FM
signal. For HAM radio enthusiasts, or if you want to fine-tune your signal, you may
want to modify it. The units are the same as the units of center frequency. For FM, 15
is about ideal. For most ham radio uses, you want more like 2 or 5. When we were
hacking stuff together we guessed at this number, and it seems we guessed a bit big.

perma-lien

embed

parent

[]themdh 1 point il y a 3 ans

"Can't open /dev/mem". Any ideas what Im doing wrong?

I replaced pifm.c with the linked file above, opened terminal, navigated to the folder
and typed "./pifm sound.wav". Not sure what's wrong. Thanks for any help.

perma-lien

embed
parent

[]themdh 1 point il y a 3 ans

Nevermind I pulled a stupid and forgot sudo

perma-lien

embed

parent

[]LeoPanthera 4 points il y a 4 ans

What's the range of frequencies that this could work at? If you could modify it to
work on one of the amateur radio bands then licensed users would not be breaking the
law.

perma-lien

embed

[][deleted] 3 points il y a 4 ans

Ho. Ly. Shit.

How did I not know the Pi had a SSC signal generator? This is brilliant. I will have to
look into DMA with the ARM to see if I can help write up a kernel-mode driver.

perma-lien

embed

[]londons_explorer[S] 3 points il y a 4 ans

It seems nearly all chips have smart clock generators to produce very accurate clock
rates for peripherals without needing additional crystals, or to get round EMI
regulations.

Basicly, this hack was done on a Raspberry Pi, but I bet you could reproduce it on
nearly any processor.

perma-lien

embed

parent
[]EchoNoise 3 points il y a 4 ans

If this is possible, would it then be possible to do short wave?

perma-lien

embed

[][deleted] 1 point il y a 4 ans

I doubt it, shortwave is AM.

perma-lien

embed

parent

[]londons_explorer[S] 4 points il y a 4 ans

AM is much harder, although it is not impossible for certain. There are lots of
harmonics of these signals you can "abuse" into falling to the frequencies you desire.
Use of harmonics even allows power (amplitude) to be modulated quite easily by
switching between the first harmonic of 100Mhz @ 100Mhz and third harmonic of
33.3Mhz @ 100Mhz for example you can effectively modulate the amplitude of the
signal seen at 100Mhz between full power and a third power.

perma-lien

embed

parent

[]gsvimx 1 point il y a 4 ans

And who cares about anyone else trying to use the spectrum at 33.3MHz, amirite?

perma-lien

embed

parent

[]londons_explorer[S] 1 point il y a 4 ans

you are right. None of this stuff is kind to anyone using any other frequency.
If you were to put a basic bandpass filter on the output you could solve it, but
obviously that isn't as cool as a "zero components" hack...

perma-lien

embed

parent

[]LeoPanthera 3 points il y a 4 ans

I made a video demonstrating this: http://youtu.be/blvaYR6aYXA

perma-lien

embed

[]TSwift13 2 points il y a 4 ans*

I can only assume I'm doing something wrong.


Edit: Maybe not. 'tar xvf Pifm.tar.gz' outputs:

pifm
pifm.c
PiFm.py
PiFm.pyc
sound.wav

gzip: stdin: invalid compressed data--crc error


tar: Child returned status 1
tar: Error is not recoverable: exiting now

So that leads me to believe that the default 'sound.wav' that is supplied is corrupt, as
mplayer says 'Failed to recognize file format.' also..

EDIT

Fixed it. I just compiled it using:

gcc -lm -std=c99 pifm.c

and it worked perfectly,

perma-lien

embed

[]londons_explorer[S] 3 points il y a 4 ans


I have hopefully fixed the archive online - something got corrupted somehow. You
now have a valid tar archive, valid permissions on the binary, and a valid wav file
inside.

perma-lien

embed

parent

[]Justinsaccount 1 point il y a 4 ans

a corrupt wav file would not give you the error you are getting.

try

sudo ./pifm sound.wav

perma-lien

embed

parent

[]TSwift13 1 point il y a 4 ans

I tried that, there is no output, and I can't hear anything except silence through the
radio.

perma-lien

embed

parent

[]Justinsaccount 1 point il y a 4 ans

try a different audo file?

perma-lien

embed

parent

[][deleted] 1 point il y a 4 ans


Does it actually broadcast silence then, so you're not hearing static? I'm tryign to find
out if this actually works before I try it.

perma-lien

embed

parent

[]TSwift13 1 point il y a 4 ans

I've got it working now.

I had to compile it myself, using the instructions in the link. Then I could hear the
sound.wav file, which is the Star Wars theme.

And even when I first turn on my Raspberry Pi, I hear silence when tuned into
100.0Mhz

perma-lien

embed

parent

[]londons_explorer[S] 3 points il y a 4 ans

This is worth noting.

In a normal environment, you should hear static on 100Mhz. Then after the first time
you play a sound, the program leaves the carrier activated, so you will hear silence.
This is to make it easier to write a game or something that uses sound - you don't want
the radio playing static loudly between each sound you want played.

A reboot of the Pi will stop the carrier, and you'll be back to the old static.

If you hear silence even with the Pi off, it may be your laptop or something else is
broadcasting on 100Mhz. When we first did this project, we used 96.0Mhz, and it
turns out thats no use because USB usually uses a 19.2Mhz clock crystal, and the 5th
harmonic of that is 96Mhz. If any of that harmonic leaks out, it interferes. My laptop
has an interference range of about 1 meter. A macbook we tried didn't interfere.

EDIT: Also, in the first version the .wav file was accidentally corrupted by chopping
off the header so it would play through PiFm, but not through a media player. I was
wondering how long till someone knew what the song was! I have now un-corrupted
the wav file for all future downloads.

perma-lien
embed

parent

[]Hansmuh 1 point il y a 4 ans

Same error for me, but it worked.

perma-lien

embed

parent

[]benjgvps 2 points il y a 4 ans

I wasn't expecting the range to be that good when I saw the title! 50 meters? That
might be useful for some sort of one-way data transfer (Sensor info, perhaps).

perma-lien

embed

[]londons_explorer[S] 2 points il y a 4 ans

A zero-hardware FM receiver isn't a totally silly idea. I think it might be do-able. You
would rely on a floating IO pin to pick up your signal, and another nearby IO pin
transmitting the carrier frequency at very low power. The two signals sum by mere
virtue of being near eachother on the circuit board, and the result can be sampled by
the chip.

The chances of this working alone is pretty low, but with maybe just one resistor or
capacitor, I reckon it could work for short distance two way low bandwidth
communication.

If the chip has any schmitt-triggeryness on the inputs, this isn't going to work at all...

perma-lien

embed

parent

[]benjgvps 2 points il y a 4 ans

I was thinking along the lines of using a cheap fm radio and usb sound card on the
receiving end.
perma-lien

embed

parent

[]Maxious 1 point il y a 4 ans

Reminds me of the project using the compass in an android device and a coil of wire
on an arduino to transfer data

perma-lien

embed

parent

[]Really_Likes_Nutella 2 points il y a 4 ans

Looks cool, will have to do some hacking when it's not midnight.

How is this as far as broadcast regulations?

perma-lien

embed

[]TSwift13 -1 point il y a 4 ans

Pretty sure it's 100% legal


http://en.wikipedia.org/wiki/FM_transmitter_%28personal_device%29

perma-lien

embed

parent

[]Really_Likes_Nutella 2 points il y a 4 ans

Looks iffy but I'm going to bed now so I can't be arsed to look into it.

The new Regulations set out the technical specifications for legal devices. This is to
minimise the risk of interference to other radio devices. In particular, the Regulations
set a 50 nanowatts power limit for legal devices, which limits the distance at which
they can broadcast to up to around 30 metres in stereo, using a modern hi gain FM
radio, however by receiving the signal in mono this range can be increased due to the
lack of audible noise when receiving in mono,
perma-lien

embed

parent

[][deleted] 2 points il y a 4 ans

Nowhere near legal.

perma-lien

embed

parent

[]cybergibbons 1 point il y a 4 ans

Hmm. Whilst you can use low power transmitters for personal audio, power is limited
and I don't think it is clear what happens with home brew devices.

I would be concerned about this method producing nasty harmonics. I doubt this
would cause any problems, but technically it could be illegal. You are also highly
unlikely to be caught or prosecuted.

perma-lien

embed

parent

[]Beegee773012/06/2012 Arrival 2 points il y a 4 ans*

I seem to be getting an error. I installed Raspbian through the netinstall, and tried
running it on Python 2.7.3.

root@raspi:/usr/lib/python2.7# sudo python


Python 2.7.3rc2 (default, May 6 2012, 20:02:25)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> import PiFm
>>> PiFm.play_sound("sound.wav")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "PiFm.py", line 7, in play_sound
call(["./pifm", filename])
File "subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "subprocess.py", line 679, in __init__
errread, errwrite)
File "subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
>>>

As you can see, I'm running from root so it's no permission issue I believe. Can
anyone help? I've also tried compiling but have got nothing.

(I did place the files correctly, right? In /usr/lib/python2.6 and /usr/lib/python2.7?)

perma-lien

embed

[]MrLumaz 2 points il y a 4 ans

I'm having the same problem!

perma-lien

embed

parent

[]Beegee773012/06/2012 Arrival 1 point il y a 4 ans

I did manage to temporarily bypass it by running it manually...

./PiFm sound.wav

And it works, but it doesn't seem like the "official" method.

perma-lien

embed

parent

[]MrLumaz 1 point il y a 4 ans

At what point do you enter that? Note: I'm a noob.

perma-lien

embed

parent

[]Beegee773012/06/2012 Arrival 1 point il y a 4 ans


Assuming you copied the files in the tar.gz to your /usr/lib/python2.6 folder, type

Cd /usr/lib/python2.6

Sudo ./pifm sound.wav

perma-lien

embed

parent

[][effac] il y a 3 ans

[deleted]

[]Beegee773012/06/2012 Arrival 2 points il y a 3 ans

I haven't used my Pi for a while, but did you chmod 777 the folder?

perma-lien

embed

[]Mega1mpact 2 points il y a 4 ans

I don't think anyone will notice this post but I'l give it a try. I made a small hack for
this program that allows you to change the channel. Source:
http://pastebin.com/EWw0iMXT Screen: http://ezyimg.com/0DDX84 I hope that this
helps out in your Raspberry Pi adventures :)

perma-lien

embed

[]parkerlreed 2 points il y a 4 ans

I noticed! :D

But somebody beat you to it.


http://www.reddit.com/r/raspberry_pi/comments/14k5o3/raspberry_pi_fm_transmitter
_with_no_additional/c7efamt :(

perma-lien

embed

parent
[]try_again_ian 2 points il y a 3 ans

I'm definitely very late to this party, but just in case OP still checks this thread, I'd like
to ask a question. I'm having a lot of difficulty playing .wav files. The one that I
downloaded with PiFm (sound.wav) just outputs one solid tone to my radio. When I
try playing other .wav files I get the exact same tone. I looked at the specifications for
.wav files with PiFm and it does call for 16 bit mono 44.1 kHz, but is all that very
strict. The wav files I'm trying to play are 16 bit mono but 16 kHz, so I don't know if
that matters. Also I noticed sound.wav is 22050 Hz, so I don't know why I'm getting
this problem. Another note, I do not have an attached antenna, I'm just using RPi's
base hardware with PiFm.

perma-lien

embed

[]londons_explorer[S] 2 points il y a 3 ans

Hmm... This is odd...

If the sound file that comes with the download isnt working then there is something
up with PiFm itself, not the audio file formats.

From your message, this is the bahaviour I would expect:

When you power up the PI, you hear fuzz on the radio.

When you run PiFm with any sound file, and then press Ctrl+C, you hear
silence on the radio.

If the above facts are not true then you should choose a different FM frequency -
something else is transmitting on your chosen frequency with more power than you!

Another possible cause for this is some odd behaviour I have seen with apps that play
real sound (ie. through the headphone jack). The real sound hardware uses some of
the same timers PiFm uses, and they may interfere. I suspect you must use PiFm
before you play any sound - best to reboot the Pi and try straight away. Beware any
startup sound or anything.

perma-lien

embed

parent

[]TheCommie 1 point il y a 3 ans

I have the same problem, and both of the facts above are true. Im using the standard
sound file. Are you still checking the thread?
I have tried 130.0 as well.

perma-lien

embed

parent

[]londons_explorer[S] 2 points il y a 3 ans

Hmmm...

I suspect the cause is because there is a buffer underrun. Basically the problem is the
CPU has for some unknown reason filled an audio buffer with DMA commands, and
then stopped doing anything. That audio buffer is then playing, but when it gets to the
end the CPU hasn't put in any more audio data, so it replays again and again and
again. That replaying is causing a constant tone.

Did you recompile pifm or are you using the binaries provided? PiFm worked with
my compiler settings (which was all optimisation off IIRC), but it is entirely possible
I left a "volatile" off a variable somewhere causing the above bug. Such a bug would
only be triggered by certain compilers and compiler options.

Reply to this sometime after Monday and I shall check with my pi that the binaries in
the tar work. If you compiled it yourself, post the options and version of gcc you used
and I'll check if that works too.

perma-lien

embed

parent

[]TheCommie 1 point il y a 3 ans

I used the binary. What settings should i use to compile?

perma-lien

embed

parent

[]londons_explorer[S] 2 points il y a 3 ans

Hmm... I retested on my Pi with the binary and default sound from:


http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_
Transmitter
With linux 3.2.27+ as provided with Raspbian, and it worked. I'm connecting via ssh
and don't have the desktop enabled. What's your setup?

If you use this command to generate a sound file: dd if=/dev/zero of=sound.wav


bs=1M count=1

And then try to play that sound, do you still hear the tone?

perma-lien

embed

parent

[]TheCommie 1 point il y a 3 ans

Using Wheezy uname -r returned: '3.6.11+' Im running headless with ssh, no X


running Using the zero file gave the same tone. Changing the sample rate changes the
pitch on the radio.

perma-lien

embed

parent

[]londons_explorer[S] 1 point il y a 3 ans

Hmm... I think I know whats going on... You are hearing the correct output, but the
sample rate is massively too slow.

To confirm my theory: Play the default sound file. The program should appear to hang
and then terminate after 2 min 20 secs. If it does not, try creating a sound with this
command:

dd if=/dev/zero of=sound.wav bs=2000 count=1

Then try playing that. Does the program now run for a short time and then quit itself?
If it does, can you try to find the number to set "bs" to to make the program run for 10
seconds? That should help me track down what sample rate is being used, and
therefore which clock setting was changed.

My theory is that either:

Some linux kernel driver or bit of the graphics firmware has reconfigured
either the priority of the DMA unit or the clock rate of the signal clocking the
serializer module (that I use for timing).
I am running the serializer module 10x faster than the datasheet says it will
work at - it's possible some chips can't keep up and are skipping most of the
clock cycles, making them look really slow. If the behaviour changes with
temperature then this is almost certainly the case.

As a workaround, you might try using a super high sample rate - like 30x the real
sample rate and see what happens.

perma-lien

embed

parent

[]TheCommie 1 point il y a 3 ans

I tried running the default sound, (starwars) it ran for 7m41s when i quit it. This
worked more or less, i could recognize the song: http://pastebin.com/raw.php?
i=dQgzSEa9 bs=7215 = 10s: http://pastebin.com/raw.php?i=6ynrWW6H

perma-lien

embed

parent

[]amitabhsaran 1 point il y a 3 ans

Hi, Thanks for the great work..

I tried to setup my RPi as a FM transmitter and i faced the same problem ("one solid
tone from the radio instead of the song")

I am now able to hear the default sound.wav file as suggested below by "The
Commie" using command - sudo ./pifm sound.wav 106.0 10000000.

But i am not able to hear other audio files. Is there a new version of "pifm" that can
resolve this problem?

Also can i play .mp3 file? I tried playing .mp3 file also but again some garbled noise
is coming.

Thanks in advance for providing any solution..

perma-lien

embed
parent

[]londons_explorer[S] 1 point il y a 3 ans

Since lots of people are having this issue, I shall try to resolve it. Give me a few days.
I'm suspecting the problem might be quite in-depth, and the fix might break other
things on the system (like audio out or the sd card) unless I'm careful.

perma-lien

embed

parent

[]ha1o2surfer 2 points il y a 4 ans

For someone who does not know how this can even work.. how does this work with
no additional hardware??

perma-lien

embed

[]TSwift13 3 points il y a 4 ans

Click the link and read the section where it says

The details of how it works

perma-lien

embed

parent

[]ha1o2surfer 2 points il y a 4 ans

oh I did! lol I just am not sure what band a spread-spectrum signal generator runs at.
Just curious if 100MHZ fm is out of band for what it was designed to do.

perma-lien

embed

parent

[]londons_explorer[S] 2 points il y a 4 ans


It certainly is! The specification sheet says it works at no more than 25Mhz. We are
putting 500Mhz into it... Yet somehow it works.

I guess it only guarantees to be glitch free and work perfectly at 25Mhz, but if it
misses a clock cycle occasionally we don't really care, so we can fairly safely push it
way above its operational limits.

perma-lien

embed

parent

[][deleted] 0 point il y a 4 ans

Just a note to everyone...

This is illegal in pretty much every country in the western world. If you are going to
do this try and stick to bands where it is allowed to run transmitters without a licence.

For the UK 27MHz and 49MHz are available. And in the UK if you can get it on
26.60125 to 27.99125 in 10kHz steps you can listen to it on a CB radio.

For the love of god don't go into any of the amateur bands without a license or they'll
go apeshit.

perma-lien

embed

[]pelrun[] 4 points il y a 4 ans

If it was completely illegal, then commercial devices to transmit audio to your car's
radio wouldn't be available. There is usually a specific exemption to allow low power
broadcasts - with a range of only 50m, this certainly falls into that category.

perma-lien

embed

parent

[][deleted] -2 point il y a 4 ans

Those devices have to be CE certified in the UK and I suspect the FCC will also have
similar requirements.

perma-lien
embed

parent

[]pelrun[] 5 points il y a 4 ans

Any electronic device sold in the EU has to be CE certified, that's not the constraining
requirement.

In general radio spectrum licensing specifies what modulations and power outputs can
be used in what bands, and what the licensing requirements are. Licenses apply to
operators, not pieces of equipment; and you don't need to apply for a license to
operate a car fm transmitter (at least not in the western countries we're in) because
there's a specific license-free class for low-power FM broadcasts in that band.

perma-lien

embed

parent

[][deleted] -1 point il y a 4 ans

However for private individuals it is only amateur radio operators above a certain
license level who can legally build their own equipment and use it to transmit with.

you don't need to apply for a license to operate a car fm transmitter (at least not in the
western countries we're in) because there's a specific license-free class for low-power
FM broadcasts in that band.

Correct however the bit you miss is that the only transmitters that are legally allowed
to be used in that band for that purpose have to be CE certified which something
you've built at home isn't going to be. Please point me to the legislation that states
otherwise.

perma-lien

embed

parent

[]pelrun[] 3 points il y a 4 ans

However for private individuals it is only amateur radio operators above a certain
license level who can legally build their own equipment and use it to transmit with.

That's how the amateur license is structured; but that requirement doesn't extend
outside the amateur bands.
I'm not going to point at specific legislation; these things can vary at the country level,
and I don't live in the EU. That said, it's broadly coordinated by the ITU, which most
countries are members of.

perma-lien

embed

parent

[]LeoPanthera 1 point il y a 4 ans

It's illegal on the CB band (in the UK), since only pre-approved transmitters may be
used.

perma-lien

embed

parent

[]deadken 1 point il y a 4 ans

Ha! This reminds me of using an old TRS-80 back in the day. There were some
commercial games which used roughly the same method.

perma-lien

embed

[]cybergibbons 1 point il y a 4 ans

Surely it was AM? Spread spectrum PLL modulation hasn't been around long.

perma-lien

embed

parent

[]bradn 1 point il y a 4 ans

Yep, it would have been AM.

Actually it's fascinating to listen to old computers on an AM radio, you can actually
hear them thinking, and you get different sounds when different loops of program
code execute.
perma-lien

embed

parent

[]BrassMinkey 1 point il y a 4 ans

This is great!

The first time I ran it I was logged in through TightVNC and there were some really
weird pitch variances, as I assume the sample rate was being varied with processor
load.

Running it through PuTTY with nothing else happening on the machine gave me
much better results.

perma-lien

embed

[]londons_explorer[S] 1 point il y a 4 ans

At the moment it requires 100% of the cpu to play stuff back. Give it any less and it
will slow down and glitch.

If someone is smart they can implement a DMA based version to fix it.

perma-lien

embed

parent

[]playaspec 1 point il y a 4 ans

This is genius. I started digging into using the composite video output for SDR, but
the GPU is somewhat of a black box.

perma-lien

embed

[]F8FTK 1 point il y a 4 ans

Awesome work. In your newer code, what does 1400 stand for in the following
statement?

int clocksPerSample = 22500.0/samplerate*1400.0;


I guess it's related to the frequency of the PWM clock driving the DMA transfers,
but... Is it an exact or approximate value? Was it determined using the docs or
experimentally?

perma-lien

embed

[]salat99 1 point il y a 4 ans

Could you program an APRS trx (144,8 Mhz)?

perma-lien

embed

[]F8FTK 1 point il y a 4 ans

Broadcom's spec mentions 125 MHz as the upper limit for proper clock operation.
However for me it works well on 145 MHz apparently. Therefore APRS TX should be
possible, I may investigate this at some point. RX is another story though.

perma-lien

embed

parent

[]a_trojan 1 point il y a 4 ans

looking for help. From India and tried running with the value 25.0 on line 127 reduces
to 15.0 . I can here the song playing on 100MHz but with a lot of noise.

Is there anything I'm missing ??

electronics noob

perma-lien

embed

[][deleted] 1 point il y a 4 ans

This is brilliant. I'm suddenly compelled to pitch a tent on Rockall and start a pirate
radio station.

perma-lien
embed

[]jyf 1 point il y a 3 ans

i just want to know if it could generated wave in 18hz? is it a evil thought?

perma-lien

embed

[]londons_explorer[S] 1 point il y a 3 ans

Yes. It could transmit 18 hz audio, but most receivers won't receive stuff at such low
frequencies...

perma-lien

embed

parent

[]screwthat4u 1 point il y a 3 ans

This is amazing... it's a fucking gpio guys

perma-lien

embed

[]londons_explorer[S] 1 point il y a 3 ans

:-)

perma-lien

embed

parent

[]Wizzer10 1 point il y a 3 ans

Okay. Total noob over here. By "plain wire to GPIO 4," what do you mean? So I
guess GPIO 4 is the 4th GPIO port but what do you mean by plain wire? Do you
mean jumper wire? M-F? F-F? M-M? Would it need stripping? Any help much
appreciated.

perma-lien
embed

[]londons_explorer[S] 2 points il y a 3 ans*

begin with nothing connected.

You should find it works fine.

If you want more range, a F-F wire jumper about 10 cm long connected to the 4th one
from the left, bottom row: http://elinux.org/images/6/61/RPi_P1_header.png

You dont need anything connected to the other end of the jumper - the jumper itself
acts as the antenna.

In fact, due to a quirk of physics, connecting the wire to pretty much any pin still
extends the range...

perma-lien

embed

parent

[]matze5800 1 point il y a 3 ans

I'm using this for a private music radio since a few months, it's awesome and works
with a decent quality. Thanks a lot for this! :)

Is there any developement going on? Is it possible to have it transmitting in stereo or


maybe build a fm transmitting alsa driver?

Also it seems to randomly crash my pi after a few hours of transmitting, is there any
way of stop it from doing that? It's not a big matter as i have a second pi which
reboots the transmitting pi when it stops responding to ping requests but of course this
is not the way it should be done.

perma-lien

embed

[]londons_explorer[S] 1 point il y a 3 ans

ble to have it transmitting in stereo

Someone else in this thread has successfully done this. It involves pre-generating the
stereo signal though, but I bet with work you could do it realtime.

Is there any developement going on?


No. I'm vaguely working on an extension to transmit any signal (ie. not just FM) via a
GNU radio extension with a sampling rate of 250Mhz, but only if I get time. If you
want to work on it, then by all means go for it!

it seems to randomly crash my pi after a few hours

This could be for many reasons. There could be hardware issues - the IO pin and
clock spread spectrum hardware is changing state much quicker than it was designed
to (by a factor of 5!), and as such it could cause localized heating within the chip.

The software also does quite a lot of unsafe things. It relies on DMA operations on
memory in userspace, which itself relies on the physical to virtual mapping of that
memory never changing. If the system ever gets short of RAM, it may try to page out
that stuff, and use the RAM for another program but the DMA controller will be still
operating which will cause it to do random stuff, probably erase or copy random
memory...

Basicly, this is a hack and bodged in so many ways that it could be any of them
failing...

perma-lien

embed

parent

[][effac] il y a 3 ans

[deleted]

[]londons_explorer[S] 2 points il y a 3 ans

open the song in ausacity (free), and save as wav. in options somewhere there is a
setting what to use - just make sure its set to 22khz, 16 bit mono.

perma-lien

embed

[][effac] il y a 3 ans

[deleted]

[]londons_explorer[S] 1 point il y a 3 ans

put all the commands on one line seperated by semicolons, like so:

sudo ./pifm hello.wav; sudo ./pifm moo.wav; sudo... etc.


thats a bit of a bodge, but should do what you want. You can write all the commands
in a text editor and then copy and paste to the console as well (for that you don't even
need the semicolons - newlines have the same effect).

perma-lien

embed

[][effac] il y a 3 ans

[deleted]

[]londons_explorer[S] 1 point il y a 3 ans

You could make it broadcast when the pi is powered up...

run this command:

sudo nano /etc/rc.local

Then you are in a basic text editor. The last line usually says "exit". Above that, on a
new line, type the command you want to run in brackets followed by and & sign. Like
this:

( sudo /home/pi/pifm /home/pi/music.wav; sudo /home/pi/pifm /home/pi/music2.wav;


sudo /home/pi/pifm /home/pi/music3.wav ) &

Then save and exit by pressing "Ctrl X" and pressing enter. Beware that (as above)
you must use full paths to all your files. If you are on the console, type "pwd" to find
the full path to the folder you are in.

perma-lien

embed

[][effac] il y a 3 ans

[deleted]

[]londons_explorer[S] 1 point il y a 3 ans

When its running you can ssh back in and go into that file and remove the line and
reboot...

or you could probably kill pifm by typing "sudo killall pifm" on the console to end the
pifm program.

Many ways.....
perma-lien

embed

[][effac] il y a 3 ans

[deleted]

[]londons_explorer[S] 1 point il y a 3 ans

No idea sorry - never used it...

perma-lien

embed

continuer ce sujet

[]pettefar 1 point il y a 3 ans

Is it possible to use a microphone as a sound source instead of a sound file? I am


interested in making a ham radio FM transmitter on 145MHz (yes, I am a ham! -
m0NjP)

There is some talk about an RPi SSB Tx too.

perma-lien

embed

parent

[]londons_explorer[S] 1 point il y a 3 ans*

I'm pretty sure there is, yes.

I don't know exactly how to do it, but the pifm program accepts a stream on standard
input.

So a command like this ought to do the trick:

arecord -d0 -c1 -f S16_LE -r 22050 -twav -D copy | ./pifm - 145.0

You might have to set up arecord as shown here. I guess you'll need some USB
microphone because the pi doesn't have a mic input.

I dunno how the 145 Mhz range works, but bear in mind as it stands the Pi will
transmit FM, with pre-emphasis of high frequencies, time constant 50us, and a total
bandwidth around 75Khz. If you need anything else, you will have to modify the
source code, which should be quite easy. Ask if you need a hand.

If you connect an amplifier to the output pin, make sure you also band-filter the
output, since it contains a lot of harmonic frequencies, which would become
problematic if you chose to amplify the signal.

perma-lien

embed

parent

[]foxh8er 1 point il y a 4 ans

HOLY FUCKING SHIT THAT IS COOL.

I think you've just sold me on an RPi. As a beefier ARMputer that I can use for
arduino-like tasks.

perma-lien

embed

blog

about

code source

Publicit

emplois

rgles du site

FAQ

wiki

rediquette

transparence

contactez-nous

Reddit pour iPhone


Reddit pour Android

site mobile

boutons

reddit gold

carte cadeau reddit

L'utilisation de ce site implique que vous acceptiez nos Accord d'utilisation et Privacy
Policy (updated). 2017 reddit inc. Tous droits rservs.

REDDIT and the ALIEN Logo are registered trademarks of reddit inc.

Advertise - technology

Вам также может понравиться