Skip to content

Clockgen Mod

Harry Munday edited this page Nov 8, 2024 · 22 revisions

Clockgen Mod

Previous Page CX Cards

Sub-Page RF Capture Guide

Next Page Hardware Installation Guide

Index

What is this doc?

This doc is a 1 page version of Rene Wolfs "cxadc-clock-generator-audio-adc" clockgen mod setup wiki which is flushed out with more theory, this doc focuses on the basics of what goes ware and how to actually make captures, and also features the sane use of the SMA connector, there is also a spin off of this just using wires and a Pi Pico on its own.

User Operation

Important

This Guide Assumes you have CXADC Installed and have tested your cards before starting modification of them and know the basics of capture with a CX Card, and have at least overview info about its mods.

The clockgen + ADC mod setup typically assumes external amplifiers are employed, allowing for optimal signal-to-noise ratio of the raw signal's intended to be captured without need for the CX Cards gain levels to ever be modified.

Important

C31 Mod & BNC Mod is normally recommended and assumed deployed with this mod.

Preset your CX Card settings

To avoid any worries of permissions of configuration we want to set the system to use the same config on every re-boot, to do this we use the udev rules.

/etc/udev/rules/

Inside this folder using admin privileges made place a cxadc.rules file with your desired configuration.

This example config should be ample for most users current setups.

Capture Workflow Method 1: Simple Bash Scripts

  • Direct capture creates 2 40msps files
  • Resampling uses SoX on the HiFi RF to make a 10msps 8-bit file

If your system is slow and or very low-end direct capture is the safest option if you're noticing time differences between decoded HiFi and baseband captures of HiFi for example.

Capture Script With Resampling

Synchronised capture is all scripted into a single .sh file to run it simply download it and define the output path

Example:

./cxadc-vhs-sync-capture.sh /home/harry/Desktop

The Resulting Output:

RF Output is:

xxxx.xx.xx-xx.xx.xx-rf-audio-10msps.u8

xxxx.xx.xx-xx.xx.xx-rf-video-40msps.u8

Audio is 24-bit 3 channel 46875sps (46khz) file the mapping is:

Left/Right/Headswitch

You will want to map this to 2 separate audio tracks for muxing into a final video file.

The file set is automatically date stamped yyyy.hh.dd-hh.mm.ss

Workflow Method 2: Namazso's Web Server

Tip

For 8mm users and people with mixed setups, this method allows you to pick and choose what hardware is capturing.

This web server capture workflow can be done locally on a single computer. This also allows for captures to networked storage pools, but has more reliable buffering than the direct script for lower end systems.

./local-capture.sh --add-date --video=0 --hifi=1 --convert-linear Your-Tape-Name

Important

Ensure both the script & the capture server itself has read and write permissions for the video group.

Caution

Only stop/exit with pressing q if you do CTRL + C as you would for a normal script, it will break USB audio device access and will require restarting your system.

Handling Audio

Important

Read this segment if you are confused by multiple standard audio files from long duration captures!

Combining Audio Files

For the next step to be easy and fluid captures over 1 hour long typically end up being split into multiple .wav files by the encoder for the baseband audio capture.

You can consolidate these together in an audio editor or DAW such as Ocen Audio, Audacity, Adobe Audition, iZotope RX with relative ease or you can use FFmpeg and or SoX.

SoX:

sox input-1.wav input-2.wav combined.wav

FFmpeg:

ffmpeg -i input1.wav -i input2.wav -i input3.wav -i input4.wav -filter_complex '[0:0][1:0][2:0][3:0] concat=n=4:v=0:a=1[out]' -map '[out]' output.wav

Auto Audio Align

After decoding your Video RF and or HiFi FM audio you will want to sync your PCM audio data with your video file.

With a standard configuration you just need to alter the following:

  • -i baseband.wave - Input PCM Audio File
  • --json capture.tbc.json - Input TBC JSON from decoding
  • baseband_aligned.flac - Output name at the end (also s16 will do 16-bit if s24 is replaced)

Tip

Below is premade commands for usage:

Linux & MacOS:

Stereo

"ffmpeg" -i baseband.wav -filter 'channelmap=map=FL-FL|FR-FR' -f s24le -ac 2 - | mono VhsDecodeAutoAudioAlign.exe stream-align --sample-size-bytes 6 --stream-sample-rate-hz 46875 --json capture.tbc.json --rf-video-sample-rate-hz 40000000 | ffmpeg -f s24le -ar 46875 -ac 2 -i - -af aresample=48000 -sample_fmt s32 baseband_aligned.flac

Mono

