Weird timing difference between Script Editor and Sequence

The issues found when using the Function Manager panel
Post Reply
brad992
Posts: 9
Joined: Mon Aug 22, 2022 3:21 pm
Real Name: Bradley

EDIT:Ok so it turns out my original explanation for the issue is wrong. Meaning that simply subtracting 15ms does not work. It seemed to work in many of my cases but completely wrong in other cases. I’ve done a fair bit more messing around and I think I understand the issue better now.

It seems to me what is happening when I type “wait:120ms” is that it is actually waiting for 139ms. However, when I type “wait:105ms” it seems to be waiting for 119ms. So I experimented more and typed things like “wait:110ms” and “wait:115ms” and in both of these cases seems to be waiting for 119ms.

This explains why subtracting 15ms worked in my first scenario. However in a different scenario where I want to have “wait:135ms”, this appears to be rounding to 139ms. Subtracting 15ms changes it to “wait:120ms” but again is still waiting for 139ms. The only solution I can come up with for this case is to alternate having “wait:119ms” and “wait:139ms” in a way that makes the average time to be 135ms. Not something which is at all easy for me to do.

Long story short, the way I understand it now is that whatever time you put in, it rounds it up to the nearest 20ms. Maybe the take home message is to avoid using the Script Editor?



I think I've finally figured out this timing issue I've been having using the Script Editor vs using a Sequence.

I've created a Sequence which has 128 steps, and each step is 120ms. This Sequence takes 15,360ms. This is exactly what I expect, perfect.

However, if I instead create the exact same thing but this time in the Script Editor, ie., the same 128 steps with a "wait:120ms" between each of the steps, it takes a total of 17,280ms. That is weird... Why do they not take the exact same time to run? Well I think I figured it out. It seems to me that typing "wait:120ms" is actually waiting for 135ms. It seems to add approximately another 15ms.

How did I figure this out? Well I experimented by changing each wait to "wait:105ms" and this time the total time to run was 15,360ms, just as I would expect if the wait time was in face 120ms. Next, I tried two waits between each step, ie., "wait:45ms" twice in a row. This gave me the same total time of 15,360ms. Now I am convinced that every time you use the wait command, it adds 15ms on top.

The take home message here is if you are using the Script Editor then you may need to subtract 15ms from each time you use the wait command. I will need to test this more but this has solved all my timing issues in the Script Editor instantly so far. This really has been bugging me for days. Hopefully this helps someone else out there experiencing the same issue.


version 4.12.5, windows 10
Last edited by brad992 on Wed Aug 24, 2022 4:19 am, edited 1 time in total.
User avatar
GGGss
Posts: 2732
Joined: Mon Sep 12, 2016 7:15 pm
Location: Belgium
Real Name: Fredje Gallon

brad992 wrote: Mon Aug 22, 2022 4:01 pm typing "wait:120ms" is actually waiting for 135ms. It seems to add approximately another 15ms.
As far as I am aware, the script engine does 1 step per internal QLC+ cyclus; thus explaining the 15ms latency.
All electric machines work on smoke... when the smoke escapes... they don't work anymore
brad992
Posts: 9
Joined: Mon Aug 22, 2022 3:21 pm
Real Name: Bradley

Ok so it turns out my original explanation for the issue is wrong. Meaning that simply subtracting 15ms does not work. It seemed to work in many of my cases but completely wrong in other cases. I’ve done a fair bit more messing around and I think I understand the issue better now.

It seems to me what is happening when I type “wait:120ms” is that it is actually waiting for 139ms. However, when I type “wait:105ms” it seems to be waiting for 119ms. So I experimented more and typed things like “wait:110ms” and “wait:115ms” and in both of these cases seems to be waiting for 119ms.

This explains why subtracting 15ms worked in my first scenario. However in a different scenario where I want to have “wait:135ms”, this appears to be rounding to 139ms. Subtracting 15ms changes it to “wait:120ms” but again is still waiting for 139ms. The only solution I can come up with for this case is to alternate having “wait:119ms” and “wait:139ms” in a way that makes the average time to be 135ms. Not something which is at all easy for me to do.

Long story short, the way I understand it now is that whatever time you put in, it rounds it up to the nearest 20ms. Maybe the take home message is to avoid using the Script Editor?
brad992
Posts: 9
Joined: Mon Aug 22, 2022 3:21 pm
Real Name: Bradley

GGGss wrote: Tue Aug 23, 2022 11:31 am
brad992 wrote: Mon Aug 22, 2022 4:01 pm typing "wait:120ms" is actually waiting for 135ms. It seems to add approximately another 15ms.
As far as I am aware, the script engine does 1 step per internal QLC+ cyclus; thus explaining the 15ms latency.
Thank you for your response. But I don't understand the technical details enough to understand your comment, is it possible to explain in layman's terms?
janosvitok
Posts: 1274
Joined: Mon Apr 13, 2015 7:05 am
Location: Bratislava, Slovakia
Real Name: Jano Svitok
Contact:

QLC+ computes a frame every 1/50 second = 20 ms. You can adjust the master timer as you wish: https://www.qlcplus.org/docs/html_en_EN ... asterTimer (Section 4.5).
Ideally, you match this to your DMX/artnet frequency somehow (that is normally 1/44 s =~ 23ms).
brad992
Posts: 9
Joined: Mon Aug 22, 2022 3:21 pm
Real Name: Bradley

janosvitok wrote: Wed Aug 24, 2022 6:30 am QLC+ computes a frame every 1/50 second = 20 ms. You can adjust the master timer as you wish: https://www.qlcplus.org/docs/html_en_EN ... asterTimer (Section 4.5).
Ideally, you match this to your DMX/artnet frequency somehow (that is normally 1/44 s =~ 23ms).
Thank you very much for this information! I think this is exactly the information I was looking for. I'm really glad to know this now. I really never considered this to be a thing. I will experiment with changing the master timer, but I imagine it is set to the default value for a good reason
User avatar
GGGss
Posts: 2732
Joined: Mon Sep 12, 2016 7:15 pm
Location: Belgium
Real Name: Fredje Gallon

brad992 wrote: Wed Aug 24, 2022 9:24 am I really never considered this to be a thing.
Off topic: During high school, defending my master paper, one specialist came up with exact this question ... one to never forget: "What does influence the internal timing of this type of PLC controller?" Seemed, afterwards, the time the PLC needed to read all inputs, which took quite some time compared to the whole processing and equation time needed. I passed without problem, it was a sleeky question to get me blocked into the corner.
All electric machines work on smoke... when the smoke escapes... they don't work anymore
Post Reply