having trouble reading sigma delta circuit
Project5k
Posts: 58
I have my 4 line LCD up and working, and i can write to it, reset it, turn its backlight on and off, but after hooking up a sigma delta circuit to pins 6-7 and using the ADC.spin obj, i'm not getting what i think i should be as a result...
I'm brand new to coding, so please, any help would be great....
i'm getting Here We Go!!! on line 1 of the lcd, and then on line 2 i'm getting 43690.
i have 100k between pins 6 and 7, and then 150k between pin 7 and the output of my LM34. Feeding the LM34 from the 5V on my proto USB board...
what i would really like is to just display(and be able to do some basic math functions) with the value i "expect" to get, which is just the mV of the output of the LM34... if i could get the thing to show me 78 and then be able to work with that # i think i can do all i need to do... the other thing that i know i need to do is that i'm gonna wanna read more than one of these, can i just name a couple of the ADC objects, like ADC1, ADC2 and so forth, and change the pin assignments in each, and then call each when i need them? Otherwise how do i go about calling for different measurements from the same ADC obj with the pins set inside?
[edit] after sitting here and reading more, and just letting the thing run for a bit, i started noticing the lcd display change, from 43689 to 43690... I'm sure its just "splitting a step" in the ADC, but at least now i know that its not just harvesting that # from some fixed point... and the change is not predictable, and increasing the temp on the LM34 seems to have NO EFFECT on the # displayed, even tho i can measure a V change with my DMM{/edit]
I'm brand new to coding, so please, any help would be great....
i'm getting Here We Go!!! on line 1 of the lcd, and then on line 2 i'm getting 43690.
i have 100k between pins 6 and 7, and then 150k between pin 7 and the output of my LM34. Feeding the LM34 from the 5V on my proto USB board...
what i would really like is to just display(and be able to do some basic math functions) with the value i "expect" to get, which is just the mV of the output of the LM34... if i could get the thing to show me 78 and then be able to work with that # i think i can do all i need to do... the other thing that i know i need to do is that i'm gonna wanna read more than one of these, can i just name a couple of the ADC objects, like ADC1, ADC2 and so forth, and change the pin assignments in each, and then call each when i need them? Otherwise how do i go about calling for different measurements from the same ADC obj with the pins set inside?
[edit] after sitting here and reading more, and just letting the thing run for a bit, i started noticing the lcd display change, from 43689 to 43690... I'm sure its just "splitting a step" in the ADC, but at least now i know that its not just harvesting that # from some fixed point... and the change is not predictable, and increasing the temp on the LM34 seems to have NO EFFECT on the # displayed, even tho i can measure a V change with my DMM{/edit]
{ Project5k READING LM34 ON PINS 6-7 SIGMA DELTA } CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 TX_PIN = 0 BAUD = 19_200 OBJ LCD : "FullDuplexSerial" adc : "ADC" Var LONG adcsample PUB main LCD.start(TX_PIN, TX_PIN, %1000, 19_200) waitcnt(clkfreq / 100 + cnt) repeat lcdgo adc.SigmaDelta(@adcsample) pub lcdgo waitcnt(clkfreq / 2 + cnt) LCD.str(string(12)) waitcnt(clkfreq / 100 + cnt) LCD.str(string(17)) waitcnt(clkfreq / 2 + cnt) LCD.str(string(22)) LCD.str(string("Here We GO!!!",148)) LCD.dec(adcsample)
{{ ***************************************** * generic ADC driver v1.0 * * Author: Beau Schwabe * * Copyright (c) 2007 Parallax * * See end of file for terms of use. * ***************************************** }} CON SDF = 6 'sigma-delta feedback SDI = 7 'sigma-delta input PUB SigmaDelta (sample) cognew(@asm_entry, sample) 'launch assembly program in a COG DAT org asm_entry mov dira,#1<<SDF 'make SDF pin an output movs ctra,#SDI 'POS W/FEEDBACK mode for CTRA movd ctra,#SDF movi ctra,#%01001_000 mov frqa,#1 mov asm_c,cnt 'prepare for WAITCNT loop add asm_c,asm_cycles :loop waitcnt asm_c,asm_cycles 'wait for next CNT value '(timing is determinant after WAITCNT) mov asm_new,phsa 'capture PHSA mov asm_sample,asm_new 'compute sample from 'new' - 'old' sub asm_sample,asm_old mov asm_old,asm_new wrlong asm_sample,par 'write sample back to Spin variable "sample" '(WRLONG introduces timing indeterminancy here..) '(..since it must sync to the HUB) jmp #:loop 'wait for next sample asm_cycles long $FFFF '(use $FFFF for 16-bit, $FFF for 12-bit, or $FF for 8-bit) asm_c res 1 'uninitialized variables follow emitted data asm_cnt res 1 asm_new res 1 asm_old res 1 asm_sample res 1 asm_temp res 1 DAT {{
Comments
Please edit your post.
Thanks,
-Phil
Take the line that starts the ADC out of the repeat loop, and put it in your initialization of your PUB main.
adc.SigmaDelta(@adcsample)
Once the ADC is started, it simply sits there and autonomously updates your variable, adcsample. So you just have to print it to the LCD, not ask the ADC for it. The number that comes back will be between 0 and 65535 at the ends of the scale. Once you see the number moving in response to the voltage changes, you will have to do some calibration to get it as a temperature value.
You didn't mention having capacitors at the input pin. It's there, right? The performance of the sigma-delta is sensitive to circuit layout.
please review:
now when run, the display still has the here we go, but it toggeles between 32767 and 32768... waitcnt added to slow display down to about 2-3 updates a second, give or take... at least you can see it now... without the wait, it moved so fast it was just a blur...
no change from increasing the temp(mV input) by .2V
caps, no i didnt have them, but i do now. one is from vdd, 3.3v to pin 7 and the other goes from p7 to vdd (ground), wasnt sure about values, so i started with a couple .001uF mylars...
no change in the output of the circuit...
just a thought... its been said that this is a sensitive circuit... is working on a 3m solderless breadboard an issue?
The number 32768 is interesting, because that is exactly half scale. That is the number you expect if the input is disconnected.
has an noticable effect on the sigma-delta-measuring because it switches the IO-pin at really high frequencies. There is even an effect of crosstalking if you use two IO-pins laying next to each other.
If you don't mind adding another chip I recommend the MCP3208. Needs three IO-Pins to connect to the propeller and provides 8 ADC-channels at 12 bit resolution.
Drivercode is ready to use in the OBEX and lots of forum members are using them.
keep the questions coming
best regards
Stefan
I've called all the local electronics parts shops I can find and none of them have either. Guess I'll have to get together an order for Digikey.
I will loose the breadboard and solder it up shortly. Also haven't tried putting full 3v or gnd to the input. That'll get done as well. Results to come...
am i missing something? i think i have the caps your saying i should have.. right?
i'll go check the docs...
we have readings that make sence....
soldered it all up on a little radioshack copperclad i had, and bingo, shes responding to temperature changes!
alrighty, now... how do i "calibrate" it?(get a mV #) lets see, lemme think... full scale voltage, devided by the total number of divisions, then times the reading i'm getting, right?
[edit] wait, dont i remember reading somewhere that i can change the # in the adc part, so that its got the right # of divisions? i think i remember changing something like the #fff, to $0CE4... ideas?
seems to me if i use 330 total divisions, then each one would be worth 10mV, right? then the # i would get is the mV reading, and thus is my temp?
well i tried using 14a and it didnt work... hmmm
Thanks so much everybody... it'd probably taken me weeks to figure out that one!!!
Changing the sigma-delta factor from $FFFF to $0CE4 does not change the full-scale range. It only affects the resolution (making it courser) and the speed (making it faster). The scale factor is set by your choice of resistors, 100k and 150k. There are several analog variables involved, including the exact resistance values and the exact switching threshold of your Propeller chip. To calibrate, it may be best to record the binary counts returned as you stick the temperature sensor (insulated) into an ice bath and into a high temperature reference. Then compute from that.
take the ADC-value of 3.3V and the one for 0.0V and maybe a third inbetween.
Then you can calculate the factors. By the way what kind of temperature sensor do you use?
keep the questions coming
best regards
Stefan
BEST CUSTOMER SERVICE EVER! its not that we had a problem, that happens, but its how you recover from the problem... gotta say, Parallax takes care of thier customers! I even ordered up another prop proto usb... solar tracking and pv charge controller... hehehe but thats down the road...
so i have my mcp3208's on the way.... after looking at the specs, yea a couple bits arent gonna matter for my application... ... if i can get mV resolution, thats good enough... that'd be tenths of a degree...
kinda feel bad going through all this to get the sigma delta going and then i'm just gonna change gears to the 3208's... but hey, i learned some stuff, had fun doing it, and now i know for when i get my next board here... if nothing else, i learned about re-organizing my code and making it more efficient!!!
thanks again ya'll!