Machine Red-green colour Status Light Macro

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Machine Red-green colour Status Light Macro

Postby attila0216 » Wed Aug 16, 2017 6:26 pm

Good Evening

Was wondering if anyone could help me out with a simple macro for my machine status light. What i'd like is, that one i press Cycle start in UCCNC an Output pin goes active on my HDBB2 breakout board which will turn on Green led on Machine Tower led. and when I Press Stop, Green led Output goes off and another Output turns on which would turn RED light on. When UCCNC in RESET i'd like RED led blinking just like on screen in UCCNC.
Could someone write me a macro like that?

Thank you.
attila0216
 
Posts: 15
Joined: Wed Feb 08, 2017 11:37 pm

Re: Machine Red-green colour Status Light Macro

Postby dezsoe » Wed Aug 16, 2017 6:36 pm

Hi,

You don't need any macro, just use output trigger. Set pin and port for green light, set LED to 54. In the next row set pin and port for red light, check Low, set LED to 54. Apply and save settings. You are ready. :)
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Machine Red-green colour Status Light Macro

Postby attila0216 » Wed Aug 16, 2017 6:48 pm

Thank you Dezső,

As soon as i have my PC up and running will give it a try. Thank You again!
attila0216
 
Posts: 15
Joined: Wed Feb 08, 2017 11:37 pm

Re: Machine Red-green colour Status Light Macro

Postby attila0216 » Wed Aug 16, 2017 7:03 pm

Dezső,
I've just tried on my home PC with Demo UCCNC and works great. Just another question. I have tried to use a 3rd output pin for Reset Led number 25. and ouput goes active, but how can i make output 3 on an off in 1 second in order to blink?
attila0216
 
Posts: 15
Joined: Wed Feb 08, 2017 11:37 pm

Re: Machine Red-green colour Status Light Macro

Postby dezsoe » Wed Aug 16, 2017 8:44 pm

That needs a macroloop. Perhaps an external flash circuit or a flashing LED. :)
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Machine Red-green colour Status Light Macro

Postby Robertspark » Wed Aug 16, 2017 9:24 pm

attila0216 wrote:Dezső,
I have tried to use a 3rd output pin for Reset Led number 25. and ouput goes active, but how can i make output 3 on an off in 1 second in order to blink?


Which port, and which pin?
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Machine Red-green colour Status Light Macro

Postby dezsoe » Thu Aug 17, 2017 7:32 am

OK, here is a macroloop for flashing the output if reset is on. Save it as M2xxxx.txt and set as autorun in config/general/macroloop. Don't forget to set OutPort and OutPin constants!

Code: Select all
bool ResetState = exec.GetLED(25);
bool NewPinState;

if (ResetState != LastState)
{
  LastState = ResetState;
  Cnt = CntMax - 1;
}

if (ResetState)
{
  if (++Cnt == CntMax)
  {
    Cnt = 0;
    NewPinState = !LastPinState;
  }
  else
    NewPinState = LastPinState;
}
else
  NewPinState = false;

if (NewPinState != LastPinState)
{
  LastPinState = NewPinState;
  if (NewPinState)
    exec.Setoutpin(OutPort, OutPin);
  else
    exec.Clroutpin(OutPort, OutPin);
}

#Events

const int CntMax = 10;    // Flash speed in 50ms steps

const int OutPort = 2;    // Output port
const int OutPin = 2;     // Output pin

static int Cnt = 0;
static bool LastState = false;
static bool LastPinState = false;
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Machine Red-green colour Status Light Macro

Postby Robertspark » Thu Aug 17, 2017 9:17 am

Nice dezsoe.
I thought about using timer.elapsed, but it seemed too complicated at first last night then this morning thought about using a counter incremented by the macroloop which is way more simplified and does the job.

You should add the macroloop code to the toolbox thread so it can be found in the future and reused.
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Machine Red-green colour Status Light Macro

Postby dezsoe » Thu Aug 17, 2017 10:33 am

Robertspark wrote:You should add the macroloop code to the toolbox thread so it can be found in the future and reused.


Good idea. I will collect my macros when I'll have some time, but this will not be on this week. :)
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Machine Red-green colour Status Light Macro

Postby attila0216 » Thu Aug 17, 2017 2:50 pm

Thank You!!!!!(Köszönöm szépen!)
attila0216
 
Posts: 15
Joined: Wed Feb 08, 2017 11:37 pm

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 1 guest