plc programming

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
acorn_automation
Posts: 11
Joined: Fri Feb 15, 2019 2:15 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: ok375 - C120629; ok375 - c120683
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

plc programming

Post by acorn_automation »

Usin the Acorn to drive a custom hardware configuration for a single axis horizontal deep drill. Use two hardware inputs as triggers: ProbeDetect (INP6) to RetractDrillBtn; and ProbeTrigger (INP7) to StartDrillCycleBtn.

Remarked out all the lines the have ProbeDetect & ProbeTrigger. The StartDrillCycleBtn acts as a Cycle Start. This operates ok.

However when the RetractDrillBtn (formerly ProbeDetect) executes the ... DoCycleCancel ... the following problems occure
1) loose some of the functionality of the virtual jog panel, specifically the red cycle stop button and the green cycle start. It does not mater where the code is inserted: mainstage, spindlestage, jog panel stage or mcode processing.
2) loose the output M3, it gets stuck on no matter what is done: E-Stop, even exiting the CNC12; the m3 output relay will not turn off. have to kill power to the Acorn.

I have tried each function, StartDrillCycleBtn & RetractDrillBtn, separately and both together. The RetractDrillBtn causes the same problem no matter what, no matter where it is inserted

Any suggestions.







Code fragment liner 155 thru 166

;------------------------------------------------------------------------------
; INPUT DEFINITIONS
; Closed = 1 (green) Open = 0 (red)
;------------------------------------------------------------------------------
FirstAxisHomeLimitOk IS INP1 ;&*;
SecondAxisHomeLimitOk IS INP2 ;&*;
ThirdAxisHomeLimitOk IS INP3 ;&*;
FourthAxisHomeLimitOk IS INP4 ;&*;
DriveOk IS INP5 ;&*;
RetractDrillBtn IS INP6 ;&*; ProbeDetect
StartDrillCycleBtn IS INP7 ;&*; ProbeTripped
EStopOk IS INP8 ;&*;
;------------------------------------------------------------------------------
Code fragment liner 2032 thru 2042

IF (CycleCancelKey || KbCycleCancel_M || SkinCycleCancel_M) && (SV_PROGRAM_RUNNING || SV_MDI_MODE)
|| ErrorFlag_M
THEN (DoCycleCancel)

IF (StartDrillCycleBtn || CycleStartKey || KbCycleStart_M || SkinCycleStart_M) THEN (DoCycleStart)

IF True THEN RST JogKeysNormalStage,
RST JogKeysInvert2Stage,
RST JogKeysSwappedStage,
RST JogKeysSwapAndInvert2Stage
;------------------------------------------------------------------------------
Code fragment line 2767 thru 2076
;--M-Codes
; Reset these M-codes if not in CNC Program Running mode
IF !(SV_PROGRAM_RUNNING || SV_MDI_MODE) || SV_STOP
THEN RST M3,
RST M4,
RST M8,
RST M7,
RST M10
;
IF RetractDrillBtn && SV_PROGRAM_RUNNING THEN (DoFeedHold),(DoCycleCancel), (DoSpindleStop)
acorn_automation
Posts: 11
Joined: Fri Feb 15, 2019 2:15 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: ok375 - C120629; ok375 - c120683
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: plc programming

Post by acorn_automation »

Is it possible to program the mpu.plc to call a external custom macro: M68 thru M79. there are no definitions for calls to M68-M79 in the mpu.src file.
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 programming

Post by tblough »

acorn_automation wrote: Fri Feb 15, 2019 10:32 am Is it possible to program the mpu.plc to call a external custom macro: M68 thru M79. there are no definitions for calls to M68-M79 in the mpu.src file.
Check this thread viewtopic.php?f=20&t=2540 for macro calls from the PLC.
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.
Centroid_Tech
Posts: 286
Joined: Thu Mar 18, 2010 2:24 pm

Re: plc programming

Post by Centroid_Tech »

Please always post a current report from the system in order for us to be able to properly assist you. Personally, I believe that your issue is with the following line

