News:

  • September 11, 2026, 11:59:37 PM

Login with username, password and session length

Author Topic: Stage Program retaining the current stage after power cycle?  (Read 29 times)

Mike Nash

  • Hero Member
  • *****
  • Posts: 655
Brand new BX-DM1E with 2 HSIO2 cards.
v2.11.2 software and firmware.

I am using a conditioned RUN command in $Main to start a stage program.

If the stage program is running and I switch to program mode and back to run, the stage program will not execute until the rung is enabled in $Main. This is the expected behavior.

If I cycle power while the stage program is running, it comes back on with the stage program still executing at the stage it was in when it lost power. This means in my case that it skips Stage S0 where my AXCONFIG resides and both it and the AXVEL in Stage S1 shows execution mode as not-configured (Mode 0). The help files say it is "unconfigured".

Oddly, if I have a contact in the AXVEL rung that is false and then goes true after the PLC is running, it will switch mode straight to smart-velocity.

This starting with the stage program running and already in S1 is undesirable. I thought it might be that I had set the stage program to retentive. But unticking the box didn't change the results and yes it was a program mode change to install.

How do I prevent this?

Second question - This is being used at the moment to simulate a lead encoder going out of HSIO2 Axis1, jumped into HSIO2 CT2. I am trying to simulate the retentive accumulator that will be going into HSIO2 CT1. CT1 is lead, CT2 is follow.

I need to maintain the Current Position from Axis1 through a power loss/restore and get it back into Axis1. While this part goes away after testing, it is not cooperating.

Currently I have:

STR C100 AXVEL "blah blah blah"
AND $HSIO_001_Axis1.Active
MOVE $HSIO_001_Axis1.CurrentPosition D100

It does work, but does grab the D100 value before the CurrentPosition end value every time.
I tried saving values in $tLastScan, but it never reads the real CurrentPosition on power loss, so it's always zero.

Is there a better way?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
I just tried it.  My program stays in S0.  I am guessing that after power up, S0's AXCCONFIG executes and completes immediately and jumps to S1 (AXCONFIG OnSuccess JMP S1?)

Make sure NOTHING is driving your AXCONFIG so it stays in S0.

Also, another possibility, make sure what is doing the RUN to your program does NOT run it if you don't what the program running at all after power-up (not sure if this is the desired behavior or not).

Mike Nash

  • Hero Member
  • *****
  • Posts: 655
Thanks Franji,

It doesn't appear to ever bother going to S0 after power cycle since everything to do with that axis stays at not-configured. It jumps straight to S1 like it never stopped, except it's no longer configured.

So after I posted I went to Google Search and its "AI" said I needed to go to Memory Configuration and check that the "S" ranges weren't retentive. Doh! What S ranges? Told it they didn't exist. It excused itself and said to check the program properties, which I had (and yes I had already unticked the retentive program structure and saved.) Anyway, I then set  $HSIO_001_Axis1 to No under Heap Items Retentive. And now it behaves.

I don't understand that as all the Axis and CT structures are retentive by default.

And yes the RUN instruction for that Program (in $Main) has a conditional that is false until after $Main is running.

I have another almost identically configured axis on the same HSIO2 that doesn't get hung up. It's still set retentive.

I'll dig around further if it crops back up. But honestly, that particular axis won't be staying after development. But there are three more that will, and I don't need weirdness.



franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
AI found the DirectLOGIC "Stage" memory, which is S memory.  Do-more has "local" stage bits inside each and every PROGRAM code block (128 of them).

Not sure exactly your transition logic in S0, but sticking an INC D99 (where D99 is retentive) at the top of S0 (right under SG S0 w/no input logic) would tell you if S0 ran at all (e.g. it goes from 4 to 5 after a power cycle).

Mike Nash

  • Hero Member
  • *****
  • Posts: 655
I added the INC in each stage of two programs.
I get 2 increments each time S0 is called on either program.

I have also bounced back and forth between setting the axes as retentive in the heaps and have decided I can't tell.

Currently I suspect I may not be handling the startup from power cycle well. I'll dig in further later.

Right now it is working again without miss.