I am using an UNO with I2C LCD and SPI thermocouple module based on MAX6675 to make a temperature controller for an AC heater.
The other hardware arrangement includes one opto-coupler to detect zero-crossing and other for driving a triac. Both of them are working fine.
The problem is that the real temperature of the heater is not being updated on the LCD. The MAX6675 is working fine because when I reset the UNO, the temperature gets updated.
pert:
If you open the Arduino IDE's Serial Monitor while your program is running, do you see the expected output?
No, same output in the serial monitor.
It is very strange, even when I switch off the 220V AC mains (no zero crossing) there is no update in the temperature display though there are only 2 code lines functional in the void loop.
Please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded the max6675 library from. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.
What happens if you run a minimal sketch that only reads the thermocouple module and prints it repeatedly to the Serial Monitor?
I would try moving the CS pin of the Max chip from pin 12 to pin 10 and recompile. Pin 12 is assigned in hardware as the SPI MOSI pin and is probably in conflict with your reassignment as the chip select.
pert:
Please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded the max6675 library from. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.
I had installed MAX6675 Library by Adafruit version 1.0.0 using Library Manager.
What happens if you run a minimal sketch that only reads the thermocouple module and prints it repeatedly to the Serial Monitor?
I have already mentioned that when I switch off the 220V AC mains, only temperatures are to be read and displayed. But they are not being updated.
WattsThat:
I would try moving the CS pin of the Max chip from pin 12 to pin 10 and recompile. Pin 12 is assigned in hardware as the SPI MOSI pin and is probably in conflict with your reassignment as the chip select.
Maybe you are right, I will check that tomorrow morning.
However, it has been working perfectly fine since last one week. The strange behavior occurred today afternoon.
Don't get confused here. I meant to say that the thermocouple module has been working fine with simple test codes. I have checked it again with minimum code, it is performing perfectly.
The heater controller code which I included in the original post is still at debugging stage. In that code, the actual temperature (sensed by MAX6675) is not being updated after entering the void loop(). The target temperature set by the POT is updated.
The MAX6675 is not fast enough to respond so quickly.
I included a 500ms delay and now it working. Though I need to tweak the code to minimize the temperature oscillation around the set point.