SPI MAX6675 Simulink

Hallo zusammen,

ich habe mir 12 MAX6675 geholt und würde das ganze gerne mit Simulink weiter verarbeiten, da ich bereits den Rest hier abgearbeitet habe...

Die generelle Programmierung in der IDE habe ich verstanden nur wie ich das in Simulink umsetzen kann ist mir leider noch nicht wirklich klar.

Mit dem Support-Package, das mir zur Verfügung steht, habe ich einen SPI-Block zur Verfügung (Anhang, sowie die anderen verfügbaren Blöcke im anderen Bild).

Wie verknüpfe ich das ganze am besten bzw. wie geht man generell damit in Simulink vor wenn man etwas mit einem Arduino und SPI machen möchte? (das Beispiel, welches im Package vorhanden ist, ist meiner Meinung nach mehr als unverständlich)

SPI.PNG

Bloecke.PNG

Niemand? ^^

Oder soll ich damit ins Matlab-Forum am besten?

TW1993:
....
Die generelle Programmierung in der IDE habe ich verstanden nur wie ich das in Simulink umsetzen kann ist mir leider noch nicht wirklich klar.

Und warum machst du es nicht mit der IDE ?

Oder soll ich damit ins Matlab-Forum am besten?

Wenn du es mit Simulink machen willst, dann ja.

Da das ganze in IDE nicht gerne gesehen ist in der Firma und Matlab/Simulink das Mittel der Wahl sein soll...

trotzdem danke :slight_smile:

Wenn jmd doch Rat weiß oder wie ich das mit einem S-Function-Block abhandeln kann, würde ich gerne davon erfahren :slight_smile:

Hi

Dito, wenn Du 'dort' Deiner Lösung näher kommst - man wird ja nicht dümmer, wenn man sich andere Lösungen anschau(t/en darf).

MfG

Cross-Posting ist halt nicht gerne gesehen deshalb die Frage diesbezüglich.

aber wirklich keiner eine Ahnung hier wie ich meinen Code für 12 MAX6675 in einen S-Function-Block einfügen kann und diesen dann verwende

#include "max6675.h"

int thermoDO = 50;
int thermoCLK = 52;


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(thermoCLK, MAX1_CS, thermoDO);
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);
}