A problem with outputs

If you have a question about the software please ask it here.

Re: A problem with outputs

Postby Vmax549 » Sun Oct 14, 2018 1:13 am

HIya Dan, No point in shooting teh messenger :) He may have the answer we are looking for.

Can you give a link to your info on Wait() Sleep() and other methods of WAIT.

The problem I saw with sleep() is it would every once it a while skip teh next line after teh sleep(). :shock:

So far I have not seen that with Wait() or if it did it did not make any difference to teh outcome.

ALSO I have them OUTLAW outputs cornered up now with a report that finds EVERY instance of exec.Setoutpin and what macro it is used in. I have some more TUNING to do on it to get it into a better orginized report but it is a start.

(;-) TP
Attachments
UCCNC_Outpin_Report.jpg
Vmax549
 
Posts: 1297
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: A problem with outputs

Postby Dan911 » Sun Oct 14, 2018 2:46 am

Hi Rob Terry,
I hope my post didn't come off like a know it all or programmer because I'm neither by far. I do like to read and that's something I read and remembered a while back, a simple google search will provide many links . Wait/Sleep from what I understand are basically the same and both memory hounds used for long period delays. I wouldn't expect to get good results using for a timed loop, I wasn't able to see your delay since a variable. I did experiment with this for polling loops and timer,stopwatch or tick events may be something more reliable.
Dan911
 
Posts: 416
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: A problem with outputs

Postby dezsoe » Sun Oct 14, 2018 6:59 am

Your macroloop runs 20 times per second. Why don't you just count it? The 50ms resolution is not fine enough?
dezsoe
 
Posts: 544
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: A problem with outputs

Postby Robertspark » Sun Oct 14, 2018 8:01 am

That is fine enough for me, I just wonder why others have mentioned potential issues.

Could it be too much for the macro / macroloop to do?.... Too many macros / macro loops running exec.wait() function at the same time (too many threads waiting at the same time gives odd behaviour?)
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 981
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: A problem with outputs

Postby cncdrive » Sun Oct 14, 2018 9:10 am

The exec.Wait function is simply a cycle of Thread.Sleep function.
How it works is that there is a code cycle with Thread.Sleep(1); and the time is measured in each cycles and when the parameter of the Wait elapsed then the cycle ends.
It was made like that because the Thread.Sleep is not very precise, so e.g. a Thread.Sleep(50); is often 50-60msec and not precisely 50msec.
If the sleep time in each cycles is 1msec and the time to break out of the loop is measured then it will be more precise, in the 50-51msec range, but I think I don't have to describe this more, it should be understandable.
One more thing is that the Wait is skipped/breaks out of the loop if the macrostop is set, if a STOP or RESET was executed, because otherwise the code execution would stuck until the Wait ends even if a STOP or RESET was requested by the user which would be annoying.

Thread.Sleep is a very basic command in Windows programming, so if it has a problem then that is a Windows issue which I have never seen.

And since macroloops are fully separate threads they will not wait for eachother, they running virtually independently, they will not wait for eachother when there is a Sleep or Wait is coded.
A Sleep puts only the particular thread (macroloop) into sleep in which the Sleep was executed.

Thread.Sleep is not a bad practise in my opinion, there are things which can't be done without it. What is a bad practise is to make the UI thread to sleep, because that freezes the UI.
But the macroloops are not in the UI thread, they are separate threads running in the background independently from the UI thread.
cncdrive
Site Admin
 
Posts: 2260
Joined: Tue Aug 12, 2014 11:17 pm

Re: A problem with outputs

Postby Robertspark » Sun Oct 14, 2018 9:32 am

Thanks for the explanation.
exec.wait() is good enough for me
Rob
Einstein ― “If you can't explain it to a six year old, you don't understand it yourself”
...working my way through the 1000+ ways things don't work to find the one that does
UC400eth, UC300eth, UCCNC v1.2106, Neuron Lite
UCCNC v1.2105 Macro Manual
Robertspark
 
Posts: 981
Joined: Sat Sep 03, 2016 4:27 pm
Location: Nr Liverpool, England

Re: A problem with outputs

Postby Dan911 » Sun Oct 14, 2018 12:35 pm

Thanks for the explanation Balazs, I always assumed wait() was a UCCNC function for Thread.Sleep although I did experience different results of the 2 like Terry. I found the opposite though, wait() skipped and Thread.Sleep more reliable. In testing to see accuracy of Thread.Sleep I would consistently get a Out of Memory window after 10 minuets.

In my inexperienced, lack of knowledge opinion, Thread.Sleep is needed and great for it's purpose but what Terry is trying to use it for there are other more reliable options.

Dan
Dan911
 
Posts: 416
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: A problem with outputs

Postby Vmax549 » Sun Oct 14, 2018 12:48 pm

My Question and concern is WHY Macros cannot be made to just run in linear order. Complete each line of code before starting teh next. That would eliminate any need for Wait()/Sleep() by the users. I am constantly having to GUESS how long to wait to make SURE it completes but not wanting to add more than is needed as that time can add up over Long routines. IF i fine tune it for this PC then the next PC it may have to be tweaked to another value.

(;-) TP
Vmax549
 
Posts: 1297
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: A problem with outputs

Postby Battwell » Sun Oct 14, 2018 12:53 pm

i found this writing my button timer code.
setting a variable to the tick timer- anything else could access it if required.
seems to be working sweet.
Uc300eth on router and mill
If they say it can't be done- I find a way!
Battwell
 
Posts: 374
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: A problem with outputs

Postby cncdrive » Sun Oct 14, 2018 6:01 pm

Lines run in a linear order so I'm not sure what are you talking about.
cncdrive
Site Admin
 
Posts: 2260
Joined: Tue Aug 12, 2014 11:17 pm

PreviousNext

Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 5 guests