Jump to content

APEX Programming Question


TheClark

Recommended Posts

I have my CR set up, so that if alk is > 8.53, the CR solenoid turns off.  This is great, and keeps the tank quite stable.

However, since I only run tests every 4 hours, 4 hours goes by until alk is tested again.  Sometimes it drops a bit too far.

What I would like to do is turn it off as usual, but limit the off time to 2 hours instead of until alk drops back below 8.53.

Basically shrink the blue spikes in this chart:

 

image.png

 

Current CR solenoid outlet:

Fallback OFF
If Output CR_PH_LOW = ON Then OFF
If Output CR_PH_HIGH = ON Then ON
If Output ReturnPumpR = OFF Then OFF
If Output ALK_HIGH = ON Then OFF

ALK_HIGH virtual outlet

Fallback OFF
Set OFF
if Alkx2 > 8.53 then ON
 

So basically, when the CR solenoid is turned off by ALK_HIGH, I don't want it to stay off for more than 2 hours.

Right now, it will stay off until the next ALK test says the ALK dropped below 8.53

@SuncrestReef you got me?

Anyone, anyone?  Bueller?

 

Link to comment
Share on other sites

What if you add another virtual output that starts a 2 hour timer once ALK_HIGH turns On, and once the 2 hour countdown completes it turns ALK_HIGH off?  Example:

[ALK_HIGH]
Set OFF
If Alkx2 > 8.53 Then ON
If Output ALK_TIMER = ON Then OFF

[ALK_TIMER]
Set OFF
If Output ALK_HIGH = ON Then ON
Defer 120:00 Then ON
Min Time 120:00 Then ON

 

Note, you don't need Fallback OFF on your virtual outputs because Fallback only applies to physical outputs.

  • Like 2
Link to comment
Share on other sites

30 minutes ago, SuncrestReef said:

What if you add another virtual output that starts a 2 hour timer once ALK_HIGH turns On, and once the 2 hour countdown completes it turns ALK_HIGH off?  Example:

[ALK_HIGH]
Set OFF
If Alkx2 > 8.53 Then ON
If Output ALK_TIMER = ON Then OFF

[ALK_TIMER]
Set OFF
If Output ALK_HIGH = ON Then ON
Defer 120:00 Then ON
Min Time 120:00 Then ON

 

Note, you don't need Fallback OFF on your virtual outputs because Fallback only applies to physical outputs.

That looks great to me, thanks!!!

 

 

  • Like 1
Link to comment
Share on other sites

3 minutes ago, obrien.david.j said:

@TheClark Can you post updated graph showing the results?  (of course, it will only be 9hrs worth of results, but post a few days worth again, so we can see the Before, and After behavior)

 

Sure!

Below is the new 'blue' area.  Notice the PHCRE stayed at a high PH for only two hours instead of 4.  Also the alk drop was lower than it would have been if the reactor had been off for 4 hours instead of 2.  Liking it!

Also, I can tweak that 2 hours to be whatever makes sense now.  Good stuff!

The dream would be 

if it is in the evening, and alk has been trending high at a good rate, back of the reactor for 4 hours.

if it is in the evening, and alk has barely made it over 8.53, back of the reactor for 1 hour.

Etc..  This kind of logic and data to act on would be huge, but I am quite happy for now.

 

image.png

  • Like 2
Link to comment
Share on other sites

2 hours ago, SuncrestReef said:

Happy to help!

Hey John,  more general question.  I have noticed on several of the related posts on this (including R2R) that people are using multiple virtual outputs when it seems like one could code this all in one (e.g.  adding the timing feature to Alk High for instance).  Is there a reason for that other than being able to use the output for multiple controls (where you wouldn't necessarily want the same timing for instance)?  Just curious...  feels like I am missing something in the logic.

Link to comment
Share on other sites

3 minutes ago, albertareef said:

Hey John,  more general question.  I have noticed on several of the related posts on this (including R2R) that people are using multiple virtual outputs when it seems like one could code this all in one (e.g.  adding the timing feature to Alk High for instance).  Is there a reason for that other than being able to use the output for multiple controls (where you wouldn't necessarily want the same timing for instance)?  Just curious...  feels like I am missing something in the logic.

It all boils down to the limited ability of the Apex programming model to apply AND operations.

In this particular example, the HIGH_ALK turns On when the Trident's Alkx2 input exceed 8.53.  The only way to get it to turn Off is if Alkx drops below that value, but that reading remains constant until the next scheduled Trident test in 4 hours.  There are only 3 possible ways to work around this:

1. Use a Defer timer to delay turning On ALK_HIGH:

[ALK_HIGH]
Set OFF
If Alkx2 > 8.53Then ON
Defer 120:00 Then ON

Unfortunately this would delay shutting down the calcium reactor for 2 hours, so the alk would continue to rise, further worsening the problem.

2. Use a When timer to turn Off ALK_HIGH after 2 hours:

[ALK_HIGH]
Set OFF
If Alkx2 > 8.53Then ON
When ON > 120:00 Then OFF

But the When timer forces the output to manual OFF if exceeded, so it's not a good solution for unattended automation.  

3. Use another virtual output where you have more granular control by combining the state of ALK_HIGH with the delayed result of ALK_TIMER, which is what I recommended.  In this case, ALK_HIGH is On for 2 hours while ALK_TIMER has not yet counted down to zero.  Once it does, then it overrides Alkx2 > 8.53 even though it's still True.

  • Thanks 1
Link to comment
Share on other sites

8 minutes ago, SuncrestReef said:

It all boils down to the limited ability of the Apex programming model to apply AND operations.

Thanks John.  I think this is the crux of my lack of understanding here...  Thanks for walking me through it.  Almost picked one of these up as part of that sale the other day - really bummed that tank was just too tall to work.

  • Like 1
Link to comment
Share on other sites

1 minute ago, albertareef said:

Very nice.  Looks like the residual variation might be settling into a bit more consistent pattern but still not strictly tied to TOD.  Good stuff!

Yes!  I am thinking of pulling time of day in at some point but watching for that pattern too!  I need a peristaltic first to eliminate my last variable...  Check out flow...

image.png

 

 

Link to comment
Share on other sites

16 minutes ago, TheClark said:

Check out flow...

That is interesting.  What are you using to regulate currently? What are the units there?  I'm curious since I have been working recently to get mine dialed back in after experimenting with a different reactor (did not go well).

Link to comment
Share on other sites

3 hours ago, albertareef said:

That is interesting.  What are you using to regulate currently? What are the units there?  I'm curious since I have been working recently to get mine dialed back in after experimenting with a different reactor (did not go well).

Liters per hour, I run a good flow but it slowly ebbs over time.  Then APEX alerts, and I open / flush and repeat.

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...