A problem with outputs

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

A problem with outputs

Postby Vmax549 » Sat Oct 13, 2018 1:42 pm

While Working on a simple script to do Mist pulsing from a macroLoop I ran into this problem. It simply cycles the mister on and off for a set duration. It is triggered by teh M7 LED to start and stop. The problem is the output. IF I run this the first time after starting UCCNC it works exactly as programed. If I stop it and restart teh output durations are all out of wack. It will be random as to how it cycles. It speeds up and slow down the cycles. Some fast and some slow. To correct it I have to Shut down UCCNC and reboot teh PC. BUT after restarting it will only work 1 time again then does its thing.

I have tried it on 2 PCs . 1 is my work PC running in demo mode. The 2nd is a controller running a UC300eth.

I forgot to add: 2 different OS and 2 different versions of UCCNC.

Both PCs act exactly teh same. 1st time runs perfect 2nd time it messes up.

Also no matter how many different ways I have rewrote this it still acts teh same way. 2nd time fails

Anyone have ANY ideas about this ???

(;-)TP

//## Macro for pulsing Mist , M920

while (AS3.GetLED(52))
{
int time = AS3.Getfieldint(187);
exec.Wait(100);

exec.Setoutpin(1,14);
//if(!AS3.GetLED(52)){goto end;}

exec.Wait(time);
//if(!AS3.GetLED(52)){goto end;}

exec.Clroutpin(1,14);
//if(!AS3.GetLED(52)){goto end;}

exec.Wait(time);
//if(!AS3.GetLED(52)){goto end;}

}
end:
exec.Clroutpin(1,14);
Vmax549
 
Posts: 1297
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: A problem with outputs

Postby Robertspark » Sat Oct 13, 2018 4:27 pm

Why are you using exec.wait?

Everything stops for wait.

Use sleep.... That way the loop will not stop but check back to see if sleep time has passed

https://docs.microsoft.com/en-us/dotnet ... work-4.7.2
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 Robertspark » Sat Oct 13, 2018 4:29 pm

Exec.Wait is like / same as G4 pxxx.

Everything waits and stops for that time to pass
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 Vmax549 » Sat Oct 13, 2018 5:34 pm

It is like G4Pxxx

YES it is. ;)

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

Re: A problem with outputs

Postby Robertspark » Sat Oct 13, 2018 5:39 pm

???
Is it fixed now or did you want to use wait?
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 Vmax549 » Sat Oct 13, 2018 6:25 pm

OK I am teh Dummy on this one :o :o . With over 40 + macroloops running it is hard to remember exactly what you have running and when they may be a conflict. I had multiple macroloops triggering that port/pin on different occasions depending on what I was testing.

So when there are several macro loops triggering teh SAME pin it may look really ODD watching the output LED.

So NOW I guess I need to figure out a WAY to parse through ALL macroloops looking for Ports and pin combinations that have been used. But HOW do I get a list of teh macroloops named in teh MacroLoop config window?? HUM???

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

Re: A problem with outputs

Postby Vmax549 » Sat Oct 13, 2018 6:38 pm

HI Robert , Yes I intended to use Wait(). From time to time I see ODD things occuring when I use Thread.Sleep(). From what I see wait only effects teh thread you are running?? And in this case teh Wait() is stone dependable.

I have tested it with wait and sleep and see no difference on CPU load when running Gcode. The difference I see is Wait() ensures teh macro will run in perfect sync EVERY time. With sleep not so much.From time to time I see glitches.

Why you ask ??? I have NO idea :? :?

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

Re: A problem with outputs

Postby Robertspark » Sat Oct 13, 2018 8:40 pm

Vmax549 wrote: From time to time I see ODD things occuring when I use Thread.Sleep(). From what I see wait only effects teh thread you are running?? And in this case teh Wait() is stone dependable.


I suspect that wait is more accurate because it waits until the time has passed, however, sleep will poll the time intermittently .... And is subject to whatever else is running in the background and however long it gets hung up before it can poll the time again (I don't know but it's just a guess)
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 » Sat Oct 13, 2018 10:42 pm

I've read using Thread.Sleep() or wait() are poor and unstable solutions to thread syncing and there are many other reliable wait handles preferred. In most cases it can case more harm than good, I now refrain from using them. If used it's Thread.Sleep, I came across more than 1 instance's I seen wait() ignored. I also read using sleep/wait is poor programing.

Don't shot the messenger!!!!! Only relaying what I read.

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

Re: A problem with outputs

Postby Robertspark » Sat Oct 13, 2018 11:08 pm

So what is the alternative?
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

Next

Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 5 guests