MCP3204 code questions
Hi everyone,
Trying to measure temperature using a TH-44004 Tempearture Probe with a MCP3204 adc. Professor provided programs as a template, but it was two different spin programs for using remote sensing, so it was a bit tricky to combined.
The PRI SENS_T linearly interpolates data we have for count to temperature that was calculated just in excel for simplification.
I've attached the spin prorgram of what we've tried so far, and a section at the top with questions for anyone willing to help. I'll probably post more questions later. FYI - new to programming.
Temp_3_29_11.spin
Trying to measure temperature using a TH-44004 Tempearture Probe with a MCP3204 adc. Professor provided programs as a template, but it was two different spin programs for using remote sensing, so it was a bit tricky to combined.
The PRI SENS_T linearly interpolates data we have for count to temperature that was calculated just in excel for simplification.
I've attached the spin prorgram of what we've tried so far, and a section at the top with questions for anyone willing to help. I'll probably post more questions later. FYI - new to programming.
Temp_3_29_11.spin
Comments
Thanks in advance for your help!
The problem is understanding the code for the adc, never programmed one before. Any tips based on our current program?
Some things still have to be changed because this was code for a 16-bit 6 channel but actually using a 12-bit 4 channel adc.
There is good code available for the MCP3204 -- I wrote this object:
-- http://obex.parallax.com/objects/625/
And you can read about using the MCP3204 in this Nuts & Volts column (I wrote it):
-- http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp8.pdf
That article uses joysticks -- think of the your thermistor/resistor combination in similar turns (you're measuring the voltage at the tap).
Thanks so much for this program. It is much easier for reading the counts from the adc.
Now we just need to clearly extract the counts. We've run the program and displayed the results in parallax serial terminal, and we're getting the counts read then gibberish like this:
®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ¬ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ¬ÿÿÿÿÿÿÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ¬ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿÿ
ÿÿÿÿÿÿÿÿ¬ÿÿÿÿÿÿ¬ÿÿÿÿÿÿÿÿÿ®ÿÿÿ¬ÿÿÿ¬ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ2965
1: 0
2: 23
3: 28
®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿÿÿÿ¬ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿÿÿÿÿÿÿ®ÿÿÿ®ÿÿÿÿÿÿ¬ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ¬ÿÿÿ®ÿ
ÿÿÿÿÿ®ÿÿÿÿÿÿ®ÿÿÿ¬ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿ®ÿÿÿÿÿÿÿÿÿ®
We've looked at this part of the code and are trying to figure out how to get just the count readings to be displayed. What is causing all of the extra text?
t := cnt
repeat
term.tx(HOME)
term.tx(LF)
term.tx(LF)
repeat ch from 0 to 3
term.dec(ch) ' display channel #
term.str(string(": "))
term.dec(adc.read(ch, adc#SE)) ' display channel value (counts)
term.tx(CLREOL)
term.tx(CR)
term.tx(CLRDN) ' terminal clean-up
waitcnt(t += constant(MS_001 * 100)) ' update every 100ms
John Abshier
But we are still getting some fluctuation, especially for the temperature sensor. We tried replacing it with a constant voltage supply and seeing the reading, but it wouldn't read the value. And the pressure sensor also fluctuates about between 0 and 10 counts (expecting somewhere close to zero just in normal conditions, right?)
Yet to test the humidity sensor, that's next.