SkillAgentSearch skills...

PiFunk

PiFunk Radio Transmitter - with FM/AM-Modulation for HAM-Bands (CB 27 & PMR 446)

Install / Use

/learn @wodowiesel/PiFunk

README

README

alt text

PiFunk Radio Transmitter - with FM/AM-Modulation for HAM-Bands

Early Experimental!

(WIP - Work in Progress)


Configurations

  1. Download Linux-Pi-Distribution

Raspbian Buster lastest (Full) >= v4.19.97+

or use the extra provided imager and extract and load bootable image on SD-card via Rufus

  1. Get this program:

sudo apt-get install git via git or download it on the page as .tar.gz

sudo git clone https://www.github.com/wodowiesel/PiFunk

  1. Configurations

To configure the Pi modules via menu (I2C, ALSA-Audio, UART etc.): sudo raspi-config

  • Not recommending to use w1-protocol at the beginning (i don't need it in my setup)

Using w1-gpio sometimes needs a 4.7 - 10 kΩ pullup resistor connected on GPIO-Pin

1-Wire by default BCM4 setting needs to be activated in boot-config for additional autostart

if you like to you can install wiringpi

via sudo apt-get install wiringpi

(if you have problems while transmission deactivate 1-wire config, default should be off!)

  1. Adding parameters:

Manually open with nano-editor:

sudo nano /boot/config.txt (i provide one too)

check/add lines:

dtoverlay=i2c1-bcm2708 for Pi1, Pi4: 2711 for using I2C Bus

dtoverlay=gpiopin=4,pullup=0 add pullup=1 or w1-gpio if needed

dtoverlay=audio=on for bcm-alsa-audio required!

optional:

dtparam=spi=on for SPI support optional

enable_uart=1 for UART RX & TX remote control

init_uart_baud=9600 data transmission rate for serial data

dtoverlay=pps-gpio,gpiopin=18 for GPS-device pps (puls-per-second)-support

Add PPS to autostart boot process:

sudo nano /boot/cmdline.txt

bcm2708.pps_gpio_pin=18 It must be on the same line, not on a new line

Sync to GPS 1-PPS signal for Pi PCM-Clock (PIN 12 / GPIO 18 = PCM_CLK / PWM0) or RTC for accuracy

sudo nano /etc/modules opens modules.conf with text editor (provide one too)

pps-gpio Add this line at end of the list

  1. Save your changes with ctrl-o <return/enter> then exit with ctrl-x and reboot

sudo lsmod | grep pps to check the loaded modules

output be like:

pps_gpio 2529 1 and pps_core 7943 2 pps_gpio

To run the pps command:

sudo ppstest /dev/pps0 it should fetch the data and print it


Installations

  1. First update & upgrade system:

sudo apt-get update for system updates

sudo apt-get upgrade for system upgrades

  1. You will need some libraries for this:

a) sudo apt-get install libraspberrypi-dev raspberrypi-kernel-headers i2c-tools for Kernel & Firmware

b) sudo apt-get install libsndfile1-dev for ALSA SND-lib

or download it directly SND

c) sudo apt-get install python3-dev for py3

d) RPi.GPIO lib v0.7.0+ for Py3 (also in repo)

RPi.GPIO Project Site

RPi.GPIO Sourceforge-Site

or download via terminal: sudo wget https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.7.0.tar.gz

then extract: tar -xvf RPi.GPIO-0.7.0.tar.gz or a later version

and install it: sudo pip-3.7 install RPi.GPIO for Py3 (easiest way)

or alternative way: sudo apt-get -y install python3-rpi.gpio

e) Check i2C Bus: sudo i2cdetect -y 1

  1. Compiler installation:

a) GNU C Compiler GCC sudo apt-get install gcc-9.2.0 or g++

b) GNU Debugger GDB sudo apt-get install gdbserver

  1. sudo reboot then reboot to apply the changes

Builds

  1. Navigate to directory:

a) cd PiFunk with default path: /home/pi/PiFunk/

b) GCC Compiler flags:

You can use this flags in your makefile or directly in your terminal if you prefer it manually

GCC Flags

-g3 for normal GNU compiler debug informations (1-3 level, 2 is default)

-ggdb3 for GNU debugger informations level 3

-pg for GNU Profiler (gprof) informations

-Q Prints function names & shows statistics about compilation passes

-O3 for optimization stage 1-3 (memory, speed etc.) via compiler

-Wall for debug all warning informations

-pedantic-errors for error console messages if problem between c99 and gnu extensions

-v Print compilation verbose informations

-std=c99 (as iso -std=iso9899:1999 strict)

-std=gnu99 with additional gnu extension for c99 (what i use)

(-std=gnu++17 if you like with version 11/14/17 or later)

-Iinclude for using include-directory with header files

-I/opt/vc/include/ for loading bcm headers folder-path

-Llib for using library-directory

-L/opt/vc/lib for loading bcm lib folder-path

-lgnu for loading extra gnu-lib extentions

-lm for math-lib it's obligatory!

-lbcm_host & -lbcm2835 for loading bcm firmware >= v1.20190718

-lpthread for loading process threads

-lgthread for loading graphic threads (not needed right now)

-lsndfile for loading ALSA "snd"-lib (sound)

-lpifunk for loading own pifunk lib if needed rather self-made beforehand see under b)

-shared for generating shared object (.so/.dll) libraries

-fPIC for generating position independent code (PIC) for bigger shared objects

