电子说
在电子工程师的世界里,创新与探索永无止境。今天,我们将深入探讨 Adafruit Si4713 FM 无线电发射器,它能让你轻松变身海盗电台主播,开启属于自己的广播之旅。
文件下载:1958.pdf
Adafruit Si4713 是一款基于 Si4713 芯片的一体化立体声音频 FM 发射器,不仅能发射音频,还支持 RDS/RBDS 数据传输。通过将其连接到微控制器(如 Arduino)的 I2C 数据线,设定发射频率,再将线路电平音频输入立体声耳机插孔,就能实现音频发射。其有效传输距离约 10 米/30 英尺,使用普通 FM 接收器(如汽车或口袋收音机)就能收听。而且,它还支持 RDS/RBDS 功能,能传输文本和数据,就像一些汽车收音机显示电台和当前播放歌曲那样。搭配 Adafruit 提供的 Arduino 库、示例代码和教程,几分钟内就能让它运行起来。
该 FM 发射器芯片需要微控制器进行设置,采用 I2C 通信方式(虽支持 SPI,但文档未提供 SPI 代码示例)。所有接口输入引脚兼容 5V,可用于 3 - 5V 逻辑。
有两个 GPIO 引脚(GP1 和 GP2)可用于控制 LED 闪烁。初始状态用于设置芯片为模拟模式,复位时不要将其短接到地或 VCC,且它们仅为 3V 输出。GPIO #3 用于板载 32KHz 时钟发生器。
根据需要裁剪排针长度,将其插入面包板(长引脚朝下),便于后续焊接。
将 breakout 板放在排针上,使短引脚穿过板上的焊盘。
确保焊接所有引脚,以实现可靠的电气连接。可参考 Adafruit 的焊接指南(https://adafru.it/aTk)获取焊接技巧。
该发射器需要天线,可使用提供的 1 米长电线,也可根据需要选择不同长度的电线。将电线末端剥去几毫米,插入 ANT 孔并焊接。
Si4713 默认 I2C 地址为 0x63,可通过将 CS 连接到地将其改为 0x11,但建议先让演示程序正常运行后再进行更改。
从 Arduino 库管理器中搜索并安装 Adafruit Si4713 库,也可参考 Adafruit 的 Arduino 库安装教程(http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use)。
打开 File -> Examples -> Adafruit_Si4713 -> adaradio,上传到连接好传感器的 Arduino。可根据需要修改 FM 发射频率,默认发射频率为 102.3MHz,可将代码中的 #define FMSTATION 10230 修改为未使用的频率(频率值以 10KHz 为单位,如 88.1MHz 写为 8810)。上传代码后,打开串口监视器(波特率 9600),若看到 “RDS On!” 消息,说明一切正常。将音频输入 3.5mm 插孔,应能看到音频音量范围在 0 到 -10dB 之间。
Si4713 可扫描 FM 频段并测量输入功率,帮助找到未使用的电台频率。在 adaradio 演示程序中,找到相应部分并取消注释 for 循环,重新上传代码后查看串口监视器。数值越大,传输功率越高,应选择数值较低且周围没有高数值的频率,避免被附近频率干扰。
begin() 初始化 Si4713 芯片组,若初始化成功返回 true,否则返回 false。使用 setTXpower(txpwr) 开启电台发射,txpwr 为 dBμV 传输功率,可设置为 88 - 115dBμV 或 0(关闭)。使用 tuneFM(freq) 调谐发射频率,freq 以 10KHz 为单位。使用 readTuneStatus() 检查电台状态,可获取当前频率、功率输出和调谐天线电容等信息。readTuneMeasure(freq) 开始测量,freq 以 10KHz 为单位;然后调用 readTuneStatus() 等待芯片测量数据并将结果存储在 currNoiseLevel 变量中。beginRDS() 初始化 RDS 子系统,使用 setRDSstation("AdaRadio") 设置电台名称(最多 8 个字符),使用 setRDSbuffer( "Adafruit g0th Radio!") 发送主缓冲区数据(最多 32 个字符)。setGPIOctrl(bitmask) 设置 GPIO 引脚为输出,bitmask 为每个引脚设置 1 位。使用 setGPIO(bitmask) 设置 GPIO 输出状态。adafruit_si4713.mpy 和 adafruit_bus_device 复制到板上的 lib 文件夹或根文件系统。连接到板的串行 REPL,进入 CircuitPython 提示符。sudo pip3 install adafruit-circuitpython-si4713。可使用 received_noise_level 函数测量 FM 频段的信号质量,扫描 87.5MHz 到 108MHz 的频率范围,以 50KHz 为步长。噪声值(dBuV)越高,信号越强,一般小于 32 的值可能表示未使用的频率,大于 40 的值表示强无线电信号。
找到未使用的频率后,使用 tx_frequency_khz 属性设置发射频率(以 KHz 为单位,范围在 87.5MHz - 108MHz 且以 50KHz 为步长),使用 tx_power 属性设置发射功率(88 - 115 dBuV 或 0 关闭)。可通过读取 input_level 属性检查音频输入电平,读取 audio_signal_status 属性检查音频信号状态,确保输入电平在 -20 到 -10dB 之间,避免过调制。
使用 configure_rds 函数配置 RDS 传输,传入电台 ID、电台名称和缓冲区数据。配置后,可通过 rds_station 和 rds_buffer 属性更新电台名称和缓冲区数据。
# SPDX-FileCopyrightText: 2018 Tony DiCola for Adafruit Industries
# SPDX-License-Identifier: MIT
# Simple demo of using the SI4743 RDS FM transmitter.
import time
import board
import digitalio
import adafruit_si4713
# Specify the FM frequency to transmit on in kilohertz. As the datasheet
# mentions you can only specify 50khz steps!
FREQUENCY_KHZ = 102300 # 102.300mhz
# Initialize I2C bus.
i2c = board.I2C() # uses board.SCL and board.SDA
# Initialize SI4713.
#
# si4713 = adafruit_si4713.SI4713(i2c)
# Alternatively you can specify the I2C address of the device if it changed:
# si4713 = adafruit_si4713.SI4713(i2c, address=0x11)
#
# If you hooked up the reset line you should specify that too. Make sure
# Raspberry Pi, and probably other devices:
si_reset = digitalio.DigitalInOut(board.D5) # to pass in a DigitalInOut instance. You will need the reset pin with the
#
print("initializing si4713 instance")
si4713 = adafruit_si4713.SI4713(i2c, reset=si_reset, timeout_s=0.5)
print("done")
# Measure the noise level for the transmit frequency (this assumes automatic
# antenna capacitance setting, but see below to adjust to a specific value).
# Alternatively measure with a specific frequency and antenna capacitance.
# This is not common but you can specify antenna capacitance as a value in pF
# from 0.25 to 47.75 (will use 0.25 steps internally). If you aren't sure
# about this value, stick with the default automatic capacitance above!
# noise = si4713.received_noise_level(FREQUENCY_KHZ, 0.25)
noise = si4713.received_noise_level(FREQUENCY_KHZ)
print("Noise at {0:0.3f} mhz: {1} dBuV".format(FREQUENCY_KHZ / 1000.0, noise))
# Tune to transmit with 115 dBuV power (max) and automatic antenna tuning
# capacitance (default, what you probably want).
si4713.tx_frequency_khz = FREQUENCY_KHZ
si4713.tx_power = 115
# You can also set the broadcast station name (up to 96 bytes long) and
# broadcast buffer/song information (up to 106 bytes long). Setting these is
# optional and you can later update them by setting the rds_station and
# rds_buffer property respectively. Be sure to explicitly specify station
# and buffer as byte strings so the character encoding is clear.
si4713.configure_rds(0xADAF, station=b"AdaRadio", rds_buffer=b"Adafruit g0th Radio!")
# Print out some transmitter state:
print("Transmitting at {0:0.3f} mhz".format(si4713.tx_frequency_khz / 1000.0))
print("Transmitter power: {0} dBuV".format(si4713.tx_power))
print("Transmitter antenna capacitance: {0:0.2f} pF".format(si4713.tx_antenna_capacitance))
# Set GPIO1 and GPIO2 to actively driven outputs.
si4713.gpio_control(gpio1=True, gpio2=True)
# Main loop will print input audio level and state and blink the GPIOs.
print("Broadcasting...")
while True:
# Print input audio level and state.
print("Input level: {0} dBfs".format(si4713.input_level))
print("ASQ status: 0x{0:02x}".format(si4713.audio_signal_status))
# 'Blink' GPIO1 and GPIO2 alternatively on and off.
si4713.gpio_set(gpio1=True, gpio2=False) # GPIO1 high, GPIO2 low
time.sleep(0.5)
si4713.gpio_set(gpio1=False, gpio2=True) # GPIO1 low, GPIO2 high
time.sleep(0.5)
通过以上介绍,你是否已经迫不及待地想要动手打造自己的 FM 电台了呢?在实践过程中,不妨多尝试不同的设置和参数,挖掘 Adafruit Si4713 的更多潜力。如果你在使用过程中遇到问题或有新的发现,欢迎在评论区分享交流。
全部0条评论
快来发表一下你的评论吧 !