News:

  • October 02, 2026, 07:06:52 PM

Login with username, password and session length

Author Topic: TIme Slice Adjustment  (Read 7908 times)

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
TIme Slice Adjustment
« on: November 30, 2018, 11:29:47 AM »
I just noticed that the time slice in the for/next instruction did not reflect what I set them to. Now I realize, that it doesn't take into effect until the next run/program transition. Is this true for execution order as well? I couldn't find anything in the manual about it.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: TIme Slice Adjustment
« Reply #1 on: November 30, 2018, 12:44:44 PM »
I bet you are setting the "Initial" time slice value in the code-block configuration, which occurs when you go from Program to Run.  .TimeSlice is LIVE.  Hence, just set it (either via logic or Data View or whatever).

Execution order is actually a change in the logic itself, so you just have to write your program to the PLC.  Technically, this does not require a Pgm->Run transition, but could be done via a runtime edit.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: TIme Slice Adjustment
« Reply #2 on: November 30, 2018, 01:02:05 PM »
That is interesting. So I could actually adjust the interval based on what is advantages at the time. I have a tasks that capture data during the running of a test and one updating the display.  I could adjust it programmatically a higher slice during the run for acquisition and less for the update to the screen. Flip it around when not running to make the HMI more responsive. That is so cool. You guys think of everything.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: TIme Slice Adjustment
« Reply #3 on: November 30, 2018, 01:10:08 PM »
Exactly.  .TimeSlice was always meant to be tweakable.  It's kind of like PID.  As the complexity/length of your looping changes, you may need to adjust the balance between PLC scan time vs. Loop calendar time.

I wrote a bubble sort algorithm and you can play with the .TimeSlice in the Data View to see where the "sweet spot" is between minimizing PLC scan time vs. full loop processing time.  Bubble Sort is 2 nested loops.  So when sorting 1000 elements, you are doing the inner-most loop work on the order of 1000*1000 times (1,000,000 times - technically not THAT high, but definitely on the order of N-Squared),  There is definitely a "diminishing rate of return" at the two extremes  Check it out here:
https://forum.hosteng.com/index.php/topic,1020.0.html