03-12-2024 04:01 PM
Hello everyone,
I am writing a code that gives pulses of voltage to a heater, either on or off, and I have code that is measuring the output temperature response in multiple locations. All conditions in the code below work except for the code which uses values form my case structure inside my last while loop. I am using this case structure to find the maximum hot side temperature response for each period pulse of heat from the heater. The inside while loop is each pulse/period, the for loop around that is for how many periods there should be, and then the rest of the for loops cycle through various heater on and off time combinations.
My error is that when the condition of "peak temp convergence" signals, that signal does not also transfer to the "for loop condition met". However, when the condition of connected to the "elapsed time major loop" Boolean that is also wired to the "for loop condition met" works great. I think that this has something to do with me taking the max temperature from the last loop iteration (inside the case structure) and subtracting that form the current max temperature makes it so that conditions are not being passed out of the main while loop.
Can anybody help me with this? What more information do you need? Is there a better way to find the maximum temperature of each peak during each period?
03-12-2024 07:46 PM - edited 03-12-2024 07:51 PM
Your code is very hard to analyze because of serious architectural problems. A stack of four FOR loops containing a while loop, a pointless sequence structure and a greedy loop that consumes all CPU while not doing anything is not viable. Why would you open the same VISA resource over and over deep inside a loop stack? You have pointless local variables and duplicate code (e.g. you compare the elapse time with the same wire twice in parallel). Silly code such as finding the max between two zero diagram constants just does not inspire any confidence on the accuracy of the rest of the code. All your string concatenations could be done with simple formatting statements.
Sorry, I cannot look at this in detail on my laptop, but all you probably need is a simple state machine, one outer loop, and a few states where the entire code fits on one screen. That would make it debug'able.
Can you reduce it to a simple simulation (no DAQ) so we can actually run it?