"ffmpeg" -i baseband.wav -filter_complex "[0:a]channelsplit=channel_layout=2.1:channels=FL[FL]" -map "[FL]" -f s24le -ac 1 - | mono VhsDecodeAutoAudioAlign.exe stream-align --sample-size-bytes 3 --stream-sample-rate-hz 46875 --json capture.tbc.json --rf-video-sample-rate-hz 40000000 | ffmpeg -f s24le -ar 46875 -ac 1 -i - -af aresample=48000 -sample_fmt s32 baseband_aligned.flac

Windows:

Stereo

ffmpeg -i baseband.wav -filter 'channelmap=map=FL-FL|FR-FR' -f s24le -ac 2 - | VhsDecodeAutoAudioAlign.exe stream-align --sample-size-bytes 6 --stream-sample-rate-hz 46875 --json capture.tbc.json --rf-video-sample-rate-hz 40000000 | ffmpeg -f s24le -ar 46875 -ac 2 -i - -af aresample=48000 -sample_fmt s32 baseband_aligned.flac

Mono

ffmpeg -i baseband.wav -filter_complex "[0:a]channelsplit=channel_layout=2.1:channels=FL[FL]" -map "[FL]" -f s24le -ac 1 - | VhsDecodeAutoAudioAlign.exe stream-align --sample-size-bytes 3 --stream-sample-rate-hz 46875 --json capture.tbc.json --rf-video-sample-rate-hz 40000000 | ffmpeg -f s24le -ar 46875 -ac 1 -i - -af aresample=48000 -sample_fmt s32 baseband_aligned.flac

Alsamixer

Sample rate modes are the following:

28.63msps, 20msps, 40msps, 50msps

To open the terminal control window use:

alsamixer 

Press F6

Navigate with & keys.

Hit Enter with CXADC+ADC+ClockGen selected.

Press Space to enable audio control.

That is about it, you only play with these settings when doing manual overrides for stock settings.

Setup

Software Setup

Install asmixer

sudo apt install asmixer 

Run alsamixer with:

alsamixer

Fix Capture Script Permissions

chmod +x cxadc-sync-capture.sh

Pi Pico Firmware Flashing

Test Firmware / Clock Gen Firmware / Reset Firmware

  1. Ensure Pi Pico is not plugged into the mainboard of the clockgen.

  2. Equip a USB-C or Micro-B cable depending on your Pi Pico Type.

  3. The Pi Pico displays as a USB storage device if working.

  4. Simply drag and drop the test firmware onto the filesystem and it will automatically flash

Note

If the unit blinks then its all good to reset and proceed.

Note

To reset an Pi Pico Hold the button on it while unplugged then plug into usb, and use the flash_nuke.uf2 file to reset it to clean.

After a successful flashing, the Pi Pico will show up as a microphone 3ch 48khz device to any systems sound manager application.

USB Connection

Internal USB headers can be used for the data connection to the Pi Pico

Normally PC's and Servers have internal USB 2.0 header's for basic devices.

Shielded Case & Bracket

As the audio ADC is unbalanced, and the clock gen board is sensitive to EMI due to high frequency clock signals being generated its recommended to shield the setup.

You can print a PCI bracket or you can drill out metal brackets.

Copper Tape + 3D Printed Case

Debugging

Software Debugging

Check USB Devices with

lsusb

Check PCI & PCie Devices with

lspci

Device Busy

Test

arecord -D hw:CARD=CXADCADCClockGe -c 3 -r 46875 -f S24_3LE --samples=1000 test.wav

Result

arecord: main:831: audio open error: Device or resource busy

Solution:

Restart, try again

Hardware Debugging

  • PC Wont boot

This can be 2 key issues, bad SMA cable, or bad jig.

The Jig boards for the CX Cards are very sensitive, if a board is damaged or component then the board will not work.

Solution:

Reflow parts, if fail use another board, or replace all SMD components on PCB Jig.

Hardware Fabrication & Setup

Direct PCB Fab - Here's the Gerber's

I like PCBway but you can use JLCPCB or any domestic fab house or make them at home even have fun!

Is it worth using a PCB fab to populate parts?

No not really doing it yourself is very easy and the price of having 2 boards populated, you can buy the tools and learn a invaluable skill, or if would like to support the work and save some time then you can order the pre-made boards off Harry's Kofi-Store.

Cables:

  • 2x 50Ohm SMA to SMA 30-50cm Cable
  • 1x 50Ohm SMA to BNC bulkhead 30-50cm.
  • 2x BNC to BNC 50Ohm cables (Video RF + HiFi RF)
  • 1x RCA or XLR to RCA cable (Linear or HiFi Ref)

Tools:

