How can I assign an integer variable to always update with the value of a thermocouple input?

What seems like it should have been simple logic, has stumped me. I am beginner to programming at best.

I am controlling a pair of burners A and B, when one burner fires, the other is flueing. Every 20 seconds it switches, I have thermocouple pairs inside each burner to measure the temperatures.

D19_D19HOTA_IN
D19_D19COLDA_IN
D19_D19HOTB_IN
D19_D19COLDB_IN

These thermocouples represent a different thing (Air preheat or POC Hot and POC Cold) or equal 0 depending on the burner’s state.

Problem I’m having here is assigning the variable to equal the thermocouple values and constantly update with the thermocouple value. I can set them equal in an OptoScript box, however, they only retain the initial value at that given time and do not update throughout the cycle. I considered just making a whole other chart just to update these variables and continually loop, is this the way or is there something in the local cycle chart I can do? Thanks!

Entire cycle chart

Cycle burner A on

Cycle burner B on

Hello! If you are moving the temperatures to a variable then the variable will only update when it is requested to do so in your code. This would not allow you to set your values to 0, but could you use the thermocouple inputs directly in place of the variable in your code when you need the temperatures? That would allow it to use the current thermocouple values at any given time and not the stale data from when you last updated the variable.

The simplest approach would be to update these in another chart in a loop with a short delay. You could change your existing chart, but you would be basically starting over from scratch and need to keep track of your state/mode and use timers for your delays. That would have other benefits (like being able to reprogram/stop/start/debug your strategy and it remember where it is in the process), however the way you have it is simple and easy to understand.

1 Like

I think @philip has some solid advice, just make another small chart with a loop and delay to update these things you need ‘live’ so you do not have to rebuild your main chart.

Just in case you missed it, the notion of having delays in ALL your charts is more critical than it sounds, check out my blog on the topic here, its a quick read: Add delays to speed up

1 Like

Thanks all for the confirmation. I did end up making a small loop chart this morning. Works exactly like I wanted!

1 Like