最近发现一个好玩的项目,用树莓派制作FM调频无线电发射器

github地址 https://github.com/ChristopheJacquet/PiFmRds

FM-RDS transmitter using the Raspberry Pi

This program generates an FM modulation, with RDS (Radio Data System) data generated in real time. It can include monophonic or stereophonic audio.

It is based on the FM transmitter created by Oliver Mattos and Oskar Weigl, and later adapted to usingDMA by Richard Hirst. Christophe Jacquet adapted it and added the RDS data generator and modulator. The transmitter uses the Raspberry Pi's PWM generator to produce VHF signals.

NEW: now supports any sample rate for audio files, and generates FM-Stereo signals!

How to use it?

Pi-FM-RDS, depends on the sndfile library. To install this library on Debian-like distributions, for instance Raspbian, run sudo apt-get install libsndfile1-dev.

Then clone the source repository and run make in the src directory:

git clone https://github.com/ChristopheJacquet/PiFmRds.git
cd PiFmRds/src
make

Then you can just run:

sudo ./pi_fm_rds

This will generate an FM transmission on 107.9 MHz, with default station name (PS), radiotext (RT) and PI-code, without audio. The radiofrequency signal is emitted on GPIO 4 (pin 7 on header P1).

You can add monophonic or stereophonic audio by referencing an audio file as follows:

sudo ./pi_fm_rds -audio sound.wav

To test stereophonic audio, you can try the file stereo_44100.wav provided.

The more general syntax for running Pi-FM-RDS is as follows:

pi_fm_rds [-freq freq] [-audio file] [-ppm ppm_error] [-pi pi_code] [-ps ps_text] [-rt rt_text]

All arguments are optional:

  • -freq specifies the carrier frequency (in MHz). Example: -freq 107.9.
  • -audio specifies an audio file to play as audio. The sample rate does not matter: Pi-FM-RDS will resample and filter it. If a stereo file is provided, Pi-FM-RDS will produce an FM-Stereo signal. Example: -audio sound.wav. The supported formats depend on libsndfile. This includes WAV and Ogg/Vorbis (among others) but not MP3. Specify - as the file name to read audio data on standard input (useful for piping audio into Pi-FM-RDS, see below).
  • -pi specifies the PI-code of the RDS broadcast. 4 hexadecimal digits. Example: -pi FFFF.
  • -ps specifies the station name (Program Service name, PS) of the RDS broadcast. Limit: 8 characters. Example: -ps RASP-PI.
  • -rt specifies the radiotext (RT) to be transmitted. Limit: 64 characters. Example: -rt 'Hello, world!'.
  • -ctl specifies a named pipe (FIFO) to use as a control channel to change PS and RT at run-time (see below).
  • -ppm specifies your Raspberry Pi's oscillator error in parts per million (ppm), see below.

By default the PS changes back and forth between Pi-FmRds and a sequence number, starting at00000000. The PS changes around one time per second.

Clock calibration (only if experiencing difficulties)

The RDS standards states that the error for the 57 kHz subcarrier must be less than ± 6 Hz, i.e. less than 105 ppm (parts per million). The Raspberry Pi's oscillator error may be above this figure. That is where the -ppm parameter comes into play: you specify your Pi's error and Pi-FM-RDS adjusts the clock dividers accordingly.

In practice, I found that Pi-FM-RDS works okay even without using the -ppm parameter. I suppose the receivers are more tolerant than stated in the RDS spec.

One way to measure the ppm error is to play the pulses.wav file: it will play a pulse for precisely 1 second, then play a 1-second silence, and so on. Record the audio output from a radio with a good audio card. Say you sample at 44.1 kHz. Measure 10 intervals. Using Audacity for example determine the number of samples of these 10 intervals: in the absence of clock error, it should be 441,000 samples. With my Pi, I found 441,132 samples. Therefore, my ppm error is (441132-441000)/441000 * 1e6 = 299 ppm, assuming that my sampling device (audio card) has no clock error...

Piping audio into Pi-FM-RDS

If you use the argument -audio -, Pi-FM-RDS reads audio data on standard input. This allows you to pipe the output of a program into Pi-FM-RDS. For instance, this can be used to read MP3 files using Sox:

sox -t mp3 http://www.linuxvoice.com/episodes/lv_s02e01.mp3 -t wav -  | sudo ./pi_fm_rds -audio -

Changing PS and RT at run-time

You can control PS and RT at run-time using a named pipe (FIFO). For this run Pi-FM-RDS with the -ctl argument.

Example:

