Controlling the Program Order

Is there a command to stop/start strategies without having to open pac control and clicking on the stop/start buttons in debug mode?
I’m utilizing opto22 on a manufacturing assembly line. There are five machines communicating to one another via individual R1 snap pac controllers. Each machine has a unique strategy and IP address. The issue is that when one of the controllers loses power, the order of the programs changes and the operator has to manually open pac control > debug >stop/start in the order of machine 1> machine 2> machine 3> etc. for the 5 strategies running. Only when they are ran in the correct order will it not affect the communications.
My goal is to have a button on the hmi similar to “reset plc” that will do this procedure automatically.
What is your suggestion?

Hi Casey,

Welcome to the OptoForums! So, sounds like you have 5 R1s, and one (all?) of those is connected to some kind of HMI (PAC Display? groov?), is that correct?

There are a few ways for a PAC or HMI to:
a) detect that a PAC has lost power
b) restart/reboot the others

Do you have access to all the strategies?
Just curious: What’s causing this loss of power? (Machine shut off?)
Aside: Sounds like should possibly be part of one supervisory strategy…

Let’s start with those questions, and I can recommend the best way(s) to restart those machines based on your answers.

Thanks,
OptoMary

OptoMary, thank you or the quick response! Here are my answers:

  1. All of the R1s are connected to one HMI, though it is not utilizing PAC Display rather a third party software (WindowViewer).
  2. I have access to all of the strategies.
  3. The loss of power occurs when one machine needs maintenance and has to be safely locked out. Once the power is restored, it is required to restart the program order.

I am interested on how to:
a) detect that a PAC has lost power
b) restart/reboot the others
What section in the opto22 manuals are these answers located in?

Hi Casey,

Our memory map can do both of those things. The guide for that is here:

For example, using PAC Manager, you can see how long it’s been powered up (and compare that to a previous value, or see if it’s below a certain threshold). And you can also use PAC Manger/mem map writes to reboot a PAC, as shown below:

However, for your application since you have access to the strategies, I’d recommend doing something a little less brute force than a reboot like that. How many charts to your strategies have?

Also, does your HMI support Modbus? Because if it does, you could access these memory map addresses via Modbus.

But I’d recommend adding logic to your Powerup that says: “do I need to reboot myself?” (a button from the HMI) and then if it does, you can gracefully shut down whatever charts, perhaps make a log entry somewhere, etc. Do you see what I mean here?

Thanks,
Mary

I’m going to go the route of creating a block for “do I need to reboot myself” and I’ll make a script on the hmi to send the command in the order of machine 1, 2, 3 etc.
Thank you!

Update: unable to fix the communications error by restarting charts. I’m wondering if it is ethernet/IP related. The route I’ve been using to fix the program order is as follows:
Open Pac control Pro strategy for machine 1: stop>start button.
Repeat with strategy for machines 2-6 (brute force method but have many spares).
Example:
Machine 3 loses power for moment.
Issue: Numeric table with 300+ lines of math for machines 2-3 stops updating. Not always the same table has issue.
Fix = Minimize HMI, open Pac Control Pro and stop/start the 6 machine strategies in order 1>6 (for the 6 R1 controllers).

Question: is there a chart to replicate stop/start strategy button without having to open PAC control pro or Pac Manager (like button on HMI to a numeric variable)? Also, I’m looking the option you mention in the manual for memory mapping: if this is better/only option, how do I command R1 to reboot device via memory map? I’m using WonderWare HMI with FSGateway.
-I seem to only have issue if strategies are not ran in the correct order and it’s easy to replicate.

Have you worked with support about this issue?
Sounds very odd. And must be frustrating to have to go through this mouse dance every time…

That said, have you thought about starting the powerup chart when you detect it needed to restart things?
The powerup chart should start the other charts and not do much else.
If the other charts are running, they will all restart (I am pretty sure) from their block zeros, this is in-effect like restarting the strategy.
This would be like clicking the stop start button (which simply stops all charts and runs the powerup chart).
If you really wanted to be sure, you could stop each chart before you started the powerup chart, but it should not be necessary.

As far as rebooting yourself, if you do quick forum search you can find the mmp address for a reboot.
But I would not be going down that path.

1 Like

The other difference between restart from power up and restarting all the charts is the variable initialization. So if you need variables reset to their startup value, you will need to do that in your power up chart as well.

It would be nice if each strategy was programmed in such a way that it can gracefully recover, but you got what you got, and if everything else is working fine, why mess with it.

Since you are simply stopping and starting the strategy sequentially, you could send the restart strategy forth command “_END _RUN” through a comm handle from one of your controllers:

sTransmitBuffer = "_END _RUN" + Chr(13);

//Repeat the following for each controller to restart.
SetCommunicationHandleValue("tcp:172.27.72.30:22001", comm); //put the controller to restart IP address in here
status = OpenOutgoingCommunication(comm);
status = TransmitReceiveString(sTransmitBuffer, comm, sReceiveBuffer); //sReceiveBuffer will have a couple nulls in it
status = CloseCommunication(comm);

Then set a flag from your HMI to run that code.

2 Likes

If the charts are already running, the Start Chart command will have no effect.

1 Like

hi…does your HMI support Modbus? Because if it does, you could access these memory map addresses via Modbus.
But I’d recommend adding logic to your Powerup that says: “do I need to reboot myself? and then if it does, you can gracefully shut down whatever charts, perhaps make a log entry somewhere, etc

pcb manufacturing and assembly

Thanks. I like the comm handle option. I will experiment with this. I can stop/start 5 controllers through the comm handle from 1 main controller is that correct?
I need variables reset to their startup value. However for me to include each variable in the power up chart would be rough since I have 1k~ numeric variables and then charts of 400 lines each that may need reset for invalid entries such as a #QNAN digital input.

Yes, just close the comm handle, change the handle to the next IP, open, and transmit. If you need the first controller restarted first, then you could have it restart itself, then put the commands to restart the others in the first controllers power up chart.

Question:
Based on these instructions, do I create three communication handles? One called “sTransmitBuffer” another called “comm” and the other “sReceiveBuffer.” Thanks.

Here is where I am at:

Created 3 communication handles
“sTransmitBuffer”
“sReceiveBuffer”
“comm”
Created numeric float variable
“status”
Created numeric float variable
“Strategy1_Restart”
-this is the variable I will turn on from the HMI to run the code in my scratchpad chart.

Result when compiled is image. First line is #172
-The IP I will change to my controller after I am able to compile.

Thanks.

sTransmitBuffer and sReceiveBuffer need to be strings. I would recommend integers for status and Strategy1_Restart, but floats will work, but it is bad style.

Change the IP address to match your controller - none of your controllers IP address will be 172.27.72.30.

Be sure to repeat the code for each controller you need to restart per the comment.

1 Like

Thanks for your help. I was able to compile.
Thoughts on adding a delay between each controller restart? Or will it be ok as is?

Also:
What is required on the controllers receiving the _End _Run command?
Such as:
Two Strings= “sTransmitBuffer” and “sReceiveBuffer”
one comm handle= “comm”
one Interger numeric variable= “status”

Delay is up to you - it isn’t strictly necessary, but if you need to make sure one controller starts before another, then putting in delays will help with that.

There is nothing needed on the other controllers - only one controller will need the control logic to restart the others.

1 Like