- https://www.mathworks.com/help/supportpkg/arduinoio/ref/matlabshared.spi.device.html
- https://www.mathworks.com/help/supportpkg/arduinoio/ref/writeread.html
Display temperature reading of MAAX6675 on Matlab GUI via Arduino board
12 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Bora Eryilmaz
2022-12-13
编辑:Bora Eryilmaz
2022-12-13
You will have to use the SPI interface of the Arduino support package to configure access to MAX6675:
Also this example might be helpful: https://www.mathworks.com/help/supportpkg/arduinoio/ug/communicate-with-spi-device-on-arduino-hardware.html
2 个评论
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
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 Center 和 File Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!