IF RetractDrillBtn && SV_PROGRAM_RUNNING THEN (DoFeedHold),(DoCycleCancel), (DoSpindleStop)

I believe that the parenthesis on those system variables may be the culprit. The PLC logic uses the following logic

IF CONDITION THEN SET/RST OUTPUT

The OUTPUT can be a physical output, memory bit, timer, stage, etc. If you had logic in the PLC program that would have the following behavior

IF CONDITION THEN SET OUTPUT
IF !CONDITION THEN RST OUTPUT

then those 2 lines can be combined into 1 line as follows

IF CONDITION THEN (OUTPUT)

The parentheses on OUTPUT will set the state of OUTPUT to be "on" or "set" as long as the CONDITION is true and if the CONDITION is false then the state of OUTPUT will be "off" or "reset". When writing a PLC program, those parentheses should only be used if the state of that OUTPUT is ONLY controlled by that one CONDITION. If there are other CONDITIONs anywhere else is the PLC program, then you are going to have competing logic trying to control the state of the OUTPUT.

There are other locations in the PLC program that are setting DoFeedHold, DoCycleCancel, and DoSpindleStop so chances are that is what is causing your issue but without the current report, I can only speculate on that. Also, having the CONDITION set DoFeedHold and DoCycleCancel doesn't make any sense. There is no need to place the system into a FeedHold state if you are cancelling out of the job.

What I would recommend doing is adding your CONDITION, RetractDrillBtn && SV_PROGRAM_RUNNING, to the existing CONDITION that is already in the PLC program that handles the DoCycleCancel and DoSpindleStop.

Let me know if what I stated above is confusing and what is confusing so that I can try to make it clearer.
When requesting support, please ALWAYS post a current report. Find out how to take a report from your Acorn, CNC11 or CNC10 system here: https://www.youtube.com/watch?v=Ecvg0VJp1oQ.

If your question is PLC, Macro or program related, please also post a copy of the program or macro as well.

Without the above information we may not be able to help and/or reply until the required information is posted..
acorn_automation
Posts: 11
Joined: Fri Feb 15, 2019 2:15 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: ok375 - C120629; ok375 - c120683
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Post by acorn_automation »

Understood. FYI I am an experienced computer and PLC programmer. I have read thru the mpu.src code many times. I understand the syntax, and can distinguish between variables and functions. But any guidance you can provide is appreciated. In modifying the code, I make one change at a time and keep a history of changes so I can revert to a prior working version if things go to crap. When changes are made I try everything associated with the change to make sure nothing is 'broken'.

Have tried many variations on getting this to work but have been unsuccessful. Specifically, added code/logic that does what Is desired but 'breaks' : the virtual jog panel Cycle Start and or Hold; MDI M5, spindle does not stop; hard wired E-stop, not stop spindle.

Stepping back and starting over with an unmodified version of mpu.src.

1st step just compile and load to see no adverse affects; all ok.
2nd step rename ProbeDetect to StartDrillCycle
modified line as shown: <ProbeDetect IS INP6 ;&*;> to <StartDrillCycle IS INP6 ;&*;>.
And remark out where ProbeDetect appears, it causes a compiler error.

