MacroLoop Quirk ??

If you think you've found a bug post it here.

MacroLoop Quirk ??

Postby Vmax549 » Fri Mar 02, 2018 2:15 pm

I am testing button activation in a macro Loop. I simple press a button and teh LED lights up. Then an action is performed when the macro sees teh LED go active. I used a while loop to HOLD teh macro so it did not repeat teh action until the button is released.

In a normal macro this works exactly as it is programed to do. The while loop HOLDS teh macro until the button is released.

BUT in a macro Loop it does not work that way. When the button is pressed teh LED comes on and teh macro SEES the led go active and it does the action as programmed.

Then the HOLD is applied by the while loop BUT it does NOT hold teh macroLoop. It appears that teh macroloop simply spawns another thread and keeps on looping.

Is this a bug or a feature ??? IF it is a feature it is a BAD one.

(;-) TP


exec.Setoutpin(4,16);
exec.Clroutpin(4,16);

if (!AS3.GetLED(104))
{
string Num ="2";
exec.AddStatusmessage(Num);

while(!AS3.GetLED(104))
{
// Wait for Button Release
}

}
Vmax549
 
Posts: 910
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Re: MacroLoop Quirk ??

Postby cncdrive » Fri Mar 02, 2018 2:20 pm

No, there is no such bug in macroloops. The macro loop code is compiled and executed as it is typed. It is directly compiled by the .NET compiler, so it is not possible that the macro compiler creates another thread when you not coding to create another thread.
cncdrive
Site Admin
 
Posts: 1855
Joined: Tue Aug 12, 2014 11:17 pm

Re: MacroLoop Quirk ??

Postby cncdrive » Fri Mar 02, 2018 2:36 pm

I modified the macro a bit to be able to test it here now.

Code: Select all
exec.Setoutpin(2,10);
exec.Clroutpin(2,10);

if (!AS3.GetLED(10))
{
string Num ="2";
exec.AddStatusmessage("one");

while(!AS3.GetLED(10))
{
  // Wait for Button Release
  Thread.Sleep(100);
  exec.AddStatusmessage("two");

}

}


It checks the port#1 pin#10 LED for the IF and the WHILE loop.
So, when I'm triggering the input it writes "one" and then it writes "two" multiple times until I release the input.
Then when I'm triggering the input again it does the same again.
So, the macro works fine as it should.
cncdrive
Site Admin
 
Posts: 1855
Joined: Tue Aug 12, 2014 11:17 pm

Re: MacroLoop Quirk ??

Postby Vmax549 » Fri Mar 02, 2018 3:26 pm

That is not how it is working here. IF I hold down teh button teh 2 will keep repeating in teh status window.

This is testing on a UC300eth if that has anything to do with it.

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

Re: MacroLoop Quirk ??

Postby cncdrive » Fri Mar 02, 2018 3:31 pm

And what does that button do?
You checking a LED not a button, so the question is how does the button trigger the LED? Maybe the problem is in that code.
cncdrive
Site Admin
 
Posts: 1855
Joined: Tue Aug 12, 2014 11:17 pm

Re: MacroLoop Quirk ??

Postby cncdrive » Fri Mar 02, 2018 3:34 pm

And if the "one" and "two"s are repeating does not mean that the loop is duplicated, just that the loop went to the end and then started from the beginning again,
so that means the the LED you reading changed states, flickered etc.
cncdrive
Site Admin
 
Posts: 1855
Joined: Tue Aug 12, 2014 11:17 pm

Re: MacroLoop Quirk ??

Postby Vmax549 » Fri Mar 02, 2018 3:40 pm

I just tested your version and as long as I hold down the button the "one" keeps repeating in the status bar. AND when I let up the button the "two" never shows up.

V2047 UC300eth

Are you testing it in a MacroLoop ? In a normal Macro it works just fine.

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

Re: MacroLoop Quirk ??

Postby Vmax549 » Fri Mar 02, 2018 4:18 pm

OK I had to go back and double check. I installed a button switch between COM and input port4 pin2. When I press teh button teh LED104 turns OFF and shows steady. When I release teh button the LED turns ON and shows steady. No flickering that I can see.

I HAVE tried this on 2 different systems with same results.

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

Re: MacroLoop Quirk ??

Postby Vmax549 » Fri Mar 02, 2018 5:39 pm

OK further testing, I tried this on port5 and port 4 with teh same results. I then tried it on port1 and it works. Back to 4&5 and it does not work. SO I think I have something flaky going on with port 4&5.

I also change out teh 5LPT board and same results. 4&5 are flaky 1 is good.

SO it is NOT a quirk in teh software.

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

Re: MacroLoop Quirk ??

Postby cncdrive » Fri Mar 02, 2018 6:13 pm

OK, I thought it is a button on the screen, a virtual button which somehow set something to set that LED.
Now I see that you physically triggering the port#4 pin#2 which is LED 104. and checking that LED in the macro.
So, I've changed the macro which I already modified a bit as I posted to look for LED 104. instead of LED 10. and then I triggered the port#4 pin#2 kept it on and then released it finally.
And it works fine at me, it works the same, it writes "one" when the pin is triggered and write "two"s until I release the pin. And when I do it again then it again does the same with "one" and then "two"s.

I think it should be something with how you triggering the input. It could be a prell on the button or something which releases the pin and so you see lots of "one"s because the loop restarts when the pin is released for even a short time.
cncdrive
Site Admin
 
Posts: 1855
Joined: Tue Aug 12, 2014 11:17 pm

Next

Return to Report a bug

Who is online

Users browsing this forum: No registered users and 1 guest