mkfifo rds_ctl
sudo ./pi_fm_rds -ctl rds_ctl

Then you can send “commands” to change PS and RT:

cat >rds_ctl
PS MyText
RT A text to be sent as radiotext
PS OtherTxt
...

Every line must start with either PS or RT, followed by one space character, and the desired value. Any other line format is silently ignored.

Warning and Diclaimer

Never use this program to transmit VHF-FM data through an antenna, as it is illegal in most countries. This code is for experimental purposes only. Always connect a shielded transmission line from the RaspberryPi directly to a radio receiver, so as not to emit radio waves.

I could not be held liable for any misuse of your own Raspberry Pi. Any experiment is made under your own responsibility.

Tests

Pi-FM-RDS was successfully tested with all my RDS-able devices, namely:

  • a Sony ICF-C20RDS alarm clock from 1995,
  • a Sangean PR-D1 portable receiver from 1998,
  • a Samsung Galaxy S2 mobile phone from 2011,
  • a Philips MBD7020 hifi system from 2012,
  • a Silicon Labs USBFMRADIO-RD USB stick, employing an Si4701 chip, and using my RDS Surveyor program,
  • a “PCear Fm Radio”, a Chinese clone of the above, again using RDS Surveyor.

Reception works perfectly with all the devices above. RDS Surveyor reports no group errors.

CPU Usage

CPU usage is as follows:

  • without audio: 9%
  • with mono audio: 33%
  • with stereo audio: 40%

CPU usage increases dramatically when adding audio because the program has to upsample the (unspecified) sample rate of the input audio file to 228 kHz, its internal operating sample rate. Doing so, it has to apply an FIR filter, which is costly.

Design

The RDS data generator lies in the rds.c file.

The RDS data generator generates cyclically four 0A groups (for transmitting PS), and one 2A group (for transmitting RT). get_rds_group generates one group, and uses crc for computing the CRC.

To get samples of RDS data, call get_rds_samples. It calls get_rds_group, differentially encodes the signal and generates a shaped biphase symbol. Successive biphase symbols overlap: the samples are added so that the result is equivalent to applying the shaping filter (a root-raised-cosine (RRC) filter specified in the RDS standard) to a sequence of Manchester-encoded pulses.

The shaped biphase symbol is generated once and for all by a Python program calledgenerate_waveforms.py that uses Pydemod, one of my other software radio projects. This Python program generates an array called waveform_biphase that results from the application of the RRC filter to a positive-negative impulse pair. Note that the output of generate_waveforms.py, two files named waveforms.c and waveforms.h, are included in the Git repository, so you don't need to run the Python script yourself to compile Pi-FM-RDS.

Internally, the program samples all signals at 228 kHz, four times the RDS subcarrier's 57 kHz.

The FM multiplex signal (baseband signal) is generated by fm_mpx.c. This file handles the upsampling of the input audio file to 228 kHz, and the generation of the multiplex: unmodulated left+right signal (limited to 15 kHz), possibly the stereo pilot at 19 kHz, possibly the left-right signal, amplitude-modulated on 38 kHz (suppressed carrier) and RDS signal from rds.c. Upsampling is performed using a zero-order hold followed by an FIR low-pass filter of order 60. The filter is a sampled sinc windowed by a Hamming window. The filter coefficients are generated at startup so that the filter cuts frequencies above the minimum of:

  • the Nyquist frequency of the input audio file (half the sample rate) to avoid aliasing,
  • 15 kHz, the bandpass of the left+right and left-right channels, as per the FM broadcasting standards.

The samples are played by pi_fm_rds.c that is adapted from Richard Hirst's PiFmDma. The program was changed to support a sample rate of precisely 228 kHz.

References

  • EN 50067, Specification of the radio data system (RDS) for VHF/FM sound broadcasting in the frequency range 87.5 to 108.0 MHz