remarked out lines 2182 thru 2186
;IF (SpinStopKey || KbSpinStop_M || SkinSpinStop_M) ||
; (SpinAutoModeLED && !(M3 || M4)) ||
; (SV_PC_RIGID_TAP_SPINDLE_OFF && SpinAutoModeLED) ||
; ProbeDetect || SV_STOP || ErrorFlag_M || LimitTripped_M
; THEN (SpinStop_M

and line 2220
;IF ProbeDetect && SpinStart_M THEN SET ProbeFault_M

Nothing else. No processing or logic.
Loaded the new mpu.plc. Power off the acorn board. Powerup. Home the machine.
Run spindle via MDI M3. Spindle output comes on, contactor activates, spindle runs.
Try to stop spindle via MDI: M5. Nothing, spindle will not stop. "Press" Jog Panel Virtual Estop: nothing, spindle will not stop. Exit CNC12, spindle does not stop. The only way to stop the spindle is to remove power from the Acorn board.

No logic added only label and remark out code.

I do not see how to attach a report file.
rruizvial
Posts: 64
Joined: Wed Feb 27, 2019 11:09 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 7804738481A4 0130191589.
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Contact:

Re: plc programming

Post by rruizvial »

I am a senior programmer in C / C ++, but I do not understand much about PLC programming, there is only IF THEN and GOTO (is it like using BASIC language?? or they are macros for C, because they use the operators || (OR) and && (AND) ??), where there is a document that explains if there are more keywords or the structure of the program or the specificities of acorn board??
rl49
Posts: 52
Joined: Wed Nov 23, 2011 11:04 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: K2019,K1110
DC3IOB: No
CNC11: No
CPU10 or CPU7: Yes
Location: Finger Lakes, NY

Re: plc programming

Post by rl49 »

martyscncgarage
Posts: 9914
Joined: Tue Mar 28, 2017 12:01 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Location: Mesa, AZ

Re: plc programming

Post by martyscncgarage »

You attach a report to your message by clicking on the attachments tab below the box you type your message in. (Under the Save Draft Preview Submit buttons)
Reminder, for support please follow this post: viewtopic.php?f=20&t=383
We can't "SEE" what you see...
Mesa, AZ
DannyB
Posts: 109
Joined: Mon Jan 15, 2018 1:11 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: Yes
CNC Control System Serial Number: A900712
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: plc programming

Post by DannyB »

rruizvial wrote: Sat Mar 02, 2019 9:45 pm I am a senior programmer in C / C ++, but I do not understand much about PLC programming, there is only IF THEN and GOTO (is it like using BASIC language?? or they are macros for C, because they use the operators || (OR) and && (AND) ??), where there is a document that explains if there are more keywords or the structure of the program or the specificities of acorn board??
You can think of PLC programming as a while loop around some C code where everything is a shadow variable. All loads to shadow variables occur at the top of the loop, all stores from shadow variables occur at the end of the iteration.

IE
while (1)
{
reg1 = *realmem1
reg2 = *realmem2

<plc code that uses reg1, reg2, reg3>

*realmem1 = reg1
*realmem2 = reg2
}


Things like stages are just scoped blocks controlled by conditionals.
IE

if (stage1) { <code for stage> ...}

(PLC languages vary a *lot*. Though nowadays, there are standards for PLC programming languages like iec 61131-3 that are supported by a lot of vendors that make it fairly portable.)
rruizvial
Posts: 64
Joined: Wed Feb 27, 2019 11:09 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 7804738481A4 0130191589.
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Contact:

Re: plc programming

Post by rruizvial »

DannyB wrote: Mon Mar 04, 2019 1:05 am
rruizvial wrote: Sat Mar 02, 2019 9:45 pm I am a senior programmer in C / C ++, but I do not understand much about PLC programming, there is only IF THEN and GOTO (is it like using BASIC language?? or they are macros for C, because they use the operators || (OR) and && (AND) ??), where there is a document that explains if there are more keywords or the structure of the program or the specificities of acorn board??
You can think of PLC programming as a while loop around some C code where everything is a shadow variable. All loads to shadow variables occur at the top of the loop, all stores from shadow variables occur at the end of the iteration.

IE
while (1)
{
reg1 = *realmem1
reg2 = *realmem2

<plc code that uses reg1, reg2, reg3>

*realmem1 = reg1
*realmem2 = reg2
}


Things like stages are just scoped blocks controlled by conditionals.
IE

if (stage1) { <code for stage> ...}

(PLC languages vary a *lot*. Though nowadays, there are standards for PLC programming languages like iec 61131-3 that are supported by a lot of vendors that make it fairly portable.)
"stages" it reminds me a little the arduino programming:

InitialStage -> setup()
MainStage -> loop()
Post Reply