Adafruit MAX31855 With MATLab
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit MAX31855 With MATLab

by Jsph.gomez89 on Wed Feb 27, 2013 4:07 pm

Hello everyone,

I am fairly new to Arduino and MATLab, so I apologize in advance if the answer seem trivial.
I am currently doing a project that is to build a PID controller which is to use a Thermocouple as a feedback to the controler (Arduino) to control temperature of the system.

I picked up the MAX31855 breakout board and the Type-K Thermocouple and was successful in having it work with my Arduino with the MAX31855 giving readings within 1 degree C on the serial monitor of the Arduino. My big issue right now is now having to use MATLAB to plot this data in a live data plot. But under further research, I need to create an library within MATLab to us the scrips given within the tutorial of the thermocouple. Because it is a Digital output i am not sure where to even start with this kind of work. Like I said I am fairly new to the world of Arduino, MATLab,and coding.

Thank you in advance!!
Posts: 1
Joined: Wed Feb 27, 2013 3:39 pm

Re: Adafruit MAX31855 With MATLab

by Bedmonds91 on Tue Jun 21, 2016 1:07 pm

I would really like to know if this problem has been solved. Matlab's support package for Arduino has a specific way to communicate with SPI devices where you have to write in order to read. The MAX31855 thermocouple amplifier is read-only so it matlab won't let me read values.

Posts: 2
Joined: Tue Jun 21, 2016 1:04 pm

Re: Adafruit MAX31855 With MATLab

by Bedmonds91 on Thu Jun 23, 2016 5:59 pm

So I know this is a reply to a fairly old post, but after searching the entire web I didn't find an answer to this problem, which was how to read the Max31855 from a matlab script. I provided the Matlab code I used in order to plot the temperature in real time.

%Thermocouple Data
dev = spidev(a,'D10'); %Chip select pin D10, MISO is ICSP-1, SCK is ICSP-3, MOSI(not used)
for i=1:1000
dataIn = [1 1]; %write 2 pieces of info in order to receive 2 pieces of info
dataOut = writeRead(therm,dataIn,'uint16'); %uint16 is the largest integer you can use with this function therefore you need 2
bytepack=uint32(dataOut(1)); %since there are two separate pieces you need to combine them to a 32-bit integer
bytepack=bitshift(bytepack,16); %data(1) is the 1st half and is converted to uint32 and the data is shifted to the correct side.
z = bitor(bytepack,uint32(dataOut(2))); %data(2) is the 2nd half and bitor() is used to place this into the correct side of uint32
z = dec2bin(z,32); %create a 32-bit binary number
centigrade=bin2dec(z(2:14))*0.25; %from the MAX31855 datasheet, bits 18-31 is the temperature in celcius. These number are referenced backwards in matlab.
% I left out the 1st bit because it was the signed integer, which I didn't need.
% Multiplied by 0.25 since the datasheet says the LSB is 0.25°C.
%Check the adafruit Max31855 library for an in-depth look at processing these bits.
temp = [temp, centigrade];
time = [time, t];

Posts: 2
Joined: Tue Jun 21, 2016 1:04 pm

Re: Adafruit MAX31855 With MATLab

by adafruit_support_mike on Fri Jun 24, 2016 4:42 am

I'm afraid we don't have any in-house experience connecting sensors to Matlab.

The only suggestion I could give you is to put a microcontroller between Matlab and the sensor. The microcontroller can talk to the sensor, and then translate the information to an interface that's easier for Matlab to use.

Posts: 43132
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.