用树莓派制作FM调频无线电发射器相关推荐

  1. 中国无线电发射器市场趋势报告、技术动态创新及市场预测

    [出版商]贝哲斯咨询 [免费目录下载]在电子和通信中,发射机或无线电发射机是一种用天线产生无线电波的电子设备.发射机本身产生无线电频率交流电,应用到天线.当被这种交流电激发时,天线就会发射无线电波. ...

  2. 如何使用树莓派制作避障机器人

    学习Arduino或者树莓派的过程中,如果仅仅看代码或者做简单实验,那么常常会虎头蛇尾,所以我们建议还是尝试一些简单的机器人项目,这样既有趣也能不断学习提高.本文将向大家展示如何使用树莓派制作简单的避 ...

  3. 55节开源巨献,教你制作一个智能无线电应答平台

           <如何制作一个智能无线电应答平台>                                             作者:BG7EJL 项目背景 目前市面上基于U/V ...

  4. 基于multisim的fm调制解调_基于multisim的fm调频与鉴频电路设计与仿真

    基于multisim的fm调频与鉴频电路设计与仿真 课程设计报告题 目基于 Multisim 的 FM 调频与鉴 频电路设计与仿真 学生姓名 学生学号 系 别 电气信息工程学院 专 业 通信工程 届 ...

  5. 51单片机FM调频收音机可存台音量可调TEA5767 STM32

    实践制作DIY- GC0095-FM调频收音机 一.功能说明: 基于51单片机设计-FM调频收音机 功能介绍: STC89C52RC系列最小系统板+TEA5767 收音机模块+LCD1602显示器+喇 ...

  6. 树莓派制作“数码显微镜”,了解一下?

    今天教大家如何利用树莓派制作一个"数码显微镜". 项目虽然是19年就有了,但是不妨碍我们学习. 这个小项目诞生的起因是作者想要一个数字显微镜,来检查他的电路板以及3D打印件. 他希 ...

  7. 【利用树莓派制作无线打印服务器】

    利用树莓派制作无线打印服务器 文章目录 利用树莓派制作无线打印服务器 一.树莓派是什么? 二.什么是CUPS 树莓派如何启用CUPS 三.电脑端如何连接树莓派打印服务器? 四.手机如何连接树莓派打印服 ...

  8. 树莓派制作遥控小车教程

    树莓派制作遥控小车教程 一.成品图 二.准备材料: 三.开始制作 1.接线 2.写程序 一.成品图 二.准备材料: 1.树莓派 2.充电宝 3.小车套件(底盘,车轮,电机,电池座) 4.导线,杜邦线 ...

  9. 树莓派制作路由器,手机连接wifi

    树莓派制作路由器,手机连接wifi 在制作之前总的介绍本文用到的包:hostapd  以及dhcp服务 hostapd- 一个用户态用于AP和认证服务器的守护进程.它实现了IEEE 802.11相关的 ...

最新文章

  1. pytorch 笔记:gather 函数
  2. Linux 下crontab简单使用
  3. Linux 下使用openSSL 生成RSA密钥对
  4. 第 6 章 Distributed File Systems
  5. linq to entity 基础
  6. python 3d大数据可视化软件_最受欢迎的大数据可视化软件
  7. 如何使用ffmpeg下载腾讯课堂视频(亲自多次尝试有效)
  8. c语言程序100例pdf,经典c程序100例源代码(全).pdf
  9. OBS视频录制及其直播推流教程(超详细,非硬核)
  10. 机器人教练SWOT分析_我国工业机器人产业发展的SWOT分析
  11. c语言输出100以内的素数存放数组中,c语言素数(c语言输出100以内素数)
  12. 【labelme】制作标签数据的完整流程
  13. 解决QFontDatabase: Cannot find font directory XXX/lib/fonts
  14. dax-自定义周做同比和环比
  15. cloudflare免费证书_新Cloudflare:免费CDN+免费SSL证书轻松搞定https
  16. Windows无法连接到打印机怎么办?快收藏这些正确做法!
  17. Opencv(C++)系列学习---opencv_contrib安装
  18. 安卓开发之 在应用中使用数据库
  19. Zimbra 8.7.11规则:只能发送内部邮件
  20. 用JAVA写一个简单的21点游戏(不设置庄主的情况下)

热门文章

  1. 【中医推荐】33部中医书籍,中医医书精品(在线免费阅读),值得珍藏的国粹,涵盖中药、针灸、推拿、按摩、拔罐、气功,食疗等诸多领域
  2. 【金猿案例展】某国家级研究所——组学大数据分析平台建设
  3. “说”——英语学习的另一转折点
  4. 文献阅读_基于线上评论的区域消费环境放心度与空间特征研究(中文文献)
  5. HTML+CSS期末作业 :个人博客网站设计(2页) 学生网页课程设计期末作业下载 web网页设计制作成品
  6. html链接打开excel,龙三公子博客-win7/10下excel表格中的文本链接如何变成可点击打开的网址链接(超链接)后又提示可打开此文件的应用程序没有注册?...
  7. vi 全局替换命令等
  8. Silverlight 4实现在线大头贴程序,支持打印
  9. python课程丶优达学城_《数据分析入门—优达学城》学习python导入数据并改正数据类型...
  10. Unity中按钮控制模型爆炸拆分的制作