필터 지우기
필터 지우기

Display temperature reading of MAAX6675 on Matlab GUI via Arduino board

조회 수: 12 (최근 30일)
gdz
gdz 2022년 12월 13일
댓글: Bora Eryilmaz 2024년 6월 3일
A temperature module called MAX6675, which is used for measuring the temperature of K-type thermocouple is connected to the Arduino Uno. The MAX_6675 library is downloaded from Arduino and it is working well in Arduino, but now i would like to display the temeparature reading on MATLAB GUI. From my previous project, I connect MATLAB to the arduino, and I used readVoltage(A0) to display the voltage of my equipment. However, for MAX6675, they are using SPI to display the temperature, rather than using analog pin. I have searching for several days but I still do not have any idea. Does anyone have any idea?
By now, I guess I need to first update the MAX_6675 library (a header file and a c code) to the Matlab. So that, the thermocouple.readCelcius() function can be used on Matlab?
Thank you.

답변 (1개)

Bora Eryilmaz
Bora Eryilmaz 2022년 12월 13일
편집: Bora Eryilmaz 2022년 12월 13일
  댓글 수: 2
Andrew
Andrew 2024년 5월 31일
We have a k-type thermocouple that is connected to the MAX6675 board that is then connected to our arduino mega 2560 which is connected to matlab. The SO pin is in D42, the SCK is in D52, the CS pin is in D50, the VCC is connected to the 5Volts and the GND is connected to the ground. The code we were using so far only is outputting 0 no matter what we try. We know the sensor is working after testing it on the arduino ide software, so there is something wrong with our code and how we are sending/recieving data from the arduino. Any help is apperciated. This code was from another post here on matlab, we think the issue is with datOut, it only has been 0 the whole time we have been testing with it.
% KTYPE.m This example is based on the reference manual of the MAX6675 amplifier
% LED Versuch
clear all, close all
%ComPort = getAvailableComPort
a = arduino('COM3','Uno','Libraries','SPI');
dev = device(a,'SPIChipSelectPin','D8');
MAX6675 = device(a,'SPIChipSelectPin','D10');
tmax= 30;
fs = 1;
dt = 1/fs;
t = [dt:dt:tmax];
il = length(t);
T = zeros(il,1);
dummy = [uint8(0),uint8(0)];
for i=1:il
datOut = writeRead(MAX6675,dummy); % Read MAX6675
pause(0.5)
BINR = [dec2bin(datOut(1),8), dec2bin(datOut(2),8)]; % Show the bits of the read
DECR = bin2dec(BINR);
DECT = bitshift(DECR,-3); % Shift by 3 bits to the right
BINT = dec2bin(DECT); % Just to show the change
MP = 255/1023.75; % Reading 0 means 0°C,
% Reading 255 its hot as 1023.75°C
T(i,1) = MP*DECT; % Factor to get °C
disp(T(i,:))
end
Bora Eryilmaz
Bora Eryilmaz 2024년 6월 3일
The SPIs ports you have listed do not seem fully correct. I think you need:
  • D50 (PB3 port) for CIPO
  • D52 (PB1 port) for SCK
  • D53 (PB0 port) for nSS
You may also need to set the clock polarity/phase using the SPIMode input argument when you create the MAX6675 device. The default mode is 0, but this device might need mode 1 instead.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by