cadcoke5 Posted April 24, 2014 Share Posted April 24, 2014 I have a process that needs to follow a series of temperature goals. But, I am not clear about how to logically program the sequence. Since this is probably something you all do regularly, perhaps there is a better approach. Here is my current approach in pseudo-code Global variables CurrentTemperatureGoal, and Hysteresis. global 2D array that has the time, and its associated temperature goals for that time. There is a separate, continuously running, sequence that maintains the temperature at the value saved in CurrentTemperatureGoal 1) For-next loop, with a counter equal to the number of steps. 2) While the temperature is not at the final temperature goal (+/- the Hysteresis) 3) Set CurrentTemperatureGoal equal to the temperature goal for this step. 4) Wait for the amount of time for this step. 5) End While. 6) Endfor I need to know if the CurrentTemperatureGoal is not reached in the amount of time allocated to the current step. Wait for a little bit longer, and abort the process if it does not reach the goal. Back when I first started programming in basic, with line numbers, I might simply have used a GoTo statement and jumped out of my nested loops. But, I know that is not recommended, nor does there seem to be a way to label a line to jump to in DAQFactory. Another possibility is to insert a if-then statement before line 6. Test if the temperature goal is met, and if not wait a short time longer, and if it still is not at the goal, increment my counter to the last value. Then, when it loops back to line 1, it will exit the loop entirely. Any other recommendations? -Joe Link to comment Share on other sites More sharing options...
AzeoTech Posted April 24, 2014 Share Posted April 24, 2014 Assuming you want to wait the time for the step even if the temperature is reached (i.e. hold at that temp), it'd be something like this: (curTemp is the actual current temperature reading, and this is for a heating application in a continuously upward direction) global curTempSP // the global that holds the current setpoint that the other sequence controls too global tempSPs // array of set points global durations // array of durations, in seconds. I'm going to assume that these two arrays are the same size, or use a single 2d array. private nexttime = systime() for (private i = 0, i < numrows(tempSPs), i++) curTempSP = tempSPs[i] nexttime += durations[i] waituntil(nexttime) if (curTemp[0] < curTempSP) // SP not reached. Probably need hysteresis here. delay(30) // wait an additional 30 seconds if (curTemp[0] < curTempSP) // SP still not reached, break out of loop break endif nexttime += 30 // add in the 30 seconds so the next step still gets its time endif endwhile if (i < numrows(tempSPs)) // we failed system.messageBox("Ramp not complete, temperature not reached in time!") endif Link to comment Share on other sites More sharing options...
cadcoke5 Posted April 24, 2014 Author Share Posted April 24, 2014 What do the characters "+=" mean? It does not come up when I search the manual. -Joe Link to comment Share on other sites More sharing options...
AzeoTech Posted April 25, 2014 Share Posted April 25, 2014 x += 3 is the same as: x = x + 3 x++ is the same as: x = x + 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.