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
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;
}
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...