Connessione Arduino due e modulo MAX31685 2Ch per PT1000

Buongiorno a tutti, ho dovuto comperare questo modulo

per la lettura di due RTD PT1000 collegate ad un serbatoio.

Ho scaricato il codice di esempio dal sito del produttore, ma penso di aver qualche problema con la connessione ad arduino due, ho googlato ma non trovo nulla (probabilmente cerco la cosa sbagliata).

Questa è la parte in cui spiegano le connessioni ad arduino

* **************************************************************************
* ADDITIONAL NOTES:
* This file configures then runs a program on an Arduino Uno to read a 2-ch
* MAX31865 RTD-to-digital converter breakout board and print results to
* a serial port. Communication is via SPI built-in library.
*    - Configure Arduino Uno
*    - Configure and read resistances and statuses from MAX31865 IC 
*      - Write config registers (MAX31865 starts up in a low-power state)
*      - RTD resistance register
*      - High and low status thresholds 
*      - Fault statuses
*    - Write formatted information to serial port
*  Circuit:
*    Arduino Uno   Arduino Mega  -->  SEN-30201
*    CS0: pin  9   CS0: pin  9   -->  CS, CH0
*    CS1: pin 10   CS1: pin 10   -->  CS, CH1
*    MOSI: pin 11  MOSI: pin 51  -->  SDI (must not be changed for hardware SPI)
*    MISO: pin 12  MISO: pin 50  -->  SDO (must not be changed for hardware SPI)
*    SCK:  pin 13  SCK:  pin 52  -->  SCLK (must not be changed for hardware SPI)
*    GND           GND           -->  GND
*    5V            5V            -->  Vin (supply with same voltage as Arduino I/O, 5V)
***************************************************************************/

Ma io non riesco a capire a quali corrispondono sul modulo dato che alcune scritte non corrispondono esattamente. (Scusate ma non sono molto esperto in elettronica).

Perchè hai confuso la DUE con la MEGA non sono compatibili, sono molto differenti

pin layout DUE
http://forum.arduino.cc/index.php?topic=132130.0

pin layout MEGA2560

Che pirla che sono, grazie mille, il problema è che ho provato anche con arduino uno comprato un mese fa e non funziona con i collegamenti che faccio..

Sicuramente si riesce a farla funzionare sulla DUE, ma è un lavoraccio a livello software soprattutto.

Ti conviene adattarlo alla UNO a sto punto, però nel datasheet non vedo MISO e MOSI ....

Hai provato qui
http://forum.arduino.cc/index.php?topic=229530.0
c'è anche scritto [solved]

Il problema è che ne devo collegare 4 di queste schede ad arduino ed in più un display seriale... non so se magari sto sbagliando idea nel realizzare il tutto...

Che sia una o siano 4 cambia poco, alla fine ne legge una alla volta in sequenza, il MISO MOSI e CLK sono in parallelo, avrai 4 pin CS che abiliteranno quale scheda deve essere ascoltata.

Intanto prova con una

SPI Esso si basa su 4 segnali (si riportano i nomi dei segnali che possono variare a seconda del costruttore. Consultare il datasheet del componente che si intende utilizzare in caso di dubbi):

SCLK - SCK: Serial Clock (emesso dal master)
SDI – MISO – SOMI – DI - SI: Serial Data Input, Master Input Slave Output (ingresso per il master ed uscita per lo slave)
SDO – MOSI – SIMO – DO – SO: Serial Data Output, Master Output Slave Input (uscita dal master)
CS – SS – nCS – nSS – STE: Chip Select, Slave Select, emesso dal master per scegliere con quale dispositivo slave vuole comunicare (dalla figura, il segnale con la sbarretta sui caratteri SS, si comprende che per comunicare con il dispositivo slave deve venire messo a livello logico basso)

fonte

quindi il tuo
SDI sarebbe MISO
SDO sarebbe MOSI

vedi che ci sono anche esempi di collegamento con più slave.

PS: Non puoi usare cavi lunghi per questo tipo di connessione ...

Questa è la connessione con cui lo testo,

e questo è il codice fornito dal produttore

// the sensor communicates using SPI, so include the hardware SPI library:
#include <SPI.h>
// include Playing With Fusion MAX31865 libraries
#include <PlayingWithFusion_MAX31865.h>              // core library
#include <PlayingWithFusion_MAX31865_STRUCT.h>       // struct library

