Page 1 of 1

PLC SV_SYS_MACRO logic question

Posted: Wed Dec 06, 2023 11:30 am
by tblough
I'm updating my PLC programs to incorporate the latest revisions included in the Centroid release. Back in 2020 I asked a question about the reset logic on the SV_SYS_MACRO calls in the PLC - see https://centroidcncforum.com/viewtopic. ... CRO#p38333

In the latest Centroid released PLC programs, I see the reset logic has gotten even more complex with a timer now involved.

Code: Select all

IF MpgMacro1_M THEN SV_SYS_MACRO = 1
IF MpgMacro2_M THEN SV_SYS_MACRO = 2
IF MpgMacro3_M THEN SV_SYS_MACRO = 3
IF MpgMacro4_M THEN SV_SYS_MACRO = 4

IF ! (MpgMacro1_M || MpgMacro2_M ||
      MpgMacro3_M || MpgMacro4_M || Aux13PD_PD) THEN NoMacroKeyPressedTimer_T = 100,
                                                     SET NoMacroKeyPressedTimer_T
IF NoMacroKeyPressedTimer_T THEN SV_SYS_MACRO = 0,
                                 RST NoMacroKeyPressedTimer_T
So, once again I ask what am I missing by implementing the simpler code below?

Code: Select all

IF True_M THEN SV_SYS_MACRO = 0
IF MpgMacro1PD_PD THEN SV_SYS_MACRO = 1
IF MpgMacro2PD_PD THEN SV_SYS_MACRO = 2
IF MpgMacro3PD_PD THEN SV_SYS_MACRO = 3
IF MpgMacro4PD_PD THEN SV_SYS_MACRO = 4
Thanks - Tom

Re: PLC SV_SYS_MACRO logic question

Posted: Wed Dec 06, 2023 1:01 pm
by cncsnw
With your code, SV_SYS_MACRO holds the desired non-zero value for just one scan (20ms).

That is not necessarily long enough for CNC12 to notice it, so you will get intermittent behavior. The key might work most of the time, but it won't work every time.

Two scans seems to be sufficient, but there is no harm to leaving it on longer (e.g. five or six scans, as in the factory code). Theoretically another macro key press that comes in during the hold time would not register, but since you cannot run macros in quick succession anyway, that is okay.

Re: PLC SV_SYS_MACRO logic question

Posted: Wed Dec 06, 2023 2:32 pm
by tblough
Thanks Marc. That was the key - I didn't know that the controller needed more that one scan of the PLC to register the macro request.