MAX31855 PID heating issue

Been dealing with an issue on a heating/automation project I’ve been working on for several months now.

General plan is to heat 14 different zones on a vacuum chamber using 120V AC through high resistance wire regulated by solid state relays controlled by the arduino using a PID loop monitored by the MAX31855 system.

First, we had issues getting all 14 thermocouple boards reading, and ended up finding out that both the DO and CS lines need to be separate when you get above say 5 or so boards since things start to get strange.

At one point we switched to AD8495 analog thermocouple boards, but since we are using RF generated plasma in our chamber, we ran into grounding issues that the digital boards did not have, so we ended going back to digital.

The strange part is that with the analog, heating worked fine but not the thermocouples, but with digital, the thermocouple readings work fine but the heating is extremely delayed. Namely, it takes nearly 30 seconds per heating cycle versus the two seconds it took with analog.

I’m hoping someone can tell me looking at the code, what the issue is. Take in mind, I am not into coding, so please excuse my sloppy code. I am using a web based program to control and display the data by the way, so you might see code for that.

Any help is much appreciated!

PID_Final_3.ino (5.88 KB)

First, we had issues getting all 14 thermocouple boards reading, and ended up finding out that both the DO and CS lines need to be separate when you get above say 5 or so boards since things start to get strange.

The SO (I guess that meant that signal by "DO") and the CS signal must be separated in every case even if you just use one board. I see no chance to combine these signals.

The strange part is that with the analog, heating worked fine but not the thermocouples, but with digital, the thermocouple readings work fine but the heating is extremely delayed. Namely, it takes nearly 30 seconds per heating cycle versus the two seconds it took with analog.

I strongly guess that this is caused by code differences/errors. But I'm not sure I understand what you write. What is a heating cycle in this context?

pylon: The SO (I guess that meant that signal by "DO") and the CS signal must be separated in every case even if you just use one board. I see no chance to combine these signals.

That's exactly what I was thinking to be honest, but it worked combined on two or three, but the readings would be slightly higher. Once separated, everything worked fine. I just had another co-worker who insisted that these could be combined.... glad to hear my hunch was correct!

I strongly guess that this is caused by code differences/errors. But I'm not sure I understand what you write. What is a heating cycle in this context?

Great question! Basically, one loop reads the temperature value from each MAX31855 and passes the data into an array for the PID loop. The pid loop calculates whether or not that zone needs to be "on" or "off". The window size variable dictates how long the heating stays on. Say, if the pid formula sets the value to 50%, the relay is triggered for half of the window time. All of these are recalculated each loop for each of the 14 zones.

As far as getting more specific, please let me know what you're hung up on. Admittedly, most of the code was not written by me, but my colleague.

His thought is that the clock cycle is too slow and that the propagation delay is causing the loop to "skip over" the "on" value. Personally, I think that is bogus, and that it has more to do with errors, or the fact that the MAX31855 doesn't read as often as the analog boards did.

Any thoughts on what to try next?

Thanks for the response btw! Hopefully it's just some dumb error.

I just had another co-worker who insisted that these could be combined.... glad to hear my hunch was correct!

The two signals have a totally different function so combining them into one wire will never work.

Basically, one loop reads the temperature value from each MAX31855 and passes the data into an array for the PID loop. The pid loop calculates whether or not that zone needs to be "on" or "off". The window size variable dictates how long the heating stays on. Say, if the pid formula sets the value to 50%, the relay is triggered for half of the window time. All of these are recalculated each loop for each of the 14 zones.

I figured that out by reading the code. But I still don't know what you mean by "heating cycle".

His thought is that the clock cycle is too slow and that the propagation delay is causing the loop to "skip over" the "on" value. Personally, I think that is bogus, and that it has more to do with errors, or the fact that the MAX31855 doesn't read as often as the analog boards did.

The window size is 3 seconds, I see no reason why a 16MHz processor shouldn't be able to calculate 14 PIDs with 3 seconds even if it has to read a few SPI signals in the same loop. You can read the 32bits of the MAX31855 about 100000 times a second, reading the ADC of the Arduino is definitely slower.

How did you realize or better how did you think you realized that that loop is getting slower? Did you check the serial output? Did you check the heating outputs?

pylon: The two signals have a totally different function so combining them into one wire will never work.

I figured that out by reading the code. But I still don't know what you mean by "heating cycle".

The window size is 3 seconds, I see no reason why a 16MHz processor shouldn't be able to calculate 14 PIDs with 3 seconds even if it has to read a few SPI signals in the same loop. You can read the 32bits of the MAX31855 about 100000 times a second, reading the ADC of the Arduino is definitely slower.

How did you realize or better how did you think you realized that that loop is getting slower? Did you check the serial output? Did you check the heating outputs?

I completely agree. I thought it absurd to think the clock or arduino is "too slow". Basically, the relays have an led light to indicate when they are on, and I have manually checked the temperature readouts. They blink at the same rate as analog, but only every 30 seconds or so when it used to be every second or so. The zones only heat up by a few degrees since it's so long in between cycles. I've checked, and the current and voltage is the same for both digital and analog. Strange

On further thought, the max time for conversion of the MAX31855 is 100ms. Could this be causing it to "miss" the loop?

On further thought, the max time for conversion of the MAX31855 is 100ms. Could this be causing it to “miss” the loop?

That is how long it takes to get a new temperature (you get it about 10 times a second) but it can be read in a much higher frequency. The chip has no ability to block the reading to make everything slower.

I thought it absurd to think the clock or arduino is “too slow”. Basically, the relays have an led light to indicate when they are on, and I have manually checked the temperature readouts. They blink at the same rate as analog, but only every 30 seconds or so when it used to be every second or so. The zones only heat up by a few degrees since it’s so long in between cycles. I’ve checked, and the current and voltage is the same for both digital and analog.

Post the code you used for the analog version. I would have expected the relays to “blink” once every 3 seconds. But as you do the calculations much faster in the digital version the PID algorithm may react differently. Did you check the temperature readings on the serial output? Are they changing that much? Post that output to give us an impression.

pylon: That is how long it takes to get a new temperature (you get it about 10 times a second) but it can be read in a much higher frequency. The chip has no ability to block the reading to make everything slower.

Post the code you used for the analog version. I would have expected the relays to "blink" once every 3 seconds. But as you do the calculations much faster in the digital version the PID algorithm may react differently. Did you check the temperature readings on the serial output? Are they changing that much? Post that output to give us an impression.

So turns out my hunch was correct. I delayed the reading of each zone and staggered the readings and it is working properly. I'll post the finished code when I test fully. I'm currently converting it to use the auto pid library as well.