Skip to content

Instantly share code, notes, and snippets.

@a-a
Created November 18, 2025 18:53
Show Gist options
  • Select an option

  • Save a-a/79bcb8a5df755fda99383dbd6d216bb3 to your computer and use it in GitHub Desktop.

Select an option

Save a-a/79bcb8a5df755fda99383dbd6d216bb3 to your computer and use it in GitHub Desktop.
FE-5680A DDS helper: convert between frequency and tuning word.
#! /usr/bin/env python3
import argparse
def freq_to_word(f_out, f_ref):
N = round((f_out / f_ref) * (2**32))
return N, f"{N:08X}"
def word_to_freq(word_hex, f_ref):
N = int(word_hex, 16)
f_out = (N / (2**32)) * f_ref
return f_out
def main():
parser = argparse.ArgumentParser(description="FE-5680A DDS helper: convert between frequency and tuning word.")
parser.add_argument("--ref", type=float, required=True, help="Reference frequency in Hz ('N' value from DDS board's 'S' command output).")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--word", type=str, help="Convert Hex tuning word (truncated to upper 32 bits, e.g. 2ABB503D) to frequency..")
group.add_argument("--freq", type=float, help="Desired output frequency in MHz.")
group.add_argument("--freqhz", type=float, help="Desired output frequency in Hz.")
args = parser.parse_args()
if args.word:
word = args.word.strip().upper()
if len(word) > 8: word = word[:8]
f_out = word_to_freq(word, args.ref)
print(f"Word {word} = {f_out:.6f} Hz ({f_out/1e6:.6f} MHz)")
elif args.freq is not None:
f_out = args.freq * 1e6
N, hex_word = freq_to_word(f_out, args.ref)
print(f"{args.freq:.6f} MHz = Word {hex_word}")
elif args.freqhz is not None:
f_out = args.freqhz
N, hex_word = freq_to_word(f_out, args.ref)
print(f"{args.freqhz:.6f} Hz = Word {hex_word}")
if __name__ == "__main__":
main()
usage:
./fe5680a.py --ref <reference-freq-hz> [--word <F-value> | --freq <MHz> | --freqhz <Hz> ]
'S' command on my DDS returns me this:
R=50255056.377900Hz F=2ABB503DE5CA8C00
where R is reference frequency (tuned at factory), and F is the hex tuning word.
so what does mine say?
./fe5680a.py --ref 50255056.377900 --word 2ABB503DE5CA8C00
Word 2ABB503D = 8388607.989497 Hz (8.388608 MHz)
checks out. I measured 8.3886MHz or thereabouts when eyeballing it on my scope.
converting my fe-5680a to 10MHz operation? I would keep the R value (--ref) and calculate a new F (--word):
./fe5680a.py --ref 50255056.377900 --freq 10
10.000000 MHz = Word 32F0AD87
and just to calculte it backwards to be safe:
./fe5680a.py --ref 50255056.377900 --word 32F0AD87
Word 32F0AD87 = 10000000.001753 Hz (10.000000 MHz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment