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 support@ccsinfo.com

Pre Project ADC Help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

Pre Project ADC Help
PostPosted: Wed Aug 26, 2009 3:30 pm     Reply with quote

Hello all,

I have a project which requires measuring water level on a river.

My sensor will consist of a variable resistor which is turned by float which moves up and down as water level changes.

The water level varies over the course of the day, its a very slow Delta.
and changes in water level may be as small as 1-20 cm, up to a few meters over a few days, and in rare cases up to a meter or more in a few hours.

At the time of measurement since the rate of change is so slow, i was thinking of handling my input signal as if it was a DC signal. I don't think I'm being crazy by taking this assumption.

I would like to have 1cm Resolution on my water level... but i can settle for 3cms at worst maybe 5. but thats pushing it hahaha.

Before you all tell me to go RTFM, i have read, and searched application notes and so on.

From what if read, in most cases when doing ADC reading i see that the ADC depending on the signal might not be able to use its full bit range.

For my project i am going with a 16F88, or a 16F876A.

My variable resistor i was planning on using a trimpot, 25 turns or more if possible or something of sorts.... with some sort of transmission to allow me to have at least 5 meters of measuring range.

My specs for this project might be unrealistic and i will probably find that out soon enough....but my question still applies for my own personal knowledge.

I can see that if i use a 25 turn trim pot for a 5 meter range... I would get
0.05 turns per cm. I don't think the voltage will even vary with such a turn.
but this is just an example component. ( don't want to use a pressure sensor, lasers or ultrasonic ).... ( i know this limits my project alot )


I'll will be powering my circuit with a solarcell, battery and a switcher, either step up or step down... so i might face some noise issues with the adc?

Now, is there any external components you guys suggest I use on my analog input? So that I might be able to get good precision?
I know from reading that just increasing the amount of bits doesn't cut it.
I have been unable able to determine if this external components are only necessary of your reading signals and other fast changing voltages...
and not for such a slow signal... almost DC type.

Is it necessary in this case? To have a low pass filter, gain block etc..instrumentation amplifier? .


Can the pic ADC handle this on its own?

I've played around with the adc a few times... but nothing real world or precision wise before...

Thank you all.

gabriel
_________________
CCS PCM 5.078 & CCS PCH 5.093
Ttelmah
Guest







PostPosted: Thu Aug 27, 2009 3:17 am     Reply with quote

Just how much resolution you can get out of the ADC, depends on a lot of things.
Careful PCB design.
Using sampling methods correctly at the chip itself (possibly stopping peripherals as you sample, etc.).
Software processing (it is possible to actually get accuracies _beyond_ the hardware abilities of the ADC, by using statistical oversampling...).
Control of the reference voltage used (Using the 5v as vref, is significantly limited, and though you would inherently 'think' that if a potentiometer is used, noise on the line, and the signal would tend to self cancel, the capacitive nature of the ADC, and the wiring, tends to prevent this from happening, except for very low frequency noise sources. So, probably better to use something like a precision 4v extenal Vref (on many PICs the minimum Vref for full accuracy is 3v, and you want a margin to the supply rail to allow it to be fed).

Now, start with your distance, and spec.. 5m 'range', 0.5cm 'wanted'. 1 part in 1000. So, 'yes', with care, this is 'doable', by the standard ADC. However your problem becomes whether it is likely that you can get a potentiometer that is linear to this level, _and will remain linear as it ages_...
You will find that a pot, quoted as linear to this sort of level, will probably cost more than you expect. 0.1% or better quoted repeatable linearity and resolution needed. Something like the HHS1710, is available to special order with this sort of spec, but will not be cheap. A normal trimpot, will be at least an order of magnitude 'below' this sort of accuracy. Then, you will need to ensure that your potentiometer impedance is low enough to meet the requirement of the ADC, or you will have to buffer the signal (and remember that buffer amplifiers themselves introduce another error source...).

Realistically, I'd have to say this is much easier to do accurately, using other techniques. A simple (and quite cheap) low resolution optical shaft encoder (like to sort used in a mouse), could potentially give you resolutions of a fraction of a mm (depending on how you arrange the mechanical coupling), with almost unlimited range (if for example the connection gives one step per 0.1mm, a16bit counter, would allow over 6.5m of range to be handled, while using a 32bit counter, this would go up to 429 thousand km!.... The cost of this type of solution, is likely to be a lot less than the ADC/pot.
Again, using something like ultrasonic, has the advantage of getting rid of the gearbox, and coupling.

It is doable, but to actually meet your requirements, will end up costing more than you expect.

Best Wishes
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 27, 2009 10:53 am     Reply with quote

Ttelmah,

Thank you for such nice reply.

Optical encoders such as the ones used in mice was my first choice to do this.. simple, elegant and scalable to as many meters I needed. BUT if my system runs out of power, resets, or anything of sorts, I lose my current position, so my next reading will be off by how many cm the water level has changed while the system had a power failure. With a resistor, the current position is inherently "recorded" on the resistor itself with or without power.

Being able to handle a total power failure... for days.... without losing track of where the level is upon re-startup is essential. Suggestions?

I thought about using absolute encoders... but they are no where to be found here.

Ultrasonic, seemed good but I feel its power hungry and I can't put it inside a long tube because the echos will bounce all over the place... being inside a tube is also essential... it acts as a physical lowpass filter for the "noise" (aka waves) on the water.

I could average a few pings with ultrasonic and get my +/- 5cm... but again... power hungry?
I have NO experience with such devices.

I am completely open to suggestions on different methods.... but I am trying to stay on the cheap side.... maybe if this goes well I can go for a second gen with a better budget.


About the ADC, I was thinking of using a voltage reference... but i didn't quite understand what you said.
If I give my ADC a voltage reference of 4V (example)
can I still read 5V on my ADC? I was under the impression that the reference voltage sets a roof for the ADC.
From what I read in your reply this is not the case. Please set me straight on this.


5m = 500cm, having a 5cm resolution is 1/100 , not 1/1000.
worst case (optimum case for me) resolution will be 1/500.

I think you got confused by my explanation of 0.05 "Turns" of the trimpot Per centimeter. (I hope I can modify this to get a more significant turn on the pot)
If found 10 turn, 15 and 25 turn trimpots.... are there any with a higher number of counts? That way I can use less reduction on the mechanical links.

So I guess that if it was doable before... its even More doable now... since my resolution is not as tight as you though. Am i right?

So maybe I can pull it off with 10 bit ADC and a Sweet vref. Good news!

I know I will have to look for one Hell of a Trimpot to get away with this.

Ttelmah

Thank you for your reply. Looks like you really tried to give a good answer.

Very much appreciated. Thank you for your time.

G
_________________
CCS PCM 5.078 & CCS PCH 5.093
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Aug 27, 2009 1:02 pm     Reply with quote

One option would be a "string encoder" that has a 125 inch range (one version is made by
Celesco). It has 101 step per inch resolution (or variable voltage) and is made for use in a wet environment. I have used something similar in the past.

http://www.celesco.com/stringpots/?gclid=CLzf34q_xJwCFSQeDQodTW7hoQ

BTW, if you need more range they also have one that goes to 140 FEET!!
_________________
Google and Forum Search are some of your best tools!!!!
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 27, 2009 2:05 pm     Reply with quote

Wow that is NICE!

I thought of building something similar a few months ago... using a tape measure.... and a trimpot...

If I'm not mistaken these use an optical encoder inside....

Thanks for your suggestion.

gabriel
_________________
CCS PCM 5.078 & CCS PCH 5.093
Ttelmah
Guest







PostPosted: Thu Aug 27, 2009 2:42 pm     Reply with quote

Key to remember is that there are two different types of 'optical encoder'. Differential, and absolute. The basic mouse encoder is differential. It only tells you how much you have moved. Absolute encoders return a position. Gray coded rotary absolute position encoders are available to resolutions that will make you eyes water (I have used units with over 20000 positions), and tape encoders are available of a similar type. However these are more expensive than differential encoders. I think thogh, you overestimate the problem of power. You can power a rotary encoder, and PIC, for a couple of years off a pair of AA batteries. If you have solar charging available, it gets even easier.
Look at the current 'wireless' mice. They power the encoder, and the wireless link as well, and few run for less than a year, often using the smaller AAA batteries.
I have a couple of 'old' projects done back in the 1990's, usng a lithium cell, and these were specified for a one year battery replacement cycle. One however is still 'on test' on it's original battery, and has already gone twice as long as calculated...
You actually put the PIC to sleep, and only leave power to the encoder. When movement is detected the PIC wakes. There are also simple CMOS counters you can use that draw less than the PIC.

Best Wishes
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 27, 2009 3:49 pm     Reply with quote

Ttelmah,

you might be right, i might be overestimating the power consumption,

correct me if im wrong but, for diferential encoders, they are ON all the time, that means that there is an IR LED ON all the time.

i was assuming 5mAh to run the encoder... Full time.
thats ~25mAh a day x 30 days.. 750mAh a month, Just for the encoder.
(not so bad after all...) (i think i will reconsider this.)
i think a few counters working with this, permanently on, and just checking the counters on PIC wake up would make my project work.
nice.... i like it, thank you Ttelmah.

any suggestions on a low power counter? i assume CMOS...at least thats what i am googling right now...


BUT add that to a RS232 MAX chip, permanently on... since my PIC wakes up on an incoming text string. (there is a Cellphone on the other end.)
i know there are some chips with a SHDN pin on them which drops the current to uA.... but how do i wake up my pic.... if it needs a string comming from such chip to wake up.... (im working on a way to not use the chip entirely but until then ill assume its on.)

never mind powering the cellphone... i got that covered...turns out its easier than powering my circuit.

oh, something just ocurred to me, with the differential encoder...
since im reading a sloooow change in level... there might be times... alot of times... when the encoder is left in the possition where the LED is shining on the IR reciever ... which would be grounding a line...
i would be loosing a few mA in this situation..... if it extends for a long period of time... several times a day...
Am I sweating the Small stuff?...probably right?

you guys are pretty smart.... thank you all.

gabriel
_________________
CCS PCM 5.078 & CCS PCH 5.093
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 27, 2009 3:59 pm     Reply with quote

CD40192B

looks good...

CD40110B ... better?

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
Page 1 of 1

 
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