Coder Social home page Coder Social logo

crystalweb's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

crystalweb's Issues

divide by zero in Log10

Great ! I need to measure 120 crystals. this saves some headache.

On windows, python3, nanovna-F V2 from sysjoint.

It seems to work, but throws this at my screen:

RuntimeWarning: divide by zero encountered in log10
mag = np.median(20 * np.log10(np.abs(data)), axis=0)

add ppm flag request, and "UnboundLocalError: local variable 'loss' referenced before assignment"

This is a great little utility, and perfect for sorting though bins of xtals.
Any tips on the error would be helpful. =)

As far as I can tell, the NanoVNA-H does not have a ppm offset setting, and would require rebuilding the firmware to correct the error. Perhaps, I thought it would make sense to add the +-ppm offset to the xtal profile tool instead, but am unsure how well these devices vco are made.

Firmware:
https://github.com/hugen79/NanoVNA-H.git
NanoVNA-H_20210130.dfu

My 10MHz hc49 xtal scan example:
9.997225MHz series peak
10.017400MHz parallel dip

crystalweb Error seems to occur as peak scan window is narrowed a few times:
scanning sample label X0... TITLE: X0 RL = 50.0 ohm fs = 9997132 Hz Rm = 30.44 ohm Traceback (most recent call last): File "/home/.../crystalweb_ladder_filter_designer/crystalweb/crystalweb.py", line 256, in main stray=args.stray, title=args.title) File "/home/.../crystalweb_ladder_filter_designer/crystalweb/crystalweb.py", line 185, in analyze_crystal sweep(fs - bw_df / 2, fs + bw_df / 2) TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
And thus line 176 in crystalweb.py is never true:
if not np.isnan(bw): bw_df = df

My test script to sort my parts bin:

`#!/bin/bash
#This xtal tester does scan steps needed to get a xtal filter design BOM
#
# apache 2.0 license
# 2021 Joel Mckay
# "Hello from VE7NTP" ;-)

#OS install:
# sudo /usr/bin/python3 -m pip install --upgrade pip
# sudo /usr/bin/python3 -m pip install --upgrade numpy


# Using the NanoVNA to design a crystal ladder filter 
xtalFreqMinHz="9900000"
xtalFreqHz="10000000"
xtalFreqMaxHz="10100000"
poles=4
testlotcount=20
mydev="/dev/ttyACM0"

#constants
mydir=$(pwd)
#todo: add GPSDO ppm offset correction at 10MHz
#this feature should be in the firmware, or added in the utils
nanovnaXtalPPMerror=90

#install deps
if [ ! -d $mydir/rffilter ]
then
	echo "install rffilter..."
	cd $mydir
	git clone --depth 1 https://github.com/roseengineering/rffilter.git
	chmod 750 $mydir/rffilter/rffilter.py
fi

if [ ! -d $mydir/crystalweb ]
then
	echo "install crystalweb..."
	cd $mydir
	git clone --depth 1 https://github.com/roseengineering/crystalweb.git
	chmod 750 $mydir/crystalweb/crystalweb.py
fi

if [ ! -d $mydir/logs ]
then
	mkdir -p $mydir/logs
fi

#calibrate xtal test jig part 1
echo ""
echo "===================================="
echo "measure test fixture stray capacitance?"
read -t 30 -n 1
if [ ! $? = 0 ] ; then
	exit ;
else
	echo "OK"
fi
cd $mydir/crystalweb
## $mydir/crystalweb/crystalweb.py  --fixture --device $mydev
cd $mydir


#calibrate xtal test jig part 2
echo ""
echo "===================================="
echo "measure test fixture loss?"
read -t 30 -n 1
if [ ! $? = 0 ] ; then
	exit ;
else
	echo "OK"
fi
cd $mydir/crystalweb
##$mydir/crystalweb/crystalweb.py  --loss --device $mydev
cd $mydir


#todo: add options to recall last inventory of unused xtals, or add new ones to the lot
echo ""
echo "===================================="
echo "Scan inserted xtal sample in socket?"
echo -ne ""  > $mydir/logs/log.csv
counter=0
cd $mydir/crystalweb
while [ $counter -lt $testlotcount ]
do
	read -t 300 -n 1
	if [ ! $? = 0 ] ; then
		exit ;
	else
		echo "scanning sample label X$counter..."
	fi
	
	$mydir/crystalweb/crystalweb.py --stray 1.1 --title X$counter --device $mydev --start $xtalFreqMinHz --stop $xtalFreqMaxHz >> $mydir/logs/log.csv
	counter=$((counter+1))
	
	if [ $counter -lt $testlotcount ]
	then
		echo "Inserted next xtal sample into socket?"
	fi
done
cd $mydir


#xtal selection
echo -ne ""  > $mydir/logs/xtals_unused.csv
echo -ne ""  > $mydir/logs/xtals.csv
sort --field-separator=',' --key 2 --numeric-sort $mydir/logs/log.csv >> $mydir/logs/xtals.csv

echo "XTAL,FS,CM,LM,RM,QU,CO"  > $mydir/xtal_BOM.csv
xtalparams=""
for selected in $(head -n $poles $mydir/logs/xtals.csv )
do
	xtalSeriesHz=$(echo "$selected" | cut -d',' -f2 )
	#todo: add skip to sorted index feq min match, and tale n closest xtal ids
	#if [ $xtalFreqMinHz -lt $xtalSeriesHz ]
	#then
		if [ "$xtalparams" == "" ]
		then
			xtalparams="$xtalSeriesHz"
		else
			xtalparams="$xtalparams,$xtalSeriesHz"
		fi
		#create part list for build
		echo "$selected" >> $mydir/xtal_BOM.csv
	#else 
	#log unused to remove parts from xtal inventory list?
		echo "$selected" >> $mydir/logs/xtals_unused.csv
	#fi
done

#calculate other schematic parts needed
echo ""
echo "====== Running rffilter on xtal_BOM.csv ======="
cd $mydir/rffilter
#todo: how to auto calculate this value
# --l 70e-3         resonator inductor values, can be given in common notation
$mydir/rffilter/rffilter.py --k chebyshev_0.5 --bw 2500 -n $poles  --l 70e-3  --crystal-mesh --f  "$xtalparams" | tee $mydir/xtal_filter.cir

echo "Done!"
exit 0

 #This filter is from an example in Steder's "Crystal Ladder Filters for All" paper in QEX.
./rffilter.py --g chebyshev_0.2 --n 8 --crystal-mesh --l 69.7e-3 --f 4913.57e3 --bw 2400 --ch 3.66e-12 | tee examples/xtal.cir
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.