Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: bcoop on May 17, 2020, 05:28:09 PM

Title: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: bcoop on May 17, 2020, 05:28:09 PM
my spindle clockwise button executes the function below, everything is work fine, but i'm trying to understand how mc.OSIG_SPINDLEON  gets turned on, 
I have searched all files without finding anywhere the output gets set or cleared.

Code: [Select]
function SpinCW()
    local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
    local sigState = mc.mcSignalGetState(sigh);
   
    if (sigState == 1) then
        mc.mcSpindleSetDirection(inst, 0);
    else
        mc.mcSpindleSetDirection(inst, 1);
    end
end

bob
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: KatzYaakov on May 17, 2020, 10:48:27 PM
i didnt read the api about that function,but as i understand you need also set RPM i think
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: thosj on May 18, 2020, 07:54:01 AM
......you need also set RPM i think

I've said it before and I'll say it again, Mach4 doesn't remember spindle speed between sessions, so before you can start the spindle you need to command a speed SOMEWHERE. S1000 in MDI, in gcode, in a script, somewhere.
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: bcoop on May 18, 2020, 09:30:04 AM

I tested the scenario with spindle RPM needing to be set. that doesn't appear to be the case,  I with zero in Spindle speed,  mc.OSIG_SPINDLEON  still gets turned on.


Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: SwiftyJ on May 18, 2020, 10:02:34 AM
The API call mc.mcSpindleSetDirection probably turns on the output
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: bcoop on May 18, 2020, 10:08:09 AM
it appears that mc.mcSpindleSetDirection is happening only when mc.OSIG_SPINDLEON  signal is = 1 (on)






Code: [Select]
-- Spin CCW function.
---------------------------------------------------------------
function SpinCCW()
    local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
    local sigState = mc.mcSignalGetState(sigh);
   
    if (sigState == 1) then
        mc.mcSpindleSetDirection(inst, 0);
    else
        mc.mcSpindleSetDirection(inst, -1);
    end
end
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: bcoop on May 20, 2020, 08:25:41 AM
SwiftyJ, I believe you are correct,  relooking at the script,  it checks if direction bit is set, and if so, resets the direction bit, otherwise sets it, which somewhere in mach core code is turning on the OSIG_SPINDLEON output.   

thanks
Bob
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: Brian Barker on May 20, 2020, 09:20:47 AM
This is set when you tell the spindle to start. This has nothing to do with the RPM... You can ask for a zero RPM with the spindle on and you will get that signal :). We have a spindle on and a spindle forward and reverse as signals.
{ "Spindle On", OSIG_SPINDLEON },
{ "Spindle Fwd", OSIG_SPINDLEFWD },
{ "Spindle Rev", OSIG_SPINDLEREV },

Hope I am helping here :)
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: bcoop on May 20, 2020, 09:47:51 AM
agree on the RPM,    but it appears to me that OSIG_SPINDLEON become true automatically whenever OSIG_SPINDLEFWD or OSIG_SPINDLEREV is turned on, I see no coding that is setting OSIG_SPINDLEON to True.
is it done is some complied Mach4 code ?
Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: Brian Barker on May 20, 2020, 10:22:50 AM
That is all coded into Mach4.

Here is how we do spindle CW in the core:
   m_control->SetSignalState(OSIG_SPINDLEREV, false);
   m_control->SetSignalState(OSIG_SPINDLEFWD, true);
   m_control->SetSignalState(OSIG_SPINDLEON, true);

The idea is that you can have a relay for on and direction . Some of the VFD's need that rubbish :)

Thanks
Brian


Title: Re: mc.OSIG_SPINDLEON - how does this signal get turned on?
Post by: bcoop on May 20, 2020, 11:19:30 AM
Thank you Brian,  all makes sense now..