// CS pin used for the connection with the sensor
// other connections are controlled by the SPI library)
const int CS0_PIN = 9;
const int CS1_PIN = 10;

PWFusion_MAX31865_RTD rtd_ch0(CS0_PIN);
PWFusion_MAX31865_RTD rtd_ch1(CS1_PIN);

void setup() {
  Serial.begin(115200);

  // setup for the the SPI library:
  SPI.begin();                            // begin SPI
  SPI.setClockDivider(SPI_CLOCK_DIV16);   // SPI speed to SPI_CLOCK_DIV16 (1MHz)
  SPI.setDataMode(SPI_MODE3);             // MAX31865 works in MODE1 or MODE3
  
  // initalize the chip select pin
  pinMode(CS0_PIN, OUTPUT);
  pinMode(CS1_PIN, OUTPUT);
  rtd_ch0.MAX31865_config();
  rtd_ch1.MAX31865_config();
  
  // give the sensor time to set up
  delay(100);
}


void loop() 
{
  delay(1500);                                   // 1500ms delay... can be much faster
  

  static struct var_max31865 RTD_CH0;
  static struct var_max31865 RTD_CH1;
  double tmp;
  
  //RTD_CH0.RTD_type = 1;                         // un-comment for PT100 RTD
  RTD_CH0.RTD_type = 2;                        // un-comment for PT1000 RTD
  //RTD_CH1.RTD_type = 1;                         // un-comment for PT100 RTD
  RTD_CH1.RTD_type = 2;                        // un-comment for PT1000 RTD
  
  struct var_max31865 *rtd_ptr;
  rtd_ptr = &RTD_CH0;
  rtd_ch0.MAX31865_full_read(rtd_ptr);          // Update MAX31855 readings 
  
  rtd_ptr = &RTD_CH1;
  rtd_ch1.MAX31865_full_read(rtd_ptr);          // Update MAX31855 readings 
  
  // ******************** Print RTD 0 Information ********************
  Serial.println("RTD Sensor 0:");              // Print RTD0 header
  
  if(0 == RTD_CH0.status)                       // no fault, print info to serial port
  {
    if(1 == RTD_CH0.RTD_type)                   // handle values for PT100
    {
      // calculate RTD resistance
      tmp = (double)RTD_CH0.rtd_res_raw * 400 / 32768;
      Serial.print("Rrtd = ");                  // print RTD resistance heading
      Serial.print(tmp);                        // print RTD resistance
    }
    else if(2 == RTD_CH0.RTD_type)              // handle values for PT1000
    {
      // calculate RTD resistance
      tmp = (double)RTD_CH0.rtd_res_raw * 4000 / 32768;
      Serial.print("Rrtd = ");                  // print RTD resistance heading
      Serial.print(tmp);                        // print RTD resistance
    }
    Serial.println(" ohm");
    // calculate RTD temperature (simple calc, +/- 2 deg C from -100C to 100C)
    // more accurate curve can be used outside that range
    tmp = ((double)RTD_CH0.rtd_res_raw / 32) - 256;
    Serial.print("Trtd = ");                    // print RTD temperature heading
    Serial.print(tmp);                          // print RTD resistance
    Serial.println(" deg C");                   // print RTD temperature heading
  }  // end of no-fault handling
  else 
  {
    Serial.print("RTD Fault, register: ");
    Serial.print(RTD_CH0.status);
    if(0x80 & RTD_CH0.status)
    {
      Serial.println("RTD High Threshold Met");  // RTD high threshold fault
    }
    else if(0x40 & RTD_CH0.status)
    {
      Serial.println("RTD Low Threshold Met");   // RTD low threshold fault
    }
    else if(0x20 & RTD_CH0.status)
    {
      Serial.println("REFin- > 0.85 x Vbias");   // REFin- > 0.85 x Vbias
    }
    else if(0x10 & RTD_CH0.status)
    {
      Serial.println("FORCE- open");             // REFin- < 0.85 x Vbias, FORCE- open
    }
    else if(0x08 & RTD_CH0.status)
    {
      Serial.println("FORCE- open");             // RTDin- < 0.85 x Vbias, FORCE- open
    }
    else if(0x04 & RTD_CH0.status)
    {
      Serial.println("Over/Under voltage fault");  // overvoltage/undervoltage fault
    }
    else
    {
      Serial.println("Unknown fault, check connection"); // print RTD temperature heading
    }
  }  // end of fault handling
  
  
  // ******************** Print RTD 1 Information ********************
  Serial.println("RTD Sensor 1:");              // Print RTD0 header
  
  if(0 == RTD_CH1.status)                       // no fault, print info to serial port
  {
    if(1 == RTD_CH1.RTD_type)                   // handle values for PT100
    {
      // calculate RTD resistance
      tmp = (double)RTD_CH1.rtd_res_raw * 400 / 32768;
      Serial.print("Rrtd = ");                  // print RTD resistance heading
      Serial.print(tmp);                        // print RTD resistance
    }
    else if(2 == RTD_CH1.RTD_type)              // handle values for PT1000
    {
      // calculate RTD resistance
      tmp = (double)RTD_CH1.rtd_res_raw * 4000 / 32768;
      Serial.print("Rrtd = ");                  // print RTD resistance heading
      Serial.print(tmp);                        // print RTD resistance
    }
    Serial.println(" ohm");
    // calculate RTD temperature (simple calc, +/- 2 deg C from -100C to 100C)
    // more accurate curve can be used outside that range
    tmp = ((double)RTD_CH1.rtd_res_raw / 32) - 256;
    Serial.print("Trtd = ");                    // print RTD temperature heading
    Serial.print(tmp);                          // print RTD resistance
    Serial.println(" deg C");                   // print RTD temperature heading
  }  // end of no-fault handling
  else 
  {
    Serial.print("RTD Fault, register: ");
    Serial.print(RTD_CH1.status);
    if(0x80 & RTD_CH1.status)
    {
      Serial.println("RTD High Threshold Met");  // RTD high threshold fault
    }
    else if(0x40 & RTD_CH1.status)
    {
      Serial.println("RTD Low Threshold Met");   // RTD low threshold fault
    }
    else if(0x20 & RTD_CH1.status)
    {
      Serial.println("REFin- > 0.85 x Vbias");   // REFin- > 0.85 x Vbias
    }
    else if(0x10 & RTD_CH1.status)
    {
      Serial.println("FORCE- open");             // REFin- < 0.85 x Vbias, FORCE- open
    }
    else if(0x08 & RTD_CH1.status)
    {
      Serial.println("FORCE- open");             // RTDin- < 0.85 x Vbias, FORCE- open
    }
    else if(0x04 & RTD_CH1.status)
    {
      Serial.println("Over/Under voltage fault");  // overvoltage/undervoltage fault
    }
    else
    {
      Serial.println("Unknown fault, check connection"); // print RTD temperature heading
    }
  }  // end of fault handling
  
}

