Mein Arduino-Code:
#include "max6675.h"
//SPI-Pins
int thermoDO = 50;
int thermoCLK = 52;
// CS-Pins
int MAX1_CS = 24;
//int MAX2_CS = 25;
//int MAX3_CS = 26;
//int MAX4_CS = 27;
//int MAX5_CS = 28;
//int MAX6_CS = 29;
//int MAX7_CS = 30;
//int MAX8_CS = 31;
//int MAX9_CS = 32;
//int MAX10_CS = 33;
//int MAX11_CS = 34;
//int MAX12_CS = 35;
MAX6675 thermocouple1(52, 24, 50);
//MAX6675 thermocouple2(thermoCLK, MAX2_CS, thermoDO);
//MAX6675 thermocouple3(thermoCLK, MAX3_CS, thermoDO);
//MAX6675 thermocouple4(thermoCLK, MAX4_CS, thermoDO);
//MAX6675 thermocouple5(thermoCLK, MAX5_CS, thermoDO);
//MAX6675 thermocouple6(thermoCLK, MAX6_CS, thermoDO);
//MAX6675 thermocouple7(thermoCLK, MAX7_CS, thermoDO);
//MAX6675 thermocouple8(thermoCLK, MAX8_CS, thermoDO);
//MAX6675 thermocouple9(thermoCLK, MAX9_CS, thermoDO);
//MAX6675 thermocouple10(thermoCLK, MAX10_CS, thermoDO);
//MAX6675 thermocouple11(thermoCLK, MAX11_CS, thermoDO);
//MAX6675 thermocouple12(thermoCLK, MAX12_CS, thermoDO);
//int vccPin = 3;
//int gndPin = 2;
void setup() {
Serial.begin(9600);
// use Arduino pins
// pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
// pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
Serial.println("MAX6675 test");
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
// basic readout test, just print the current temp
//
Serial.print("C1 = ");
Serial.println(thermocouple1.readCelsius());
// Serial.print("C2 = ");
// Serial.println(thermocouple2.readCelsius());
// Serial.print("C3 = ");
// Serial.println(thermocouple3.readCelsius());
// Serial.print("C4 = ");
// Serial.println(thermocouple4.readCelsius());
// Serial.print("C5= ");
// Serial.println(thermocouple5.readCelsius());
// Serial.print("C6 = ");
// Serial.println(thermocouple6.readCelsius());
// Serial.print("C7 = ");
// Serial.println(thermocouple7.readCelsius());
// Serial.print("C8 = ");
// Serial.println(thermocouple8.readCelsius());
// Serial.print("C9 = ");
// Serial.println(thermocouple9.readCelsius());
// Serial.print("C10 = ");
// Serial.println(thermocouple10.readCelsius());
// Serial.print("C11 = ");
// Serial.println(thermocouple11.readCelsius());
// Serial.print("C12 = ");
// Serial.println(thermocouple12.readCelsius());
//
//
delay(1000);
}
Matlab-Code (erstmal für einen MAX6675):
/*
* Include Files
*
*/
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#include <math.h>
#ifndef MATLAB_MEX_FILE
#include <Arduino.h>
#include "max6675.cpp"
int CLK=52;
int CS=50;
int SO=24;
MAX6675 thermocouple (CLK,CS,SO);
#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define y_width 1
/*
* Create external references here.
*
*/
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* extern double func(double a); */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */
/*
* Output functions
*
*/
extern "C" void T_6_1_Outputs_wrapper(real_T *Celsius,
const real_T *xD,
const int8_T *CS, const int_T p_width0,
const int8_T *CLK, const int_T p_width1,
const int8_T *SO, const int_T p_width2)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
if (xD[0] ==1)
{
#ifndef MATLAB_MEX_FILE
Celsius[0]= thermocouple.readCelsius();
#endif
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
/*
* Updates function
*
*/
extern "C" void T_6_1_Update_wrapper(real_T *Celsius,
real_T *xD,
const int8_T *CS, const int_T p_width0,
const int8_T *CLK, const int_T p_width1,
const int8_T *SO, const int_T p_width2)
{
/* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
if (xD[0]!=0)
{
#ifndef MATLAB_MEX_FILE
Serial.begin(9600);
xD[0]=1;
#endif
}
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}
Also wie gesagt der Code in der IDE funktioniert (!!!), hätte ihn halt nur gerne in Simulink auch am laufen