Hi,
I am trying to set up an SD card reader and MAX6675 thermocouple on an UNO R3. I have the two SPI units sharing the same SCLK, MISO with the SD card on CS pin 10 and the MAX 6675 on CS 2.
The Thermocouple seems to work fine but as soon as I initialise the SD card I get zero returned by the thermocouple.
In the code below, the Serial terminal displays
MAX6675 Initialise
C=23.5
again C= 0.0
It appears that the initialisation of the SD card makes the MAX6675 not be able to read any more. I have looked through the MAX 6675 and SD .h and .cpp files and cant really see why, other than perhaps that the SD.cpp seems to set the SPI speed to SPI_HALF_SPEED, I cannot find a corresponding entry in the MAX6675.cpp. Could this be the root of the problem?
The SD card works fine.
Anyway, my code is attached as a txt file.
Struggling to get to grips with the specifics of daisy chaining SPI devices and relatively new to the Arduino world so I would appreciate any advice you could give.
figured out how to paste the code into the thread!!
#include <DS3231.h>
#include <SPI.h>
#include <SD.h>
#include <max6675.h>
const int thermoDO = 12;
const int thermoCS = 2;
const int thermoCLK = 13;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
File eventList; // FILE pointer for eventLst file
DS3231 rtc(SDA, SCL); // Define rtc
const int Red=3;
const int Green=5;
const int Blue=6;
byte nextEventFlag[13]; // array to hold the pointer to the next event on the list aiming to impliment multiple events for all channels
byte activeEventPointer[13]; // ppinters to show which of the 2 d array is active for any channel
float intensity[13]; // array that holds the calculated intensity for each channel
float output; // variable used to calculate the normalisation setting for the overall output once scaled to each channels individual intensity setting
long refTime[13]; // array to hold a list of event start times
long duration[13]; // array to hold the duration of each event
float maxIntensity[13]; // array to hold a list of maximum intensities
const char* filename = {"eventlis.csv"}; // file to hold list of events
long startTime;
int i;
int flag = 1;
const float pi = 3.14159;
void setup() {
Serial.begin(9600);
Serial.println("MAX6675 Initialise");
delay(500);
digitalWrite(thermoCS,LOW); // forcing CS for 6675 low although looking at MAX6675.cpp, it looks as if this is not needed
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
digitalWrite(thermoCS,HIGH); // forcing CS for 6675 HIGH although looking at MAX6675.cpp, it looks as if this is not needed
delay(2000);
pinMode(Red, OUTPUT);
pinMode(Green, OUTPUT);
pinMode(Blue, OUTPUT);
rtc.begin(); // start real time clock stream
if (!SD.begin(10)) {
Serial.println("initialization failed!");
}
digitalWrite(10,HIGH); // trying to force the sd card to release the SPI bus but making its CS pin high
digitalWrite(thermoCS,LOW);
Serial.print("again C = ");
Serial.println(thermocouple.readCelsius());
digitalWrite(thermoCS,HIGH);
delay(500);
I've read through that post but I am not sure that is it as the thermocouple read works ok until I initialise the SD card. The electronic prescence of the SD card reader does not seem to affect the 6675, but once there is activity on the SD card, the 6675 doesn't work again.
As I had nothing to lose, I have made the HW modifications suggested to the SD card reader (very very fiddley) but it has not changed anything I'm afraid. There is a suggestion about putting a diode in line with the miso from the sd card but that makes no difference and I also tried modifying the SD.h and .cpp files with some guidance found on the forum here allowing the selection of spi speed as the default is quarter speed but the sd library calls for half speed. Anyway, none of these have worked so I downloaded the adafruit sd library (sd-master). also no difference. So it si all back the way it was with the exception of the desoldered and bridged pi n on the sd card chip. all working as it was originally. huff