Working with manual tuning. Still need to do vectorscope

This commit is contained in:
cnlohr
2024-10-07 00:39:40 -07:00
parent b2995f435f
commit 529e85e066
4 changed files with 131 additions and 4 deletions
+3
View File
@@ -27,3 +27,6 @@ TODO: TODO: Test HTML values.
TODO: TODO: g_goertzel_omega_per_sample lokos WRONG. TODO: TODO: g_goertzel_omega_per_sample lokos WRONG.
Extra notes:
.87996033 = 880 AM, why?
+19 -1
View File
@@ -201,7 +201,8 @@ void SetupADC()
// ADC_SCAN: Allow scanning. // ADC_SCAN: Allow scanning.
ADC1->CTLR1 = ADC1->CTLR1 =
//ADC_SCAN; //ADC_SCAN;
ADC_Pga_16 | ADC_SCAN; ADC_SCAN | ADC_BUFEN ;
//ADC_Pga_16 | ADC_SCAN | ADC_BUFEN ;
//ADC_Pga_64 | ADC_SCAN; //ADC_Pga_64 | ADC_SCAN;
@@ -753,6 +754,23 @@ void HandleHidUserReportOutComplete( struct _USBState * ctx )
if( numconfigs > 5) g_exactcompute = configs[7]; if( numconfigs > 5) g_exactcompute = configs[7];
if( numconfigs > 6) g_goertzel_advance_r = configs[8]; if( numconfigs > 6) g_goertzel_advance_r = configs[8];
if( numconfigs > 7) g_goertzel_advance_i = configs[9]; if( numconfigs > 7) g_goertzel_advance_i = configs[9];
if( numconfigs > 8)
{
int adc_buffer = configs[10];
if( adc_buffer )
{
// Consider using PGA.
//ADC_Pga_16 | ADC_SCAN | ADC_BUFEN ;
//ADC_Pga_64 | ADC_SCAN;
ADC1->CTLR1 =
ADC_SCAN | ADC_BUFEN;
}
else
{
ADC1->CTLR1 =
ADC_SCAN;
}
}
// Need to reset so we don't blast by. // Need to reset so we don't blast by.
g_goertzel_samples = 0; g_goertzel_samples = 0;
+108 -2
View File
@@ -22,8 +22,30 @@ function DrawSpan( rowspan, colspan, freq, target, docolor, extrastr = "" )
return ret; return ret;
} }
var lastGn;
var lastGmhz;
var lastGfr;
var lastGbrf;
var lastGexact;
function Goertz( n, mhz, fr, brf, exact_compute ) function Goertz( n, mhz, fr, brf, exact_compute )
{ {
lastGn = n;
lastGmhz = mhz;
lastGfr = fr;
lastGbrf = brf;
lastGexact = exact_compute;
SendGoertz();
}
function SendGoertz()
{
var n = lastGn;
var mhz = lastGmhz;
var fr = lastGfr;
var brf = lastGbrf;
var exact_compute = lastGexact;
let tau = 3.1415926535*2.0; let tau = 3.1415926535*2.0;
let omega = fr * tau; let omega = fr * tau;
var textarea = document.getElementById("goertzeloutput"); var textarea = document.getElementById("goertzeloutput");
@@ -64,7 +86,76 @@ function Goertz( n, mhz, fr, brf, exact_compute )
exact_compute|0, exact_compute|0,
g_goertzel_advance_r|0, g_goertzel_advance_r|0,
g_goertzel_advance_i|0, g_goertzel_advance_i|0,
document.getElementById( "toggle_adc_buffer").checked ? 1 : 0,
] ); ] );
// Update toggle control
let target = Number(document.getElementById("targetmhz").value );
var tz = (target * 10000000.0);
for( var i = 0|0; i < 10; i++ )
{
var tc = (tz / 1000000000.0) % 10;
document.getElementById( "mhzm" + i ).value = tc|0;
tz *= 10;
}
}
function toggleBuffer( ths )
{
SendGoertz();
}
function mhzm( event, ths )
{
event.preventDefault();
let dy = event.deltaY > 0 ? -1 : 1;
var thss = Number(ths.id.substr(4));
var hz = 0; // actually tents of hertz
for( var i = 0|0; i < 10; i++ )
{
var dig = Number(document.getElementById( "mhzm" + i ).value);
hz += Math.pow( 10, 9-i ) * dig;
}
hz += dy * Math.pow( 10, 9-thss );
lastGmhz = hz/10000000.0;
document.getElementById("targetmhz").value = lastGmhz;
let xtal = Number(document.getElementById("crystalmhz").value );
let target = Number(document.getElementById("targetmhz").value );
let quadrature = document.getElementById("QUADRATURE").checked;
let goertzels = document.getElementById("GOERTZELS").checked;
let goertzel2 = document.getElementById("GOERTZEL2").checked;
let quanta = Math.round(Number(document.getElementById("quanta").value));
let quantasearch = Math.round(Number(document.getElementById("quantasearch").value));
let n = lastGn;
let freq = ( xtal / n );
let goertzelpoint = 0;
let goertzelpointinv = 0;
let tgoertzelp = 0;
let tgoertzelpi = 0;
let quantaA = 0;
let quantaINV = 0;
let h = 1;
let tquanta = (quanta&0xffffc);
let base = freq * h;
let next = freq * (h+1);
let tgoertzelpoint = tquanta;
tgoertzelpoint = ( target - base ) / ( next - base );
tgoertzelpoint = ((tgoertzelpoint%1)+1)%1;
quantaA = tquanta;
tgoertzelp = h;
Goertz( n, freq * (h+tgoertzelpoint), (tgoertzelpoint), quantaA , 1);
return false;
} }
function computeTable() function computeTable()
@@ -214,8 +305,23 @@ function computeTable()
} }
else if( goertzel2 ) else if( goertzel2 )
{ {
contents += "</TABLE><TEXTAREA ROWS=6 COLS=120 ID=goertzeloutput></TEXTAREA><BR>"; contents += "</TABLE>";
contents += "<TABLE BORDER=1>"; contents += "<TABLE><TR><TD><TEXTAREA ROWS=6 COLS=120 ID=goertzeloutput></TEXTAREA></TD><TD><DIV>";
// Add widget to control various things, realtime.
contents += "<input type=checkbox ID=toggle_adc_buffer onchange='toggleBuffer(this)'><label for=toggle_buffer>ADC Buffer Enable</label><BR>Scroll Wheel Control:<BR>";
contents += "<input id=mhzm0 onwheel='mhzm(event, this)' size=1>";
contents += "<input id=mhzm1 onwheel='mhzm(event, this)' size=1>";
contents += "<input id=mhzm2 onwheel='mhzm(event, this)' size=1>.";
contents += "<input id=mhzm3 onwheel='mhzm(event, this)' size=1>";
contents += "<input id=mhzm4 onwheel='mhzm(event, this)' size=1>";
contents += "<input id=mhzm5 onwheel='mhzm(event, this)' size=1>,";
contents += "<input id=mhzm6 onwheel='mhzm(event, this)' size=1>";
contents += "<input id=mhzm7 onwheel='mhzm(event, this)' size=1>";
contents += "<input id=mhzm8 onwheel='mhzm(event, this)' size=1>,";
contents += "<input id=mhzm9 onwheel='mhzm(event, this)' size=1>";
contents += "</DIV></TD></TR></TABLE><BR>";
contents += "v Click in this row; <TABLE BORDER=1>";
contents += '<TR><TH>d\\h</div></TH>'; contents += '<TR><TH>d\\h</div></TH>';
for( let h = 0|min_harmonics; h <= max_harmonics+1; h++ ) for( let h = 0|min_harmonics; h <= max_harmonics+1; h++ )
{ {