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.
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?
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.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)
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.
(Note: Liking will "up vote" a post in the search results helping others find good information faster)