Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ADC produces very different values

Status
Not open for further replies.

cyrusthevirus

New Member
Okay so I have two PIC24F chips. One is setup in a prototyping environment with a breadboard. The other I am working on to put in a enclosure for use. Everything has been going great until I started to measure the temp using an LM34DZ chip. It works fine on the prototype. I get a value of 65. However on the finished product, I get a value of 127. Everything else is the same, the code, the wiring etc... What could I be missing?
 
Sounds remarkably like you've altered the the justification of the ADC results from right to left somehow. 65 with an rlf = 130, A diff. of 3 lsb can be attributed to the altered circuitry
 
Last edited:
Here is the basic code. For the schema, I have all of the basic connections with .1 caps between vdd and vss. The LM34 is connected to AN4, ground and +5V Any idea where to start looking?

Code:
void showADC(void) {
	binary_temp =0;
	int voltage =0;
	z=0;
	for (z =0; z<64 ; z++) 
		{
			delay_5msec();
	   		adcvalue = readADC(4);    //select input channel an4 pin 21
   			binary_temp = binary_temp+adcvalue;
        }   
    binary_temp = binary_temp>>6;
    voltage =0;
	voltage =binary_temp*32;
    voltage = voltage/100;   // display 2xADRESH for thermo vlaue
	binary_to_ASCIIconvert(voltage);
	binary_temp =0;
	}	

//translate temp bit pattern into Proper I/O expansion bit setting

void binary_to_ASCIIconvert( int n) {
	bcd1000=0x00;
	bcd100 =0x00;
	bcdtens =0x00;
	bcdunits =0x00;
	while (n>=1000) {
		n = n-1000;
		bcd1000 =bcd1000+1;
	}
	while (n>=100) {
		n = n-100;
		bcd100 =bcd100+1;
	}
	while (n>=10) {
		n = n-10;
		bcdtens =bcdtens+1;
	}
	bcdunits =n;
	bcd1000 =bcd1000+0x30;
	bcd100 =bcd100+0x30;
	bcdtens =bcdtens+0x30;
	bcdunits =bcdunits+0x30;
}
 
I just noticed that envreg and vcap had connections on the prototype, but not my final. Could this lead to the problem I am experiencing?
 
Hi,
If you used bread board in your prototype and now you are using PCB, it could be related with impedances... if you are using the same code, the only difference is "protype" vs "new board", and what could influence is bad wiring or impedances...

Best regards
 
cyrus, replace the sensor with a fixed resistance voltage divider and check the adc value. Then calculate if the adc is correct.

If your ref V is 5vdc and your voltage divider gives 2V then the 8 bit adc ought to be 2/5 *256 = 102.

Otherwise the adc is faulty, or your input impedance is out of spec.
 
You need one of these I didn't post resistor values because it was for 12 volts using a 5 volt chip

But if you can't figure them I'll post them for 3.3 chip in a sec.

Ok to read 5 volts
Code:
5volts <--------------------------
                                 |
                                 |
                                1K
                                 |-------1k-------- 3.3 volts 
                                 |
                                2K
                                 |
0 volts <-----------------------------------  0
 

Attachments

  • divder.JPG
    divder.JPG
    14.1 KB · Views: 167
Last edited:
Are there 0.1uf caps near all the vdd Vss pins? Filter caps on the power supply? Caps on the crystal? Geeze where are your caps man?
On the prototype I did not have any caps and it works perfect. However on the final version I have all of these caps in place and it does not work.

Amazing it works at all. A pull up on mclr might be a bonus.
I have this for when I release it, but I can not get the correct values in debug mode.


You need one of these I didn't post resistor values because it was for 12 volts using a 5 volt chip

But if you can't figure them I'll post them for 3.3 chip in a sec.

Ok to read 5 volts
Code:
5volts <--------------------------
                                 |
                                 |
                                1K
                                 |-------1k-------- 3.3 volts 
                                 |
                                2K
                                 |
0 volts <-----------------------------------  0
If my VRef is 3.3 would I have to go lower than 3.3 volts?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top