Thanks for the additional info. While PLCs and our SNAP PACs have their differences, they also have a lot in common. Let’s break down the pieces of your situation here.
As you mentioned, we do have the Latch commands which work for I/O. These functions actually happen at the “brain” level, right there on the same rack as the I/O. The brain has a scanner (like a PLC), and includes a number of built-in I/O features (in addition to digital features like latching and counting, a SNAP PAC brain can also: run up to 96 PID loops, do totalizing, TPOs, etc.).
PAC Control strategies (which run on a controller) make super easy with to uses these features with the commands like GetClearOnLatch.
On the other hand, your variables exist in the PAC controller. (If you have a SNAP-PAC-R1 or -R2, then you have both a PAC controller and a brain in the same hardware.) As you mentioned in your first post, to detect an edge in that case, you would store the previous value and compare it to the current value.
This would look about as you described in your second post: “stop the motor when I detect a rising edge of the manual mode bit.” You could use just a single bit here, but PACs have loads of memory (click here for details), so better to use a whole, aptly named variable, perhaps: nManualModeFlag. OptoScript to do this might look like this:
Or the equivalent Action blocks (because anything you can do in OptoScript can be done in a flow chart with action blocks – your choice):
These would both be part of a looping chart (we always recommended adding the biggest delay reasonable in a looping chart so that particular chart doesn’t hog the CPU more than necessary). This logic could be in it’s own chart if you’d like. Some PLC users will just have one big chart that does everything in sequence before looping around.
Sometimes having just one big chart the loops around isn’t practical (depending on how big your application is now or will be in the future). Also, since you mentioned a concern about “redundant code,” you’ll likely want to take advantage of a PAC’s ability to run multiple charts at once and maybe even use a subroutine or two. More on that later…
Glad you’ll be using groov! Is that where you’ll have this “Manual Mode” button, and the “start command” button you mention? Have you built any screens yet? We’d love to see!