Having same issue of analog to digital conversion

Status
Not open for further replies.

KhaledOsmani

Full Member level 6
Joined
May 4, 2014
Messages
384
Helped
1
Reputation
2
Reaction score
1
Trophy points
18
Visit site
Activity points
3,933
I`m having the old error of ADC.

I will state everything clearly here, hoping to get an effective reply:

I've connected the LM35DZ, with 1k resistor, and supplied power into the circuit (supply voltage = 6.72V; note that this sensor has a range from 5 to 30VDC of voltages)
I've connected a multi-meter, one branch is connected to the output of the circuit, the other branch, is connected to the ground of the circuit, so basically here I`m testing the voltage that this circuit resulted.
Here the temperature is nowadays ranging from 20C to 23 DC.
What I see on the output voltage of the circuit is: 0.20V to 0.23V
Which means that the temperature is 100*output voltage of this circuit.
To make this more sure, I've placed this entire circuit in the refrigerator, this is what I've seen:
output voltage decreases like: 0.20 0.19 0.18 0.17 0.16 0.15 and so on

More over, I had lighted a lighter, near the sensor, and this is what I see on the output voltage:
0.20 0.25 0.30 0.55 0.58 and so on

Conclusion: This temperature sensor, is from a side, working and efficient. from another side, this whole circuit as I/O is efficient and working.

Now, concerning the micro-controller part, I`m using PIC18F4520.
I've set the PORTA to analog mode.
I've also set the PORTA to input mode.

Problem: I`m not seeing correct, or real values, of Temperature in C, on the LCD, and most of the times all I see is: 0C

This is the logic that I had used to convert from analog to digital:
put the converted value of the temperature in a special register, named for example tempdig
then I converted from digital to analog by multiplying the value inside tempdig by the factor 5/1023

due to observation, this multiplication isn't enough, there must be a multiplication of 100/2 then subtraction of 20 to get an accurate output.
When I connected the LM35DZ alone, it worked correct and great, but when adding more components of the circuit, it get stuck, or lost I can't give a logic expression about what happens to it, but It randomize, and get inaccurate.


This topic is not that hard, this problem is stuck with me for weeks, there is no intelligence in converting and outputting sensor readings on the LCD. Could any body please tell me what the problem is and its solution, is it me dealing with complexities in an in-efficient way?

NOTE that if this is solved, it remains problem with the LDR, and other other sensors...
 

Hi,

First off there is no problem with the LM35 and Pic micros, they are a tried and tested combination as many previous postings in this forum show.

Second, though the Lm35 can take higher voltages it is always simpler if you power the sensor with the same regulated +5v used with the Pic.

Are the two voltages you use being commoned on the 0v rails.


I'm not going to detail all the possible pitfalls of doing such a project but if you post all of your code and circuit diagram then I can simulate it or even run it up on my 4520 and lm35 if I can still find it.

What I would ask is have you done any basic ADC testing ?

Have you used a 10k pot ( or greater value) and used its slider as input to RA0 with the other pins connected to +5 and 0v.
You should then be able to test some basic adc code out and as you turn the pot see the display ( a lcd?) move from 0 - 255 ; though it may flutter slightly as you move it, becoming stable once you stop moving.
 
@wp100

I branch the 10k pot, to +-5V, and branch its output to RA0, and change its values?
Is this what you mean?
 

Hi,

Like this, as you change the position of the 10k so the ADC result should change from 0 to 1023 * in relation to your variable 0v to 5v signal from the pot.

You can measure the voltage from the pot on your meter and should get a quiet accurate conversion from the ADC 10 bit reading either in hex or decimal ,depending on your coding.

* sorry my eariler replay was wrong with 0 -255 thats for an 8 bit ADC the 4520 is 10bit = 0 to 1023 decimal or 0x00 to 0x3FF hex


Adding a 100nf cap from RA0 to 0v will also help stabalize the ADC readings.

Be aware that even a digital meter can put a slight load on the ADC line so the ADC result is best checked after the meter is removed.
 

Attachments

  • 000026.jpg
    41.3 KB · Views: 106
ok wp100, thanks, I will try this tomorrow.

So after Branching this, and manipulating the values of the pot, I should read on the LCD, values ranging from 0 to 1023.
Consider this is done, what must be the next step to do?
 

ok wp100, thanks, I will try this tomorrow.

So after Branching this, and manipulating the values of the pot, I should read on the LCD, values ranging from 0 to 1023.
Consider this is done, what must be the next step to do?


Hi,

Thats the point of doing the Pot exercise, first prove your ADC port reads the Port pin ok and that your code then correctly displays the 10 bit result on the lcd.

Its easy to confirm, get a reading of 2.5v on the pots slider, remove the meter and let it do a read that should give 511 on the lcd, give of take an odd digit.

If that all works ok, then it helps define the areas your lm35 /code must be at fault.

Assume you are using a simulator, being as you cannot program a chip; which one ?
 

@wp100

I had already loaded a hex file to the mcu using university electronics lab.
How ever i give back that programmer to the vendor and order an ICd2
I hope to be helped using it
I will post you a link concerning it

- - - Updated - - -

http://www.ekt2.com/products/productdetails?ProductId=6ad143a8-c856-4392-a8bd-bf9c06875a01


Is this a solution for my problem or there is even better tool

- - - Updated - - -

Could i use this on my windows8

- - - Updated - - -

Please advice me the best one to purchase and a one you have full info about
A friendly easy to use one

- - - Updated - - -

Also to be able to program a pic18f4520
 

Hi,

BigDog has really answered your question in your other post.

All I could add to his advice is to ask what is your intended use of Pics going to be ?

If its for the more common Pic16F and Pic18F chips then a Pickit2 will be fine.

For the newer and high end Pics then a Pickit3 is the better bet as that is the current device and will get all the updates as new chips come out.

The Pk2 and Pk3 work fine with W8 32 and 64 bit from what I have read. I use W8 32bit and a PK2

That programmer you link to seems to be of the same make as your current one so if you cannot get that to work I would not be too hopeful about another one.

What is your PC, a desktop or laptop

Seems strange that you cannot load the FT232 driver ...?

Are you looking to move to W8 to cure the problem ? - if might not ..

If you have a parallel port then why not build that simple programmer I posted.
It works with the 2520, 2550 4520 and 4550 chips so you could use it to program a 2550 chip and build a simple diy version of the Pk2.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…