From 256991162d03a708dfcbf2e4d1d9bebc640ce786 Mon Sep 17 00:00:00 2001 From: James Snyder Date: Wed, 25 Mar 2009 16:17:19 +0000 Subject: [PATCH] Changes to further test that ADC is behaving correctly. --- romfs/adcpoll.lua | 13 +++++-------- romfs/adcscope.lua | 8 +++----- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/romfs/adcpoll.lua b/romfs/adcpoll.lua index 9589bbee..2835d325 100755 --- a/romfs/adcpoll.lua +++ b/romfs/adcpoll.lua @@ -1,18 +1,18 @@ if pd.board() == "ET-STM32" then timer = 2 - adcchannels = {0,1,2,3} - adcsmoothing = {4, 16, 32, 64} + adcchannels = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} + adcsmoothing = {4, 4, 4, 4, 16, 16, 16, 16, 32, 32, 32, 32, 64, 128, 64, 128} else timer = 0 adcchannels = {0,1,2,3} - adcsmoothing = {4, 16, 32, 64} + adcsmoothing = {4, 64, 32, 16} end for i, v in ipairs(adcchannels) do adc.setblocking(v,0) adc.setsmoothing(v,adcsmoothing[i]) - adc.setclock(v, 30 ,timer) + adc.setclock(v, 50 ,timer) end adc.sample(adcchannels,128) @@ -26,9 +26,6 @@ term.putstr(" CH SLEN RES") term.gotoxy(1,#adcchannels+5) term.putstr("Press ESC to exit.") -local adcvals = {} -local ctr = 0 -local key local sample = adc.sample local getsample = adc.getsample local samplesready = adc.samplesready @@ -42,7 +39,7 @@ while true do term.gotoxy(1,i+3) term.putstr(string.format("ADC%d (%03d): %04d\n", v, adcsmoothing[i], tsample)) end - if adc.isdone(v) == 1 then adc.sample(adcchannels,128) end + if adc.isdone(v) == 1 then adc.sample(v,128) end end key = term.getch( term.NOWAIT ) if key == term.KC_ESC then break end diff --git a/romfs/adcscope.lua b/romfs/adcscope.lua index 9086d9db..1283be27 100644 --- a/romfs/adcscope.lua +++ b/romfs/adcscope.lua @@ -24,17 +24,15 @@ term.gotoxy(1,#adcchannels+6) term.putstr("Press ESC to exit.") local adcvals = {} -local ctr = 0 local key, stime, etime, dtime local sample = adc.sample local getsample = adc.getsample local tread = tmr.read +local tstart = tmr.start local i, v -tmr.start(0) - while true do - stime = tread(0) + stime = tstart(0) for j=1,numiter do sample(adcchannels, 1) for i, v in ipairs(adcchannels) do @@ -46,7 +44,7 @@ while true do term.gotoxy(1,4) for i, v in ipairs(adcchannels) do - term.putstr(string.format("ADC%d (%03d): %04d\n", v, adcsmoothing[i],adcvals[i])) + term.putstr(string.format("ADC%02d (%03d): %04d\n", v, adcsmoothing[i],adcvals[i])) term.gotoxy(1,i+4) end term.putstr(string.format("Tcyc: %06d (us)\n",dtime))