Add an output pin to M215 for relay

Here is where you can request new features or special features.

Add an output pin to M215 for relay

Postby Tom Jenn » Wed Apr 28, 2021 9:45 pm

I need to add an output port and pin to M215 P2 to drive a relay to change the range on my VFD.
M215 P Sets the pulley number, But it isn't in the Macro list (UCCNC\Profiles\MACRO_Default).
Please, Where can I find it, and can it be edited to do this?
Tom Jenn
 
Posts: 3
Joined: Wed Apr 28, 2021 8:55 pm

Re: Add an output pin to M215 for relay

Postby dezsoe » Wed Apr 28, 2021 11:10 pm

Not all M-codes are saved as macros, there are some that are programmed into UCCNC and this is one of them. You have to write a macroloop to check for the Pulleynumber field (2013) and set an output as you need.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Add an output pin to M215 for relay

Postby Tom Jenn » Thu Apr 29, 2021 4:46 pm

Thanks for that, dezsoe.
At this moment I have no idea how to do that, any help would be appreciated.
What is field (2013)?
Tom.
Tom Jenn
 
Posts: 3
Joined: Wed Apr 28, 2021 8:55 pm

Re: Add an output pin to M215 for relay

Postby dezsoe » Thu Apr 29, 2021 6:44 pm

The current pulley number is stored in field #2013, so you have to check this value in a macroloop and if it is 2 then set the output else clear the output. Below is a macro for this. Save it to the Profiles\Macro_yourprofilename folder as Mxxxx where xxxx is any number that is not used. (E.g. 20000, you can see the profile name on the main screen.) Go to General settings, press Config macroloops and set the number you used to an empty row. Tick Autorun, click Run, click Save settings. Don't forget to edit outputPort and outputPin, I tested with port #3 pin #17.

Code: Select all
// ================================================================================================
// Check pulley, set output when pulley is 2 (M215 P2)
// ================================================================================================

const int outputPort = 3;
const int outputPin = 17;

bool isPulley2 = (AS3.Getfieldint(2013) == 2);

if (firstRun)
{
  // Force output to be set/clear on startup
  lastIsPulley2 = !isPulley2;
  firstRun = false;
}

if (isPulley2 != lastIsPulley2)
{
  // isPulley2 changed
  if (isPulley2)
    exec.Setoutpin(outputPort, outputPin);
  else
    exec.Clroutpin(outputPort, outputPin);
  lastIsPulley2 = isPulley2;
}

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

#Events

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

bool firstRun = true;
bool lastIsPulley2 = false;

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

Re: Add an output pin to M215 for relay

Postby Tom Jenn » Fri Apr 30, 2021 9:47 pm

Hi dezsoe,
That is exactly what I wanted, it works well.
Thank you.
Tom.
Tom Jenn
 
Posts: 3
Joined: Wed Apr 28, 2021 8:55 pm


Return to Feature Request

Who is online

Users browsing this forum: No registered users and 6 guests