Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Interfacing MAX31855 with PIC

Status
Not open for further replies.

Sajjadkhan

Full Member level 5
Joined
Sep 25, 2010
Messages
307
Helped
17
Reputation
34
Reaction score
16
Trophy points
1,298
Location
Rawalpindi,Pakistan
Activity points
4,199
Hi all,
I am interfacing MAX31855 thermocouple IC with PIC16f882. I am using MikroC pro for PIC.

Reading the output gives a 32bit number which i stored in " unsigned long temp". useful bits for me are D30 to D18. and i have no idea how to extract this from 32bit number. Any help would be appreciated, thanks.
 

hello,

so your raw measure M is D31 ....D0 bits

try this :

Code:
unsigned int Result ;
unsigned long int M;
M= your raw measure ;
Result=(unsigned int) (M >>18)  & 0x7FFF;
 

Hi again. thanks for the help. Now i m able to out some numbers but the problem is they are all jumpy. Not stable at all (nowhere near the ambient). some time 2 and sometime 3 digits. thermocouple is just 5 inch long wire. yes i have included 10nF cap at T+ and T- terminals. 3.3V stable input.

I have removed the thermocouple and tried to read internal ic temperature and same case. I m going nuts. here is a part of my code. temp1 and temp2 for thermocouple last 16bits are not needed. same goes foe internal temperature, 16 MSBs not needed.

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void main() 
     {
 
     INTCON = 0b10010000;            OPTION_REG = 0b11000000;
     TRISA = 0; TRISB = 0b11111111; TRISC = 0;
     SSPCON = 0b00100000;
 
     ANSEL = 0; ANSELH = 0;
     SPI1_Init();
     temp = 0;
     while (1)
           {
           CS = 0;
           delay_ms(5);
           temp1 = SPI1_READ(buffer);
           temp2 = SPI1_READ(buffer);
           temp3 = SPI1_READ(buffer);
           temp4 = SPI1_READ(buffer);
 
           CS = 1;
           temp = (temp3*256)+temp4;
           temp = temp >> 4;
           
           display();
           }
     }

 
Last edited by a moderator:

Looking at the data sheet for the MAX31855, Figure 12 shows that the device uses the common bit ordering of MSB first. It also says that the top 12 bits of the 32-bit value contain the temperature and the bottom 16 bits contain the reference junction temperature as shows in Table 2.
Therefore, when you read the 4 8-bit values, you should be using 'temp1' and 'temp2' for the temperature rather than 'temp3' and 'temp4' as you ha vein the above code.
You also need to swap the two tempx variables around to be something like '((temp1*256l + temp2) >> 2) & 0x3fff'.
Also you need to be sure that the compiler is correctly promotes the values as part of the calculation. Not sure about the MikroC compiler but if 'temp1' is declared as a byte (you don't tell us what is really is) and you simply multiply by "256" then it could perform byte-level multiplication to give you a byte level value. That is why I specify '256l' to force that value to be 'long' which makes sure that all other parts of the calculation will be 'long' as well, no matter what the declared size of the result.
Susan
 

ok, everything runs fine now except i have one issue.

When i bring my hand close or touch the thermocouple or touch soldering iron to the thermocouple, the temperature immediately drops to zero and after 5 to 10 seconds everything goes to normal. I have a 10nF cap installed near T+ and T-.
 

Are you using a breadboard or a PCB?
Either way this sounds to me like a bad connection somewhere.
Why are you touching a 'live' thermocouple with a soldering iron?????
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top