Macroloop while running a program

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

Macroloop while running a program

Postby Battwell » Fri Sep 21, 2018 12:50 am

Ive finished up my modbus slave panel and everything is just about working as it should
Except while running a program the stop and feedhold buttons won’t respond in the macroloop.
Is there an easy way to solve this?
They work just as expected when a program is not running.
I’m using dobutton calls .
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Macroloop while running a program

Postby dezsoe » Fri Sep 21, 2018 7:08 am

It should work. I made a quick test with an Arduino configured to return 4 input pins in one register. The macroloop below works fine, presses stop or feed hold. It's storing the last input state and presses the buttons only if needed. (It's a truncated version of a longer code with analog and digital I/O.)

Code: Select all
// ================================================================================================
// Modbus I/O with Arduino
// ================================================================================================

ushort Inputs = 0;

exec.GetModbusregister(0, out Inputs);

int newInputs = ((int)Inputs & 0x0F) ^ 0x0F;                                    // 4 inputs, change to active high

if (lastInputs == 16) lastInputs = newInputs;                                   // No change on first run

if (newInputs != lastInputs)
{
  int change = newInputs ^ lastInputs;
  if ((change & 0x04) != 0)
  {
    if ((newInputs & 0x04) != 0)
      exec.Callbutton(130);
  }
  if ((change & 0x08) != 0)
  {
    if ((newInputs & 0x08) != 0)
      exec.Callbutton(522);
  }
  lastInputs = newInputs;
}

// ================================================================================================

#Events

// ================================================================================================

int lastInputs = 16;
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macroloop while running a program

Postby Battwell » Fri Sep 21, 2018 9:57 am

im using this code- works fine- if not running a program

//// STOP button////
bool stopled=AS3.GetLED(232); // stop led on?
//exec.AddStatusmessage (""+mpgled) ; //changed on screen check
if (stopled)
{
exec.SetModbusregister((57),(ushort)1);
}
else
{
exec.SetModbusregister((57),(ushort)0);
}
if(exec.GetModbusregister(18,out button)&& button==0) //mpg
{
exec.Callbutton(130); //mpg multi
exec.SetModbusregister((57),(ushort)1);

exec.SetModbusregister((56),(ushort)0);
}

//// FEEDHOLD button////
bool holdled=AS3.GetLED(217); // led on?
//exec.AddStatusmessage (""+mpgled) ; //changed on screen check
if (holdled)
{
exec.SetModbusregister((58),(ushort)1);
}
else
{
exec.SetModbusregister((58),(ushort)0);
}
if(exec.GetModbusregister(19,out button)&& button==0) //
{
exec.Callbutton(522); //
exec.SetModbusregister((58),(ushort)1);
Thread.Sleep(300);
//exec.SetModbusregister((56),(ushort)0);
}
Thread.Sleep(300);
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Macroloop while running a program

Postby dezsoe » Fri Sep 21, 2018 10:32 am

It's strange. I changed only the modbus register numbers and the button check value to fit to my config and it works. Not fine, because if you press the button too long then it will toggle the buttons, and because the long delay it's not so responsive. That's why I save the last state and do anything only if there is a change. But, it works, so I don't understand what happens at you.

Code: Select all
//// FEEDHOLD button////
bool holdled=AS3.GetLED(217); // led on?
//exec.AddStatusmessage (""+mpgled) ; //changed on screen check
if (holdled)
{
  exec.SetModbusregister((10),(ushort)1);
}
else
{
  exec.SetModbusregister((10),(ushort)0);
}
if(exec.GetModbusregister(0, out button) && button==7) //
{
  exec.Callbutton(522); //
  exec.SetModbusregister((58),(ushort)1);
  Thread.Sleep(300);
  //exec.SetModbusregister((56),(ushort)0);
}
Thread.Sleep(300);

(The stop part works too, but now I have only one button on my breadboard, so first I tested stop and then feed hold. Both work.)
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macroloop while running a program

Postby Battwell » Fri Sep 21, 2018 1:44 pm

its weird- will stop if the program has only been running a second or two- then locks out.
with modbus plugin viewabale i can see the button press- but there is no output. (output blocked)?
everything works real nice when stop is pressed on screen again. i just cant get it to stop or toggle feedhold once its blocked :-(
latest development version of software. (had to reinstall after windows defender deleted uccnc)
il make a video later to show what im getting
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Macroloop while running a program

Postby dezsoe » Fri Sep 21, 2018 1:56 pm

Exactly which version did you try? Now I left it running more than a minute before I pressed the button, but it went to feed hold and back as it should.
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macroloop while running a program

Postby Battwell » Fri Sep 21, 2018 3:23 pm

1.2106 in demo mode
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Macroloop while running a program

Postby Battwell » Fri Sep 21, 2018 3:28 pm

ah
just plugged in old usb300 - and it seems it works for a bit longer- then stops ?.
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Macroloop while running a program

Postby dezsoe » Fri Sep 21, 2018 3:59 pm

OK. First I tested with the next test version (not released yet) with demo, UC100 and UC400ETH. Now I tested with 2106 and UC400ETH. All variations work. So, I think there must be something in your macroloop (I think you posted just a part of it), or there are some other macroloops that can disturb this. First disable all other macroloops then check the whole code.
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macroloop while running a program

Postby Battwell » Fri Sep 21, 2018 4:03 pm

No other loops running.
Just testing further- seems to work all the time if start is pressed on screen but not from macro. ( to be verified by more testing)
But otherwise is working great
https://youtu.be/1ZgtuUYOtaY
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 819
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Next

Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 24 guests

cron