**RESOLVED** PLC programming

All things related to Centroid Oak, Allin1DC, MPU11 and Legacy products

Moderator: cnckeith

Locked
Maint_1
Posts: 83
Joined: Sun Sep 19, 2010 3:24 pm
Allin1DC CNC Controller: No
CNC Control System Serial Number: A50391
DC3IOB: Yes
CNC11: Yes
CPU10 or CPU7: Yes

**RESOLVED** PLC programming

Post by Maint_1 »

I'm trying to figure out how to change the PLC programming for our machines. We currently have 4 in total and another on the way.

I'm using input 18 to monitor the air line into the machine. The default programming for this input is Lube_Fault_In. When I remove air I get a Lubricant_low message which is tied to OUT63. I trace this to the program statement Lubricant_low = PC_Lube_Fault & / Fault_Override. So to me this means Lubricant Low is a 1 when PC Lube fault is a 1 and Fault Override is not active or 0. This then makes OUT63 a 1 and the message Lubricant Low is written to the screen. Am I correct so far?

What I can't find is the conditions that set PC_Lube_Fault's state. Is this an internal default?

To change my message I should need to change the statement Lubricant_low = PC_Lube_Fault & / Fault_Override to Machine_Air_Low = PC_Lube_Fault & / Fault_Override?

Should I also change Lubricant_low is OUT63 to Machine_Air_Low is OUT63?

For the input definitions Lube_Fault_In IS INP18 ; Green = Lube OK Red= Lube low should change to Machine_Air_Fault_In IS INP18 ;Green=Air OK Red=Air low?


cncsnw
Posts: 4089
Joined: Wed Mar 24, 2010 5:48 pm

Re: PLC programming

Post by cncsnw »

Maint_1 wrote:
I trace this to the program statement Lubricant_low = PC_Lube_Fault & / Fault_Override. So to me this means Lubricant Low is a 1 when PC Lube fault is a 1 and Fault Override is not active or 0. This then makes OUT63 a 1 and the message Lubricant Low is written to the screen. Am I correct so far?
Yes.
What I can't find is the conditions that set PC_Lube_Fault's state. Is this an internal default?
The PLC program is in two parts. You quote above from the CPU-based PLC program (the half which runs on the CPU7 or CPU10 controller board). The other half (in fact the bulk of the interesting stuff) runs as a background task on the PC processor. The compiled file for that half is "pc.plc"; the source file should be named similarly to the file you were looking at, but with "p" or "pc" in place of "c" or "cp" or "cpu".

The language for the PC PLC program is a little different, but reasonably easy to figure out. A typical PC PLC program to go along with the CPU program you quote above would contain lines like:

Code: Select all

;
; If the lube is low set the lube alarm
;
IF (Lube_Fault_In XOR LUBENONC) |
    (PC_Lube_Fault & !E_stop) THEN (PC_Lube_Fault)
The exclusive-or allows the "LUBENONC" memory bit to invert the state of the Lube_Fault_In input, in case you have a normally-open float switch. The rest of the line sets "PC_Lube_Fault", which the CPU side of the program echoes back in the "Lubricant_low" bit; and resets it when E-stop is pressed.

Later the PC program will decide whether the "Lubricant_low" bit should actually trigger a fault condition:

Code: Select all

IF PLC_fault_out | Spindle_fault_out | Drive_fault_out |
  (!CNC_program_running & Lubricant_low) THEN (Halt)
Low lube is only allowed to cause a fault if no program cycle is running. In other words, if the lube tank runs low during a job, we will let that job finish and fault after it is done.

Presumably your machines have no lube float switches, or perhaps no auto lube units at all. In that case it would be reasonable to reuse INP18 as the air pressure input, and to redefine OUT63 as a low-air fault. Changing the names of INP18 and OUT63 is optional. You can edit the logic as needed (for example, to allow low air to trigger a fault immediately if it happens during a program cycle).

If you do reuse the OUT63 fault flag for something other than a lube fault, you will want to customize the message. You can do that by adding a couple lines to the file "CNC7XMSG.TXT" (on a DOS CNC7 system) or "cnc10xmsg.txt" on a Linux CNC10 system. For example:

Code: Select all

OUT63
"Air Pressure Low"
It is also possible to define and handle your own fault conditions without changing or reusing the low-lube fault, but that requires a few more steps.


Maint_1
Posts: 83
Joined: Sun Sep 19, 2010 3:24 pm
Allin1DC CNC Controller: No
CNC Control System Serial Number: A50391
DC3IOB: Yes
CNC11: Yes
CPU10 or CPU7: Yes

Re: PLC programming

Post by Maint_1 »

cncsnw thanks for the reply. I have now gone through both my PC and CP plc files and modified them accordingly. However, there does not appear to be a PLC directory or plccomp application on my machine. Also what switch is used to designate the PC plc file when compiling? I found the switch is /I for the cp in the manual.


cncsnw
Posts: 4089
Joined: Wed Mar 24, 2010 5:48 pm

Re: PLC programming

Post by cncsnw »

You have not said whether your systems have DOS and CNC7; Linux and CNC10; or are one of the handful running Windows and CNC7 or CNC10.

I will assume you are using Linux and CNC10.

In that case there is no separate PLC directory. Your PLC sources will be in the /cncroot/c/cnc10 directory, along with all the other control software files. The PLC compilers should be in the bin directory under cnc10.

The compiler for the CPU PLC program is plccomp (not PLCCOMP -- Linux is case sensitive). I don't think the /i switch is supported in the Linux version, nor is it really needed. Just enter a command like:
plccomp nameofcpuprogram.src cnc10.plc

That tells it to put the compiled output in the file cnc10.plc, where CNC10 software will use it.

The compiler for the PC PLC program is xplccomp. The output file should be pc.plc. Enter a command like:
xplccomp nameofpcprogram.src pc.plc

In both cases, if there are any syntax errors, the compiler will tell you the offending token and line.


Maint_1
Posts: 83
Joined: Sun Sep 19, 2010 3:24 pm
Allin1DC CNC Controller: No
CNC Control System Serial Number: A50391
DC3IOB: Yes
CNC11: Yes
CPU10 or CPU7: Yes

Re: PLC programming

Post by Maint_1 »

Linux and CNC10. Thanks again. I will attempt this in the morning.


Locked