CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ADC maths... exercise in futility - SOLVED
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9658
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Mar 05, 2013 9:14 am     Reply with quote

great minds think alike.

I found one of the 'remote sensor boards'.Heck it's been 20 years!

Power to the board goes to a 1N4001 then a 22r then another 22r.
3 caps(22/20) used in a double pi filter configuration.
Opamp gets power from 1st section
LM35 from the last.

sorry no picture, it is simple though and I'm lousy at ASCII art....

The 1N4001 was for protection if I miswired it...
resistors and caps were 'what's handy' and gave great results in 150' quad, outside on roof(solar pool controller)

Actually your gain of two is a good idea,just be sure to use 1% resistors.You could adjust the gain to maximize the LM34 input to the PIC ADC, based on your max temperature reading.IE 212*F=2.120 V x 2 = 4.240, would be better for 'noise'.measure the real gain, store as a constant in your program.

I recall using the 'Olympic averaging' code,reading sensor every minute(so 10 quick reads,toss hi,toss lo, avg the 8 left) .The 'avg 8' is fast for a PIC,compiler right shifts so no 'ugly math'.

hth
jay
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Mar 05, 2013 9:49 am     Reply with quote

i assume that too- though in careful test before release of product- i could find no issue with accuracy or stability of the design. 6 out of 10 massaged ADC samples were part of the software, but real world testing in this case showed no problem at all - and was much simpler than amplifying the sensor dc out. the choice has never come back to bite me so.......

i am also guilty of the occasional overclocking of PICS too-but have never released a design that did that particular bad boy behavior.
Gabriel



Joined: 03 Aug 2009
Posts: 1085
Location: Panama

View user's profile Send private message

PostPosted: Tue Mar 05, 2013 9:55 am     Reply with quote

@asmboy : im sorry but i didnt understand your post....
_________________
CCS PCM 5.078 & CCS PCH 5.093
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Mar 05, 2013 10:00 am     Reply with quote

i found it is possible to operate well below the minimum ref ADC voltage , so long as you use:

** a multi sample/ smart discard strategy
and
** a nice long, sample setup time.

this strategy produces fine 12 bit data at 1/3 the min REF volt spec,
in spite of what the data sheet says
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Tue Mar 05, 2013 10:25 am     Reply with quote

asmboy wrote:
i found it is possible to operate well below the minimum ref ADC voltage ...

this strategy produces fine 12 bit data at 1/3 the min REF volt spec,
in spite of what the data sheet says


Well it might on some samples at room temperatures. That's relatively easy.

Does it work reliably over the full temperature range? With the full production variation of PICS? Over the full Vcc range? Over all valid ADC clock rates? Over all valid acquisition times? Over the worst case combination of all of these?

As a note I'm working on a project where I'll be using extended temperature range devices and expecting them (which could be several thousand) to work 100% at or a little above the upper end of the industrial temp range, i.e. around 85C. Oh, and with a good bit of RF floating around too. I can do little or nothing about the RF - its not something Microchip spec for - but needless to say that all other respects I won't be relying on working the PIC outside its specified range.

RF Developer.
Ttelmah



Joined: 11 Mar 2010
Posts: 20161

View user's profile Send private message

PostPosted: Tue Mar 05, 2013 10:56 am     Reply with quote

miro wrote:
Quote:
Then the best regulators are still an order of magnitude worse than a good voltage reference, but a zener is _not_ a good voltage reference. Look at bandgap references.

Not sure that this would be a good hint for this application. My hands-on experience shows you may get best results with oversampling and digital filtering only with dithering. The usage of a noise-free precise voltage reference causes the resulting values will be of a "better precision" only at the moments with input voltages near the transition levels between the "adc bit levels". Dithering helps you with creating improved precision within the adc "step levels" as well.


Dithering gives improved precision, but _accuracy_ depends on the accuracy of the parts. Even if you use a 16bit ADC, you won't get 0.002% 'accuracy' if you are using a 2% voltage reference. Don't confuse 'precision', with 'accuracy'.

Best Wishes
Gabriel



Joined: 03 Aug 2009
Posts: 1085
Location: Panama

View user's profile Send private message

SOLVED
PostPosted: Thu Mar 07, 2013 8:30 am     Reply with quote

So, I finished my project last night!

I want to thank all of you who helped.

I ended up using an LM358 as a 2x amplifier/buffer with a couple ceramic capacitors on the V+ at the sensor end.

The amplified signal goes to another onboard LM358 as unity gain buffer which goes into a small RC filter... (already part of the original board).

So now i have a lo impedance source feeding a high impedance load, and my sensor output is X2 so i utilize more of the ADC full range which also reduces a bit of noise.

Now both my sensors are +-0.5 degrees from each other and the data is _ALOT_ more stable...

I'll post my code tonight for your input on cleaning up the math a bit.

Thank you ALL!

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group