Hi Duy,
Okay, looking at the attached chart, first off you don’t need to start and stop the chart in itself. Another chart needs to start it (typically the Powerup chart, which is the ONLY one that is started initially, on Powerup).
In fact, if you do have the chart stop itself like I see in Block 2, there’s no point in having a line coming out of that block because the chart will be stopping and not going there, ever. If you’re familiar with other programming languages, it’s like have more code after a goto or an End – never gonna get there.
See Chapter 4 (and the rest of that manual) I mentioned above on Designing your Strategy… which also talks about listing your Inputs and Outputs.
So, now kinda doing your homework for you a little here, listing Inputs and Outputs we have:
Inputs/Outputs:[INDENT]
2 physical analog inputs: Pump_Pressure (currently referenced in blocks 52 & 10, compared to the literal 15 in that bottom condition blow); Chamber_Pressure (also compared to 15 in your floating/used OptoScript block 33)
diAP_Heater - digital input, to tell if this whole “AP thing” is there, I presume
bStartFlag - looks like the input from your user, but you use this variable elsewhere, when you’re reading your Max Pump_Pressure? I don’t think you meant to do that…
doAP_Heater - digital output, which I presume is the only thing we’re actually controlling here.
[/INDENT]
I’d suggest changing that 15, currently hard-coded into your chart in 2 places, into a Numeric Variable, perhaps called: fPressureSetpoint_in_mTorr. Because later you might want to change it (even when your testing, temporarily). And you can’t do a search on “15” in your chart, but you can search for a variable. Also, what if your boss comes by and says: oh, by the way, that 15 should be 25.5… what if you miss one when you go to change it?
Notice the name I gave that float variable (which you’ll start of at 15.0) INCLUDES THE UNITS. Always include the units. (You do know about what happens when you mix up your units like[U][B] NASA scientists did with the Mars space probe[/B][/U], yes? Don’t do that. Learn from their mistakes.) You have 50 characters to name your variables, points, etc. Use them!
And… I noticed that currently your analog inputs named Pump_Pressure (no units) and Chamber_Pressure (also needs units) are not scaled. Edit those points to include a better name and map your -10 to 10 VDC actual signal to whatever the appropriate scaling is. As you have it now, you’re using the default scaling so neither of those will EVER get to 15 anything since 10 is the max.
Also, in that bottom condition block I noticed your checking to see if your Pump_Pressure is EXACTLY equal to 15. Besides the scaling/range problem, think about the odds of this happening. Usually, even if you have a control system like a perfectly tuned PID loop keeping that value as close to possible to 15, it will only rarely if ever, get to 15.000000000 on the nose exactly (and floating-point comparisons is a whole other topic).
However, I notice in your OptoScript block you had a <= 15 which makes me think you’ve done a little programing, and might prefer to use OptoScript for this whole thing…?
Now, I’m pretty sure you’re only controlling that one output, and you’ll need to turn it on and leave it on under certain conditions, then you turn it off under other conditions. This might be the best way to approach the problem. Under what conditions should it be turned on or off? You also need to know: how often should we check for these conditions? Since you have a user input here, and you don’t want someone to press the button on the screen an have to wait more than about 100 ms, I’d suggest that’s how often you run this chart in a loop. Or more specifically, how long you DELAY before running through all your checks again.
When you first start this chart, should the doAP_Heater be turned off, before you start checking everything else?
Here’s how I think you might want your logic to flow:[INDENT](Right after the Start)
Turn off (doAPHeater)
Check: diAP_Heater present? (consider changing this name too, especially since it’s so similar to the output, perhaps something like: diAP_Box_Present_when_On, including not exactly the units there, but a clue to which way the switch goes).
Check, probably in same condition block, with AND for your Operator, which is the default, condition: bStartFlag <> 0 (Note this is [U][B]better than checking for True since sometimes true is -1 and sometimes it’s 1 but false is always 0[/B][/U]).
Both of those false? Nothing to do, go to that block where you currently Stop the chart and instead Delay for nAPHeaterLoopDelayMS which you can initialize to 100.
[/INDENT]
Is this making sense so far? You’re looping around check if we should be doing something, if nothing to do you Delay 100 ms and check again…
For the next part, explain in detail when the heater should stay Off or Turn on Stay on, and when it should be turned off again. I see you have 2 pressures in here and I’m not clear on the rest of the logic, and hope what I’ve told you so far will get you going…
Here’s a clue, if you know you’re always starting with the heater OFF, then when you do have all the conditions met to turn it ON, you’ll need to start a timer (probably and UpTimer, see those under Numeric Variables) then later check to see if it’s > 30? Or fMaxTimeToHeatBeforeGivingUp_in_Minutes… but since timers are in seconds, maybe you’d want to set that new float to 30 minutes x 60 seconds/minute = …
Also, don’t forget to think about when other stuff needs to be turned off or cleared, like your timer, and the flag coming in from the user…
Go! I’d be happy to check your next pass at this, especially since you’re willing to share w/other newbies out there!
-OptoMary