|
|
@@ -13,40 +13,6 @@ |
|
|
|
|
|
|
|
static uint16_t dac = 32768;
|
|
|
|
|
|
|
|
#define TIMER_RATE 8000
|
|
|
|
static int zero_adc = 0;
|
|
|
|
|
|
|
|
void TISR_HANDLER(7)
|
|
|
|
{
|
|
|
|
int16_t v;
|
|
|
|
|
|
|
|
timer_clear_txif(7);
|
|
|
|
|
|
|
|
if (zero_adc) {
|
|
|
|
v = adc_get();
|
|
|
|
|
|
|
|
|
|
|
|
(1024 - v)
|
|
|
|
|
|
|
|
dacval = dac;
|
|
|
|
|
|
|
|
|
|
|
|
dac_current = dac_to_current(dac);
|
|
|
|
|
|
|
|
v = adc_get();
|
|
|
|
i = adc12_to_current(v);
|
|
|
|
/* adjust by 50% of the estimated value, in case our calibration is wrong */
|
|
|
|
dac_current -= (i * 0.5);
|
|
|
|
if (dac_current < dac_current_min)
|
|
|
|
dac_current = dac_current_min;
|
|
|
|
if (dac_current > dac_current_max)
|
|
|
|
dac_current = dac_current_max;
|
|
|
|
dac = current_to_dac(dac_current);
|
|
|
|
dac_write(dac);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void sweep(void)
|
|
|
|
{
|
|
|
|
int32_t d;
|
|
|
@@ -79,9 +45,6 @@ void run_debug(void) |
|
|
|
char buf[4];
|
|
|
|
uart1_init(115200);
|
|
|
|
|
|
|
|
timer_setup_16bit(7, TIMER_RATE, 1);
|
|
|
|
timer_set_priority(7, 6);
|
|
|
|
|
|
|
|
led_pattern(0b10101010);
|
|
|
|
|
|
|
|
uart1_put_string("Zoom NILM Debug\r\n");
|
|
|
@@ -132,14 +95,6 @@ void run_debug(void) |
|
|
|
dac = 32768;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// run degauss (currently a noop)
|
|
|
|
case 'd':
|
|
|
|
uart1_put_string("degauss...");
|
|
|
|
degauss();
|
|
|
|
uart1_crlf();
|
|
|
|
dac = 32768;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// set DAC to specified hex value
|
|
|
|
case 'v':
|
|
|
|
case 'V':
|
|
|
@@ -158,9 +113,9 @@ void run_debug(void) |
|
|
|
case 'z':
|
|
|
|
case 'Z':
|
|
|
|
uart1_put_string("zeroing input...\r\n");
|
|
|
|
zero_adc = 1;
|
|
|
|
while (!uart1_can_get())
|
|
|
|
dac = seek(dac, 1024);
|
|
|
|
uart1_get();
|
|
|
|
zero_adc = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// sweep DAC
|
|
|
|