PLC SV_SYS_MACRO logic question

Moderator: cnckeith

Post Reply
tblough
Posts: 3102
Joined: Tue Mar 22, 2016 10:03 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: 100505
100327
102696
103432
7804732B977B-0624192192
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Boston, MA
Contact:

PLC SV_SYS_MACRO logic question

Post 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
Cheers,

Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
cncsnw
Posts: 3855
Joined: Wed Mar 24, 2010 5:48 pm

Re: PLC SV_SYS_MACRO logic question

Post 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.
tblough
Posts: 3102
Joined: Tue Mar 22, 2016 10:03 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: 100505
100327
102696
103432
7804732B977B-0624192192
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Boston, MA
Contact:

Re: PLC SV_SYS_MACRO logic question

Post 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.
Cheers,

Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.
Post Reply