Hello everybody;
I'm using Arduino MEGA ( Chinese clone ) with two K-Type Thermocouples via MAX6675, to measure high temperature (+400° C), everything works fine, the only problem is after some time (between 5 to more than 10 minutes ) the LCD displays weird characters!
My questions are:
1- Is it because The MEGA is Chinese cheap clone?
2-Is using many SPI slave devices affect the Arduino timers in any way?
3-I'm using the latest LiquidCrystal library? I just found this in the LiquidCrystal.cpp
void LiquidCrystal::spiSendOut() //SPI #############################
{
//just in case you are using SPI for more then one device
//set bitOrder, clockDivider and dataMode each time
SPI.setClockDivider(_clockDivider);
SPI.setBitOrder(_bitOrder);
SPI.setDataMode(_dataMode);
digitalWrite(_latchPin, LOW);
SPI.transfer(_bitString);
digitalWrite(_latchPin, HIGH);
}
How can I implement this ?!
Schematics: Sorry I don't have the tools to draw the circuit now but this is how I wire it:
LCD to mega:
RS--->8
E--->9
D4--->4
D5--->5
D6--->6
D7--->7
The Clock(Sck) and Serial output (So) are common for all slave devices
Sck--->52
So--->50
Thermocouple1
Cs1--->53
Thermocouple2
Cs1--->45
I'm using External Power (9v 2A), I checked the +5v Arduino with a multimeter, It gives 4.94v
My Code:
// Sample Arduino MAX6675 Arduino Sketch
#include <LiquidCrystal.h>
#include "max6675.h"
//LCD
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//Time
unsigned long start = 0;
//ThermoCouple 1
int ktcSO = 50;
int ktcCS1 = 53;
int ktcCLK = 52;
MAX6675 thermocouple1(ktcCLK, ktcCS1, ktcSO);
//ThermoCouple 2
//int ktcSO2 = 47;
int ktcCS2 = 45;
//int ktcCLK2 = 44;
MAX6675 thermocouple2(ktcCLK, ktcCS2, ktcSO);
void setup()
{
lcd.begin(16, 2);
delay(1000);
}
void loop()
{
if (millis() - start >= 500)
{
start = millis();
lcd.clear();
lcd.print("T1 Air= ");
lcd.print(thermocouple1.readCelsius());
lcd.setCursor(0, 1);
lcd.print("T2 Air= ");
lcd.print(thermocouple2.readCelsius());
}
}
Thank you :)))