// tumbler2.c
// 2022-01-10 R.Stirling

/*
 * DDS variable rate stepper drive
 *
 *
 * Timer interrupt for phase acc addition and PWM updates
 * Two timers set up for PWM
 * Sine wave lookup or just FP library sin/cos function call

calculations:
Fout= 1 to 10RPM, 16.7mRPS - 167mRPS, 0.833Hz - 8.33Hz
Tinc = 0.001s
PhiInc = 2 * pi * Fout * Tinc
PhiInc = 5.236e-3 - 52.36e-3
Ain = 0-1023
PhiInc = 5.236e-3 * (Ain/100+1)
Phi = Phi + PhiInc

VSout = Maxv * sin(Phi)
VCout = Maxv * cos(Phi)

At each interrupt
	read adc and calculate phase increment
	add phase increment to phase accumulator
	compute sin(phi) and cos(phi)
	scale by maxv
	write to pwms and pwmc

 */