It's worth reading the Hardware Installation Guide as this fully covers what tools are recommneded to build boards and do RF Tappping!

  • 3rd Arm Clip Holder or Vice Clamp
  • Soldering Iron / Bevel Type Tip
  • 60/40 Leaded Solder (i.g Silverline or equivalent)
  • Side Cutters
  • 99.9% IPA
  • Desoldering Gun or ENGINEER SS-02 Solder Sucker
  • Desoldering braid

Parts:

  • C - Capacitor
  • D - Diode
  • R - Resistor

Part Sizes

  • SMA's are edge mount style connectors.
  • SMD SOD-123 - Diodes
  • 0805 SMD - Resistor & Capacitor

Deployed Clockgen

(With 3D printed bracket & metal drilled bracket)

Jig Modified CX Card

Important

Ensure that the 3 parts C22, R12, C19 below the crystal package are removed.

Front & Back

Heatsinks

Important

Ensure orientation of opening fins are suited for the airflow of your case/fan setup.

L 40mm X W 40mm X H 11mm heatsinks are readily available.

Amazon UK Silver / Black

AliExpress Black / Silver

Jig Board

Tip

You can order pre-assmbled jigs or bare PCBs here!

Warning

Ensure all parts are populated in the correct orientation as shown in the image below.

  • J30: SMA Edge Mount
  • C1: 1.5 nF (6V or greater, ceramic X5R or X7R)
  • C2: 10 nF (6V or greater, ceramic X5R or X7R)
  • R1: 1K Ohm (5% tolerance or better)
  • R2: 1K Ohm (5% tolerance or better)
  • R3: 10K Ohm (5% tolerance or better)
  • 2mm thick 25mm wide double sided foam tape.
  • 26AGW wire in 4 colours Link

Caution

This PCB when connected to a CX Card will be under tension, ensure strong adhesive tape is used or use glue/epoxy and ensure both surfaces are cleaned with 99.9% IPA and dry before adhering.

Mainboard

Tip

You can order pre-assembled mainboards or bare PCBs here!

Warning

Always check via line indicator on SMD ports the polarity of diodes are in-line with indicator on PCB

Gen 2 PCB using SMA for Headswitch input and 2 clock lines, compatible with the original 3D printed case.

There is 3 off shelf boards used for this:

AliExpress is most likely the cheapest place to source these but are very available on Amazon and other vendors globally.

  • Raspberry Pi Pico as the interface and control board via USB (Clockgen PCB is based around the 1st party green PCB but you can use Micro-USB or USB-C port versions)

  • Adafruit Si5351A for generating the shared clock source with 5 potential inputs.

  • PCM1802 PCB ADC for L/R input baseband Linear or HiFi audio capture.

Parts:

  • SMA Edge Mount (On Headswitch/Ground Pads)
  • C1: 10 µF
  • R1: 1K Ohm
  • D1: 3.3V zener diode
  • D2: Generic switching diode

Sockets:

Header Socket Pin Size: 2.54mm

  • U1: 2x 20-pin Header Socket (Pi Pico)
  • U2: 1x 9-pin Header Socket (PCM1802)
  • U3: 1x 7-pin Header Socket (Si5351A)

Board Parts:

  • 1x Audio Cable (A 1m XLR cable is ideal as its shielded)
  • 1x Pair of RCA or TRS audio connectors.
  • 1x Small Zip-Tie or Cable-Tie (to secure audio line)

Interface:

  • USB 2.0 Internal to Type-A or to Micro-B (or USB-C) cable

Secondary:

  • BNC Bulkhead to SMA
  • Copper Tape
  • Electrical Tape
  • Heatshrink (optional)
  • Metal PCI Bracket & Step Drill Bits (or 3D printer and filament)

Note

The Si5351A kit headers are not recommended for socketed connectors, its recommended to solder headers then the board to said 2.54mm headers directly to ensure a secure connection.

PCM1802 Board

Caution

Ensure all parts are populated on the PCB as shown in the top-down photo below if parts are missing you will have issues!

Note

The PCM1802 Board requires a bodge wire bypass mod in most cases if 3.3v lines are not connected, its always good to test with a multi-meter if possible.

Parts

  • PCM1802 Board
  • 8Pin 2.54mm Headder

MODE0 with 3.3v Bridge Mod

Grounding The PCM to shield

Insulating & Shielding the RCA connections

Tip

When soldering the ground the the RCA lugs you can have it slightly shorter to sang proof the cable so no tugging or tension is on the signal wires.

Finished

Page End

Previous Page CX Cards

Sub-Page RF Capture Guide

Next Page Hardware Installation Guide

Clone this wiki locally