Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: ATU on November 30, 2018, 11:29:47 AM

Title: TIme Slice Adjustment
Post by: ATU 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.
Title: Re: TIme Slice Adjustment
Post by: franji1 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.
Title: Re: TIme Slice Adjustment
Post by: ATU 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.
Title: Re: TIme Slice Adjustment
Post by: franji1 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