-S (uppercase) for compiling Assembler code without linking

-c (lowercase) for compiling without linking for making object

-E for stopping after preprocessing stage in compilation

-C or CC (uppercase) for keeping the (all) comments in preprocessor

-D_USE_MATH_DEFINES for mathematical lib definitions

-D_GNU_C_SOURCE for loading GNU C Source Macros for non-std setups

(combining lot of different ones: ISO C89, ISO C99, POSIX.1, POSIX.2, BSD, SVID, X/OPEN, LFS)

-D_POSIX_C_SOURCE=200809L for POSIX2 Macros needed with bcm (or 199309L for POSIX1)

-DRASPIX defines the macro to be used by the preprocessor here the Pi model X=0-4

-> will be detected by the Makefile via the type of the ARM-Processor

(other macros possible if in the C-code implemented)

-o for individual output-filename flag

  1. Generating libraries:

a) Automatic compilation

sudo make Using Makefile

Image of the GCC Flow-diagram for generating Libraries

*.c(pp)=C-code, *.h(pp)=headerfile, *.S=assembler-code,

*.i=assembled preprocessor C-code, *.s=preprocessed assembler-code,

*.o=compiled object, *.lib=static library, *.a=static archive, *.so=shared object, *.dll=dynamic linked library

*.out=default binary (program), pifunk(.bin)=executable binary

b) manually compiling/linking libraries:

  1. sudo gcc pifunk.c -w -Q -std=gnu99 -g3 -ggdb3 -pg -Iinclude -I/opt/vc/include -Llib -L/opt/vc/lib/

-lbcm_host -lbcm2838 -lm -lpthread -lgnu -lsndfile -O3 -fPIC -D_USE_MATH_DEFINES -D_GNU_SOURCE -DRASPI1

-o lib/pifunk.o

  1. sudo gcc pifunk.o -w -Q -std=gnu99 -g3 -ggdb3 -pg -Iinclude -I/opt/vc/include -Llib -L/opt/vc/lib/

-lbcm_host -lbcm2838 -lm -lpthread -lgnu -lsndfile -O3 -fPIC -D_USE_MATH_DEFINES -D_GNU_SOURCE -DRASPI1

-shared -o lib/pifunk.so

c) manually compiling/linking executable binary:

sudo gcc pifunk.c -Wall -Q -std=gnu99 -g3 -ggdb3 -pg -Iinclude -I/opt/vc/include

-Llib -L/opt/vc/lib/ -lbcm_host -bcm2835 -lm -lpthread -lgnu -lsndfile -O3

-D_USE_MATH_DEFINES -D_GNU_SOURCE -DRASPI1 -o bin/pifunk

d) optional Pi-Flags:

-march=armv6l architecture version of ARM ("native" is auto option)

-mtune=arm1176jzf-s special architecture type tuning

-mfloat-abi=hard floating-point ABI to use, permissible values are: ‘soft’, ‘softfp’, ‘hard’

-mfpu=vfp virtual floating point hardware module support pi1-4, for pi2/3/4 use ‘neon-vfpv4’

-ffast-math increase speed for float ops and outside the IEEE-standard and deactivates errno-functions

e) Makefile commands:

sudo make piversion for checking your pi version via make

sudo make for compilation with pre-configured flags for compilation for all Pi's

sudo make install for installing pifunk files incl. build folder

sudo make uninstall for uninstalling pifunk files

sudo make run for running pifunk with standard predefined flags

sudo make help for starting help command of pifunk

sudo make assistant for starting step-assistant of pifunk

sudo make clean for removing binary and library files


Preparations

  1. Hardware-Setup:

a) Use (original) power supply 10 W, +5 V @ ~2 A or ~ +5 V / 500 mA via mini-USB 2.0 or 5 V Pins possible)

b) Check specifications: my Raspberry Pi B+ Rev. 1.2 @ 700 MHz / 512 MB RAM on ARM processor with driver bcm2835-v1.55

-> SoC from Broadcom depending on pi model: BCM2709, BCM2711 // BCM2835, BCM2836, BCM2837, BCM2837B0

for more infos on other boards just visit Adafruit

or Wikipedia Specifications Summary

c) Antenna to GPCLK0 (GPIO 4, PIN 7) for PWM (Pulse with Modulation)

@ 2-4 mA (max. 50 mA on ALL PINs and 16 per bank!)

  • Antenna should be grounded (see Pinout image) to prevent noise and other problems

  • For transmission you should use tested/certified antennas with mounts (BNC/SDA/PL - m/f) if possible

  • Tip: You could use just a copper wire for antenna:

CB 11 m-Band (lambda/2, 5.5 m, 216.535" in) and 70 cm-Band (PMR) (lambda(1/4), 17.0 cm, 6.7" in)

Pinout

d) You can try to smooth the Resistance R out with a 1:X (1-43)

if using long HF antenna for adapting Resistance

or use a 1:1 balun choke with a ring e.g.: FT23 (ferrite core) - 43 (diameter)

with 2x 4 turns for CB (27 MHz) to smooth the HF out

or 1:1.5 (e.g. 4:6 / 8:12) from 75 Ohm (TV-cable) to 50 Ohm conversion

You can compare the different materials for specific frequencies:

[D

View on GitHub
GitHub Stars19
CategoryDevelopment
Updated2mo ago
Forks5

Languages

C

Security Score

95/100

Audited on Jan 26, 2026

No findings