Sigma Delta-Interleaved with other code
I have a current program with all 8 cogs occupied but one·cog is lightly loaded.
I need to get 2 low resolution (7-8 bits) Analog values at a fairly low update rate of around·10-15 x per second.
I understand the concept of Sigma Delta but not how it is extracted from the counters as the samples I looked at all seemed to be stand alone loops and I do not understand if the read of the counter is critical other than not reading too fast for the required resolution.
Can I interleave this code with other code and just read the counter (A &
·data at a time when the other processing permits in a single cog?
Thanks,
Craig
I need to get 2 low resolution (7-8 bits) Analog values at a fairly low update rate of around·10-15 x per second.
I understand the concept of Sigma Delta but not how it is extracted from the counters as the samples I looked at all seemed to be stand alone loops and I do not understand if the read of the counter is critical other than not reading too fast for the required resolution.
Can I interleave this code with other code and just read the counter (A &
Thanks,
Craig

Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Craig
''Test ADC Interleaved.spin ''View results with Parallax Serial Terminal. CON _clkmode = xtal1 + pll8x ' Set system clock frequencey _xinfreq = 5_000_000 OBJ ' Object declarations ser : "FullDuplexSerial" PUB go | val ' Go method with local variables ser.start(31, 30, 0, 9600) ' Start FullDuplexSerial waitcnt(clkfreq/10 + cnt) ' Time for PC to connect repeat ' Loop ser.str(String(13, "val = ")) ' CR + "val = " val:= adc(8, 7, 2048) [b]' Call adc method [/b] ser.dec(val) [b]' Display result[/b] waitcnt(clkfreq/4 + cnt) [b]' Time for doing other tasks [/b] [b]' doesn't have to be constant[/b] PUB adc(pinFb, pinIn, ticks) :adcVal | t ' Sigma-delta ADC method dira[noparse][[/noparse]pinFb]~~ ' Set feedback pin to output ctra := %01001<<26 + pinFb<<9 + pinIn ' CTRA -> POS detector wi feedback frqa := 1 ' FRQA adds 1 to PHSA when pos detect phsa~ ' Clear PHSA for first measurement t := cnt ' Get current cnt register value. repeat 2 ' Sigma-delta ADC loop, 2 reps to sync waitcnt(t+=ticks) ' Wait for the measurement to complete adcVal := phsa~ ' Copy phase accumulator to variable ' and then clear phase for next measurement.▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 2/16/2009 9:33:08 PM GMT
PUB go | val, val1, val2, val_ave ' Go method with local variables ser.start(31, 30, 0, 9600) ' Start FullDuplexSerial waitcnt(clkfreq/10 + cnt) ' Time for PC to connect repeat ' Loop ser.str(String(13, "val_ave = ")) ' CR + "val = " val:= adc(8, 12, 4000) waitcnt(clkfreq/40 + cnt) val1:=adc(8, 12, 4000) waitcnt(clkfreq/20 + cnt) val2:=adc(8, 12, 4000) val_ave:=((val+val1+val2)/3) ' Call adc method ser.dec(val_ave) ' Display result waitcnt(clkfreq/4 + cnt)I am trying the interleaved adc to analyze a signal from a function generator(10 kHz, square wave), but the values being displayed are varying a bit. Is there a way to average several values?(I tried to make an average value in the code above), but the the values still vary every 1 out of 4 values(three values of ~750, and then a reading of 670 for example). I am using a photodiode to produce the signal fed into the adc, and prefer precision because I plan on having 2 photodiodes(taos TSL12S: light-to-voltage)·with their outputs filtered to 10kHz and 20kHz, and I need to compare which photodiode has the bigger output. My final project will have 9 sensors, will I need to use 18 pins to utilize this adc?