Delayed Output Off

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

Delayed Output Off

Postby matt_b » Wed Jul 21, 2021 12:11 am

Hi,

This is my first post, so hello - I'm currently in the process of rewiring the control cabinet for my CNC router and changing its controller for an AXBB-E. Is it possible to configure a spare output, on the AXBB-E, so that it activates whenever either of the M3/M4 pins are active and then deactivates a configurable number of seconds after the M3 or M4 pins have become inactive?

Matt.
matt_b
 
Posts: 3
Joined: Thu Jun 03, 2021 8:36 pm

Re: Delayed Output Off

Postby cncdrive » Wed Jul 21, 2021 2:28 pm

Yes, it is possible with a Macroloop. The loop has to check the M3 and M4 LEDs.
Dezsoe could probably help you with writting a macro quickly.
cncdrive
Site Admin
 
Posts: 4717
Joined: Tue Aug 12, 2014 11:17 pm

Re: Delayed Output Off

Postby matt_b » Thu Jul 22, 2021 10:41 am

Thanks - I'll look into that.
matt_b
 
Posts: 3
Joined: Thu Jun 03, 2021 8:36 pm

Re: Delayed Output Off

Postby dezsoe » Sun Jul 25, 2021 10:09 pm

Hi Matt,

Save the following code to a macro and set it as a macroloop. Change the time constant and the output port/pin/active low as you need.

Code: Select all
// ================================================================================================
// Set output if spindle is on and turn it off delayed
// ================================================================================================

bool Spindle = exec.GetLED(50) || exec.GetLED(51);

if (Spindle != lastSpindle)
{
  if (Spindle)
  {
    // Spindle was turned on -> turn on output
    turnOn();
  }
  else
  {
    // Spindle was turned off -> reset timer
    count50ms = 0;
  }
  lastSpindle = Spindle;
}

if (count50ms < offTime)
{
  // Timer is running
  if (++count50ms == offTime)
  {
    // offTiem is reached -> turn off output
    turnOff();
  }
}

// =============================================================================  -- Events --

#Events

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

// =============== Time constant in 1/20 seconds (20 = 1s)

const int offTime = 20;

// =============== Output port, pin, active low

const int port = 3;
const int pin = 17;
const bool alow = false;

// =============== Variables

static int count50ms = offTime;
static bool lastSpindle = true;

// output functions

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

// =============== Turn on output

void turnOn()
{
  if (alow)
    exec.Clroutpin(port, pin);
  else
    exec.Setoutpin(port, pin);
}

// =============== Turn off output

void turnOff()
{
  if (alow)
    exec.Setoutpin(port, pin);
  else
    exec.Clroutpin(port, pin);
}

// ================================================================================================
dezsoe
 
Posts: 2055
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Ask a question from support here

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 19 guests