From ee0fbbe95812db37955f6647a2e23ed2496b0ca8 Mon Sep 17 00:00:00 2001 From: Michael Dryden Date: Tue, 1 Apr 2014 14:25:26 -0400 Subject: [PATCH] Implement DAC value averaging for LSV to approximate correct position. --- DSTAT-temp/src/experiment.c | 66 ++++++++++++++++++++---------------- DSTAT1.atsuo | Bin 47616 -> 47616 bytes 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/DSTAT-temp/src/experiment.c b/DSTAT-temp/src/experiment.c index ed2d5ad..f83f225 100644 --- a/DSTAT-temp/src/experiment.c +++ b/DSTAT-temp/src/experiment.c @@ -371,37 +371,45 @@ static void porte_int0_lsv(void){ /** * ISR for taking LSV measurements. */ - int32_t result; - - if (autogain_enable == 0){ -// while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); - result=ads1255_read_fast24(); - goto noauto; - } + int32_t result; +// +// if (autogain_enable == 0){ +// // while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); +// result=ads1255_read_fast24(); +// goto noauto; +// } +// +// else{ +// while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); +// result=ads1255_read(); +// } +// +// if (autogainswitch()==0){ +// noauto: +// // if (g_gain == POT_GAIN_300) +// // printf("%u %ld\n\r", TCC1.CNT,result); +// // else if (g_gain == POT_GAIN_3k) +// // printf("%u %ld\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_30k) +// // printf("%u %ld000\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_300k) +// // printf("%u %ld00\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_3M) +// // printf("%u %ld0\n\r", TCC1.CNT, result); +// // else if (g_gain == POT_GAIN_30M) +// // printf("%u %ld\n\r", TCC1.CNT, result); +// // else +// printf("%u %ld\n\r", TCC1.CNT, result); +// } +// +// return; + static uint16_t last_value = 0; + uint32_t current = TCC1.CNT; - else{ - while (arch_ioport_get_pin_level(IOPORT_CREATE_PIN(PORTD, 5))); - result=ads1255_read(); - } + result = ads1255_read_fast24(); + printf("%lu %ld\n\r", (current+last_value)>>1, result); //DAC value is average of current and last timer - approximation of center of averaging window + last_value = (uint16_t)current; - if (autogainswitch()==0){ - noauto: -// if (g_gain == POT_GAIN_300) -// printf("%u %ld\n\r", TCC1.CNT,result); -// else if (g_gain == POT_GAIN_3k) -// printf("%u %ld\n\r", TCC1.CNT, result); -// else if (g_gain == POT_GAIN_30k) -// printf("%u %ld000\n\r", TCC1.CNT, result); -// else if (g_gain == POT_GAIN_300k) -// printf("%u %ld00\n\r", TCC1.CNT, result); -// else if (g_gain == POT_GAIN_3M) -// printf("%u %ld0\n\r", TCC1.CNT, result); -// else if (g_gain == POT_GAIN_30M) -// printf("%u %ld\n\r", TCC1.CNT, result); -// else - printf("%u %ld\n\r", TCC1.CNT, result); - } - return; } diff --git a/DSTAT1.atsuo b/DSTAT1.atsuo index 4d5dce4f8e30d4e80caa77ff3ea7751260016e6d..082d5d758ee5b59ea58f31c58f6a5f3a30c0f42d 100644 GIT binary patch delta 1201 zcmah|Uu;u#6z=c#-rJ70qn!o2vOnDh8(Al80>(@sU8n)qL0eo5n;q?-qeI%UEuEk< z*trLJSOoVaTGNz~nUFBZ{`8kPjZQ0=_@KgG&<8Qo7<>}NH$wK8>ESr6jNRdG;OIj8MNv5<}qgvaU zO^phST!M5iMeR*d6&uRbU8UHfteQw#&? zN=#21P!Zm`iaW*wdDa3?Xdfa6cIm%kUhWCzWmpdHfaACYp2K+r<8i#&@fCg6@`0yQ zKvP#U++8-LLmg~Q&;eXXi#Q+MDjId(f|P!8lqI$-E?)jV9l0;oQV-(lnUTl;Hddu`^h_>TGu+vDZsxok-V-ptQHk{ACjLnH* zdIxZC&dDbdem(l8OVA&yE|`H~&;ifXGq4V=$I}B2{BSjhz(4|(gHbFEzQoN}-V+GW z3TEd`h-3}9SMm(MoDO4jFof*vPDHM4z|yb*eHjz~eY{>j`MQ9rt7VAH4B^VV+j;)% zIe|IU)k%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