News:

  • September 28, 2026, 09:04:04 PM

Login with username, password and session length

Author Topic: Groupable Rungs  (Read 16602 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Groupable Rungs
« on: January 19, 2022, 06:19:45 PM »
I think this question or a similar one was posted on the main AD forum but what is the likelihood of being about to group a number of rungs so that they could be collapsed or expanded? I think the original question related to color coding logical groups of rungs. This is more a creature comfort than have to have. 

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Groupable Rungs
« Reply #1 on: January 20, 2022, 09:53:37 AM »
It's been in our "todo" list for a while, basically tied to "block" comments where you can collapse the rungs within a "block" (along with expanding/collapsing basic grouping constructs like loops and stages).

As programs get more and more complex, features like this would be very beneficial.

Currently, the Project Browser's Control Logic sub-tree gives a nice nested view of the logic, especially w/Stage code-blocks, displaying the first line of the rung's comment.  This is great for navigation purposes, but not for screen real estate issues when looking at actual code.

As a side note, Ladder Views are splittable, meaning you can have a Ladder View w/2 windows where each window is independently navigable, so you can look at different sections of code in the same view.  If you have a wide monitor (or multiple monitors) another option is to duplicate a Ladder View then Tile  them (Window->New Window, then Window->Tile Horizontal or Vertical) and you can basically "split" the window left/right instead of top/down.  You technically could then split each of those windows and do status on 4 independent sections of code in the same code block (e.g. huge $Main).

See the attachment of an HSIO app I wrote that generates pulses out 2 Axis to draw a circle utilizing $Axis0 virtual axis as the "angle" Master axis to $Axis1 as the Y/SIN and $Axis2 as the X/COS via a couple AXCAM instructions.  I optimized the screen real estate for showing detailed status of the critical instructions inside $Main (4 different sections of $Main split across 2 views, $Main:1 $Main:2), along with a 2nd code-block that is the "supervisor" stage program (AutoRunPgm) that continuously re-runs the circle profile after pausing 5 seconds between each cycle.

While this is not what you asked about, it provides a way to look at different sections of code at the same time (editing, status, etc.).

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Groupable Rungs
« Reply #2 on: January 20, 2022, 10:09:16 AM »
Quote
displaying the first line of the rung's comment.

Thanks for the tips. I'll try these out. I use the comments to delineate specific functions so I can find them more easily and this works well. It would just be nice to group them and collapse them so that you don't have to scroll through all of the rungs. Thanks guys for all the work you're doing. 

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Groupable Rungs
« Reply #3 on: January 20, 2022, 03:03:18 PM »
My rule of thumb is along the lines of if I find that there are more than a few rungs that code is similar enough to "group" together, it probably belongs in its own Stage, Task, Program, or possibly a Sub Routine.  Am I right?

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Groupable Rungs
« Reply #4 on: January 20, 2022, 03:10:21 PM »
Depends. It would be nice to have folders to organize tasks, programs, etc. Can't do an online change if you have to add a Program.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Groupable Rungs
« Reply #5 on: January 20, 2022, 03:13:25 PM »
Can't do an online change if you have to add a Program.

You can if you preallocate a block of PROGRAMs or TASKs (vs. heap-as-you-go), then use nicknames as you add new ones (e.g. PgmBlock0 is "DoX" PgmBlock1 is "DoY").  It's a hack, but it can work.

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Groupable Rungs
« Reply #6 on: January 20, 2022, 03:30:22 PM »
Can't do an online change if you have to add a Program.

You can if you preallocate a block of PROGRAMs or TASKs (vs. heap-as-you-go), then use nicknames as you add new ones (e.g. PgmBlock0 is "DoX" PgmBlock1 is "DoY").  It's a hack, but it can work.
Yep, I try to keep NewPrg1..NewPrg4, NewTsk1..NewTsk4, etc on deck at all times.  Works well enough if scan order is not important.  Hadn't thought about nicknaming them in the meantime though, good idea.

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Groupable Rungs
« Reply #7 on: January 20, 2022, 03:38:00 PM »
Good point about pre-making you're Tasks and such. A folder to stick these in would be nice so that they're out of the way.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Groupable Rungs
« Reply #8 on: January 20, 2022, 04:53:10 PM »
Good point about pre-making you're Tasks and such. A folder to stick these in would be nice so that they're out of the way.

They won't show up in your Control Logic until you create the actual code-block.  This is just memory configuration data blocks - not Ladder memory.

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Groupable Rungs
« Reply #9 on: January 20, 2022, 06:17:19 PM »
They won't show up in your Control Logic until you create the actual code-block.  This is just memory configuration data blocks - not Ladder memory.

Ha! I hadn't even thought of that approach, just create the Heap Items.  That's fancy right there.  Would that work though, as the .TimeSlice wouldn't be configured?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Groupable Rungs
« Reply #10 on: January 21, 2022, 09:30:18 AM »
They won't show up in your Control Logic until you create the actual code-block.  This is just memory configuration data blocks - not Ladder memory.

Ha! I hadn't even thought of that approach, just create the Heap Items.  That's fancy right there.  Would that work though, as the .TimeSlice wouldn't be configured?

Yes - realize that's "INITIAL" time slice.  You can always stick logic at the top of the code-block to set it to anything.  .TimeSlice is completely runtime configurable.  A little code takes care of that situation whenever you care about .TimeSlice.  Definitely workable.

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Groupable Rungs
« Reply #11 on: January 21, 2022, 09:54:34 AM »
Yes, but once you "actually" create the code block with the Heap Item name, won't it try to assign the default .TimeSlice, and still require a Program Mode write to PLC?  Or does the Heap Item creation cause the default of 100 us to be set?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Groupable Rungs
« Reply #12 on: January 21, 2022, 10:35:46 AM »
Yes, but once you "actually" create the code block with the Heap Item name, won't it try to assign the default .TimeSlice, and still require a Program Mode write to PLC?  Or does the Heap Item creation cause the default of 100 us to be set?

Sorry - I misunderstood.  I have been talking about having a predefined block of PROGRAMs or TASKs, not the normal heap-item creation mechanism.  When you create a code block from an existing data block of PROGRAMs, you don't have to go to PROGRAM mode (hence the Initial .TimeSlice won't get set like normal).

However, whenever you create a new code block using the normal heap-item, that tweaks the sysconfig, which implies a PROGRAM mode download, which implies the .TimeSlice of this new heap item WILL get set to the configured "Initial .TimeSlice" value from the code block configuration dialog when it goes from PGM->RUN.

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: Groupable Rungs
« Reply #13 on: January 21, 2022, 12:17:11 PM »
Alright, I'll keep doing what I'm doing.  In one of your posts I got the impression I could just create spare Heap Items, and later "activate" it when I needed it.  I'll stick to what I know...