After getting away from PHSNA for a while and then having to get a couple days re-education to test and issue revision 1.42, I was thinking of all the complex stuff a newcomer to PHSNA has to go through to get it built and running. Even though I think the program features and documentation help a lot.
One thing is the twelve polynomial constants, six for the DDS and six for the DDS plus crystal fixture, used for frequency compensation. PHSNA won't run at all if all the fields of parameters.txt aren't completed.
I was thinking of how a newcomer could "cheat" on these numbers just to get the program going for a trial run, although accuracy would be poor. One way would be to just put in a value (measured or estimated) for C0, which would be the output in the mid-frequency range more or less, and put zeroes for the other five constants.
Of course just to get the program going, one could use the constants found in the sample parameters.txt file. But I surely wouldn't want anyone to think of actually making measurements with either of these "cheats" in effect.
This got me thinking of having the program calculate the constants, but I didn't get too far with that notion. It's too complicated and using Excel as explained by N5IB in his PDF complete with screen shots, or the text-only summary in the User's Guide is the way to go.
While researching that though, I happened onto an Excel formula that calculates the polynomials from the data set of dBm versus frequency. As it turns out, it's not really easier than the method we're already using with the trendline plot, but I present my notes just as a curiosity for people who like to play with Excel:
I found a new Excel function called LINEST() which will calculate them for you. It’s a little tricky to use and just bypasses the step of plotting the data in a chart, but it might be a decent alternative method anyway.
Here’s the formula as I used it:
My data is in two columns with frequency in MHz in A3:A601 and dBm in B3:B601.
Note that the y-value range comes first and then the x-value, which seems backwards so beware.
The caret ‘^’ doesn’t mean exponential but is part of the required syntax of the function.
The ordinal numbers 1,2,3,4,5 within the curly braces tell the function that I want coefficients for a 5th order polynomial. Note that this is going to give me six (6) constants, five coefficients of powers of X and one constant we call C0.
OK, since this thing has an output that’s a vector or array of numbers rather than a single number, the way you set it up in Excel is a little tricky:
Select six empty cells like this. Click in a cell, hold down shift and use the right arrow key to select five more cells giving a total of six. Release shift key.
Press F2. Click in the formula bar, which is above the spreadsheet grid.
Type in the formula above, using your own range for y data first, then x data. I find it easier to have entered the formula somewhere first, do a control-C copy of it, and then a control-V paste of it into the formula bar. Don’t hit ENTER yet!!
Hold down the control and shift keys. Then press Enter.
Your coefficients will appear in the six cells you selected, with the coefficient of X^5 at the left and decreasing until the constant C0 is at the right.
When I first cranked out my coefficients, I found I needed more than the default resolution (number of digits) for good compensations. Here are some notes on that subject:
I was also thinking about how many decimal places you need to maintain accuracy. OK, the C5 number is a coefficient of the X^5 term, where ‘X’ is the frequency in MHz. My sweep for polynomials covers 0.2 MHz to 60 MHz. So at the top end, C5 is the coefficient of the value of 60^5 or 777,600,000.
OK, I think I want enough resolution in my coefficients such that a change of 1 unit in the least significant digit doesn’t throw me off more than 0.1 dBm, which is the resolution of PHSNA, more or less. Let 'N' be the change in the C5 coefficient that will cause a 0.1 dBm change in the result.
N * 777,600,000 = 0.1
So, N = 1.286E-10.
That should mean I want ten digits to the right of the decimal.