Il produttore mi scrive questo..

"The chip select lines are OK as you have them wired. Vin should be connected to 3.3V. I looked at the Due config, and it does not have SPI lines running to the same places as the Uno or Mega. You need to connect MOSI, MISO and SCK to the 6-pin ICSP header."

Quindi guardando la foto in allegato è corretto?

Si, ma era corretto anche prima sul 13-12-11

Vin should be connected to 3.3V.

ti dice che il MAX va alimentato a 3.3 e ovviamente i GND in comune

L'unica cosa è che non so se serve un level shifter 5v to 3.3v o i maxim ha già un partitore, perchè è logico che se va alimentato a 3.3v i segnali che escono dal MAX saranno a 3.3 ed entrano in un micro 328 che ne vuole massimo 5v, però l'MCU 328 manda segnali a 5v verso il MAX e questo non è buono se non c'è un partitore.

Tipo questo? (Ovviamente Arduino UNO non Leonardo)

o tipo
https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide

Perfetto sono riuscito a farla funzionare non serve nient'altro oltre alla board! Per farla funzionare occorre alimentare il tutto a 5V ed utilizzare gli appositi pin MISO MOSI e SCK (i sei pin al centro di arduino, vedi allegato). Quindi perfetto! Ringrazio molto Pablos per essere sempre a disposizione di tutti e Justin di playingwithfusion per il supporto.

Ora per collegarne 4 di queste board utilizzo sempre i stessi MISO MOSI ed SCK?

non serve nient'altro oltre alla board

Su questo non sapevo dirti con esattezza se i livelli vengono abbassati da partitori o meno presenti sul MAX, non potevo nemmeno dirti tranquillo non serve uno shift level :sunglasses:

Ora per collegarne 4 di queste board utilizzo sempre i stessi MISO MOSI ed SCK?

si, i CS saranno 4 diversi, ora sta tutto al software gestire le 4 schedine

ciao