pmac-nc standard header files, plcs and motion programs

70
PMAC-NC Standard Header PMAC-NC Standard Header Files, PLCs and Motion Files, PLCs and Motion Programs Programs

Upload: esmeralda-cutter

Post on 14-Dec-2015

241 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PMAC-NC Standard Header Files, PLCs and Motion Programs

PMAC-NC Standard Header Files, PMAC-NC Standard Header Files, PLCs and Motion ProgramsPLCs and Motion Programs

Page 2: PMAC-NC Standard Header Files, PLCs and Motion Programs

Introduction Introduction

PMAC-NC requires a set of files to provide the basic functionality for the machine tool. Some may be modified to fit the system specific requirements of the machine and/or supplemented with those written by the integrator. These consist of header files, PLCs and motion programs. The header files and PLCs will be the main topic of this class.

Page 3: PMAC-NC Standard Header Files, PLCs and Motion Programs

Summary of CourseSummary of Course

What are header files and how are they used in the PMAC-NC system.

What are the basic PLCs for PMAC-NC and how are they tailored for individual systems.

What additional PLCs will need to be written to augment the functionality of the provided PLCs.

Page 4: PMAC-NC Standard Header Files, PLCs and Motion Programs

Header FilesHeader Files

A header file, or include file, was developed in C to allow programmers to write better code by providing the ability to define commands with user defined macros. The CNC AutoPilot uses MACROs in the modular file structure system it creates. This helps in documentation and better control of the machine software.

Page 5: PMAC-NC Standard Header Files, PLCs and Motion Programs

Header Files (Header Files (cont.cont.))

It is strongly recommended that you only make changes to the header files where indicated.

Sections of certain header files have been set aside for the integrator to modify.

These files are closely tied to the user interface software and incorrect mod-ifications will impair PMAC-NC.

Page 6: PMAC-NC Standard Header Files, PLCs and Motion Programs

Header Files (Header Files (cont.cont.))

PMAC-NC uses header files for the assignment of DP Ram addresses between the PMAC and host. It also provides Macro definitions for many of the PMAC variables used. The header files are installed in the directory specified in the AutoPilot application.

The main header files are Address.H and OEM.H. Their directory is “pathed” so the files are accessible from any directory. These two files should never be modified.

Page 7: PMAC-NC Standard Header Files, PLCs and Motion Programs

Header FilesHeader Files

A macro definition is nothing more than a substitution name which is used in place of any valid PMAC command as in GATHER or DWELL, command phrase such as OPEN PROG 1 or M1->Y:$78C00,0,1. Or as variable reference like P1, M22, Q3042, etc..

Page 8: PMAC-NC Standard Header Files, PLCs and Motion Programs

Header FilesHeader Files

Macro definitions are declared at the beginning of the program file using the “#define” pre-processor command.

#define pressure P1

#define turn_on_Board1_Bit0 M1=1

#define collect_data GATHER

#define seconds NULL

Page 9: PMAC-NC Standard Header Files, PLCs and Motion Programs

Header Files (Header Files (cont.cont.))

The header files are used by “including” them in the project file as follows:

#include "address.h"

When you use additional header files, you will need to put them in the directory created by the CNC AutoPilot or use a full path in the “include” statement. #include “c:\MyMachine\mymacros.h"

Page 10: PMAC-NC Standard Header Files, PLCs and Motion Programs

Header Files (Header Files (cont.cont.))

It is a good practice to put all of your variable assignments and macros in one file and include that file where needed.

Example:#include "c:\cnc\mill\ MyMachine.H "

This makes debugging your code and upgrading versions of PMAC-NC easier.

Page 11: PMAC-NC Standard Header Files, PLCs and Motion Programs

The Basic PMAC-NC FilesThe Basic PMAC-NC Files

NC_I_VAR.IVR

This file stores all the I-Variables generated by AutoPilot program using the Machine Setup input.

INITIALIZE.PLC

This is a one-time execution PLC. This is used to initialize the NC system variables or I/O. Additional variables can be placed in this file.

CNTLPANEL.PLC

This is the control panel PLC for Adv 810/900. OVERRIDE.PLC

This is the percentage override control PLC used for spindle and feed rate.

Page 12: PMAC-NC Standard Header Files, PLCs and Motion Programs

The Basic PMAC-NC PLCsThe Basic PMAC-NC PLCs

HOME.PLC

This is the home PLC for all axes. HANDLE.PLC

This PLC is for the handwheel function. SPINDLE.PLC

This PLC is for spindle. It can be open or closed. Reset.PLC

This is template PLC for Reset action. User can add RESET sequence or any other Reset related action in this PLC.

Page 13: PMAC-NC Standard Header Files, PLCs and Motion Programs

The Basic PMAC-NC PLCsThe Basic PMAC-NC PLCs

GPTimer.PLC

This PLC provides additional Timers by using PMAC free memory locations.

POSITION_REPORT.PLC

This is the user position reporting PLC generated only if the User Position Reporting check box is selected.

OEM.H

This header file is created by the AutoPilot program based on user input and should not be altered. The MyMachine.H file is for general use.

Page 14: PMAC-NC Standard Header Files, PLCs and Motion Programs

The Basic PMAC-NC PLCsThe Basic PMAC-NC PLCs

NCPLC.HThe AutoPilot program generates this file based on the user input. It

consist of the macros for MILL.G, MILL.M, and MILL.T (the G, M, and T code files) used in the application.

ADVCNTLU.HThis file is in C:\Program Files\Common Files\Delta Tau Shared folder

and should not be altered. This will be useful in assigning user buttons on the Adv 810/900 control panel.

IO810.H or IO600.HThis file is an input output file. The IO810 header file is for the Adv 810

and IO600 is for an Adv 600 type controller. These files can be modified as needed and are found in C:\Program Files\Delta Tau\PmacNC\Mill.

Page 15: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

This is the control panel Initialization of variables section. It runs once being outside the infinite while loop.

OPEN PLC CONTROL_PANEL CLEAR // Set the Home Method - User Input -------HOME_MODE_P = HOME_MODE // Standard Initialization of variables -------SINGLE_BLOCK_FLAG = OFF BLOCK_DEL_FLAG = OFF OPT_STOP_FLAG = OFF

. . .

Page 16: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

. . .

S_SPND_M = SEL_SPND_OFF C_COORD_M = 0 S_COORD_M = 0 // Default Mode Inch - so RESET METRIC MODE BIT for NC. -------@SET_OFF(CS_STATUS6_M,CS_METRIC_MODE)VS_GGROUP6_1_M = 20// Actual PLC Infinite Loop -------WHILE(1>0)

Page 17: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

Usually the Isx87= TA time should at least be equal to Isx13 time. If it is found that Isx87 is less than Isx13 then this PLC will set Isx87 to the default value. The user can set the default acceleration time.

//------------------------------------------------------------// Actual PLC Infinite Loop -------WHILE(1>0) //------------------------------------------------------------IF (I5187 < I5113) I5187 = I5113 // Default Value User can change this. // I5187 = DEFAULT_ACC_TIME

ENDIF

Page 18: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

Mode selection logic

IF (PB_MDI_M = 1 AND S_MODE_M != SEL_MODE_MDI)

C_MODE_M = SEL_MODE_MDI

ELSE IF (PB_AUTO_M = 1 AND S_MODE_M != SEL_MODE_AUTO)

C_MODE_M = SEL_MODE_AUTO

ELSE IF (PB_MANUAL_M = 1 AND S_MODE_M != SEL_MODE_MANUAL)

C_MODE_M = SEL_MODE_MANUAL

ENDIF ENDIF ENDIF

Page 19: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

Switch to Auto or MDI Mode if Motion program is not running.

. . .IF (C_MODE_M > 0) IF (C_MODE_M != S_MODE_M) IF (C_MODE_M = SEL_MODE_AUTO OR C_MODE_M = SEL_MODE_MDI) IF (PROG_RUNNING_M = 0 AND IN_POSITION_M = 1) OR(FEED_HOLD_M = 1) CMD^A CMD"&1B0" S_MODE_M = C_MODE_M C_SPND_M = SEL_SPND_OFF ENDIF ENDIF. . .

Page 20: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

Switch to manual mode

. . . IF (C_MODE_M = SEL_MODE_MANUAL)

CMD^A

S_MODE_M = C_MODE_M

S_JOG_M = C_JOG_M

ENDIF

ENDIF

. . .

Page 21: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

Switch to manual mode or finally reset the Mode command . . . IF (C_MODE_M = SEL_MODE_MANUAL) CMD^A S_MODE_M = C_MODE_M S_JOG_M = C_JOG_M ENDIF ENDIF

C_MODE_M = 0ENDIF. . .

Page 22: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

Continuous JOG PLUS for selected - axis first check for allowed state.

. . .IF(PB_JOG_PLUS_M=1 OR PB_JOG_MINUS_M=1 OR @ON(CS_COMMAND3_M,CS_JOG_PLUS) OR @ON(CS_COMMAND3_M,CS_JOG_MINUS)) AND(@OFF(CS_COMMAND3_M,CS_JOG_STOP) AND S_MODE_M = SEL_MODE_MANUAL) IF (PROG_RUNNING_M=0 AND IN_POSITION_M = 1) OR(FEED_HOLD_M=1) . . .

Page 23: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

Continuous JOG PLUS for selected axis - then check for axis selected and execute jog command. JOG MINUS has similar code. . . . IF (PB_JOG_PLUS_M=1 OR @ON(CS_COMMAND3_M,CS_JOG_PLUS)) AND (S_JOG_M = SEL_JOG_CONT) IF (JOG_PLUS_FLAG = 0 AND PB_JOG_MINUS_M=0 AND HOMING_ACTIVE_FLAG=0) IF (C_AXIS_M=SEL_AXIS_X) JOG_X_PLUS @SET_ON(CS_STATUS3_M,CS_JOG_PLUS) @SET_OFF(CS_STATUS3_M,CS_JOG_STOP) ELSE IF (C_AXIS_M=SEL_AXIS_Y) JOG_Y_PLUS @SET_ON(CS_STATUS3_M,CS_JOG_PLUS) @SET_OFF(CS_STATUS3_M,CS_JOG_STOP). . .

Page 24: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

When jog is complete – clear status and reset flags . . . IF(JOG_PLUS_FLAG = 1 OR JOG_MINUS_FLAG = 1 OR @ON(CS_COMMAND3_M,CS_JOG_STOP)) JOG_STOP_ALL @SET_ON(CS_STATUS3_M,CS_JOG_STOP) @SET_OFF(CS_COMMAND3_M,CS_JOG_STOP) @SET_OFF(CS_STATUS3_M,CS_JOG_MINUS) @SET_OFF(CS_STATUS3_M,CS_JOG_PLUS) @SET_OFF(CS_COMMAND3_M,CS_JOG_MINUS) @SET_OFF(CS_COMMAND3_M,CS_JOG_PLUS) ENDIF JOG_PLUS_FLAG = 0 JOG_MINUS_FLAG = 0ENDIF. . .

Page 25: PMAC-NC Standard Header Files, PLCs and Motion Programs

Control Panel PLCControl Panel PLC

CYCLE START SECTION

. . .IF (S_MODE_M != SEL_MODE_MANUAL) IF (PB_CYCLE_START_M=1) OR (@ON(CS_COMMAND3_M,CS_CYCLE_START)) IF (CYCLE_START_FLAG=0) IF (HOME_COMPLETE_1_M = 1 AND HOME_COMPLETE_2_M = 1 AND HOME_COMPLETE_3_M = 1) IF (PROG_RUNNING_M=0 AND IN_POSITION_M = 1) OR (FEED_HOLD_M=1) @START_TIMER(TIMER_1_M,5000) IF (@TIMER_RUNNING(TIMER_1_M)) IF (@OFF(CS_STATUS3_M,CS_SINGLE_BLOCK)) CMD"&1 R" . . .

Page 26: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLCOverride PLC

Works in conjunction with the control panel PLC to set feedrate overrides based on hardware value and machine operation.

Controls Time base Mode, Slew Rate, and Time base Units.

It is highly recommended that you do not change this PLC.

Page 27: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLCOverride PLC

Time Base - PMAC’s working frequency which can be adjusted for faster or slower proportional execution.

Time Base Pointer (Isx93) - Address PMAC points to for time-base value.

Time Base Units (Isx90) - Time-base units specified in milliseconds.

Slew Rate (Isx94) - Rate of time-base changes.

Page 28: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLC (Override PLC (cont.cont.))

Calculate Time Base using Override. For Rapid and Cutting Modes set Slew to

Regular (Med) and for FPR and Thread Modes set to maximum.

For FPR, set time base units from minutes to the appropriate scaled value.

Set Time Base to Cutting, Rapid, Thread, or FPR (Exact).

Page 29: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLC (Override PLC (Calculate TBCalculate TB))

CUTTING _TIMEBASE_M = VS_FEED_OVERRIDE_M * 0.01 * I10

RAPID _TIMEBASE_M = VS_RAPID_OVERRIDE_M * 0.01 * I10

CUTTING_TIMEBASE_M M362->X:$2000,0,24,S

This address holds the C.S. 1 “%” register for override value.

RAPID_TIMEBASE_M M364->X:$10F2,0,24,S

I10 units, Open usage register

Page 30: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLC (Override PLC (Calculate TBCalculate TB))

FPR_TIMEBASE_M = SPND_TIMEBASE_M * 0.01 * VS_FEED_OVERRIDE_M

FPR_TIMEBASE_M M369->X:$0010F4,0,24,S

SPND_TIMEBASE_M M370->X:$00350A,0,24,S

This address holds the time base scale factor from the encoder conversion table for the spindle encoder

Page 31: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLC (Override PLC (Set SlewSet Slew))

Set Slew Rate depending on Time Base

Cutting and Rapid modes function best with gradual changes of velocity. I5194 = 4250.

TIME_BASE_SLEW_I = MED_SLEW

FPR and Thread need to react immediately to changes. I5194=8,388,607 (max value)

TIME_BASE_SLEW_I = MAX_SLEW

Page 32: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLC (Override PLC (Set UnitSet Unit))

For Rapid, Cutting and Thread modes set units to minutes.

CS1_TIMEBASE_UNITS_I = MINUTES_MS

For FPR mode set units to revolutions.

CS1_TIMEBASE_UNITS_I = MINUTES_MS / VS_SPINDLE_MAX_LIM_M

Page 33: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLC (Override PLC (Assign TBAssign TB))

Select appropriate time base and write to DPR.(from address.h)

S_TIMEBASE_M = SEL_TIMEBASE_CUTTING

S_TIMEBASE_M M76->Y:$6CDE4,4,4,U

SEL_TIMEBASE_CUTTING 0

SEL_TIMEBASE_RAPID 1

SEL_TIMEBASE_THREADING 2

SEL_TIMEBASE_EXACT 3

Page 34: PMAC-NC Standard Header Files, PLCs and Motion Programs

Override PLC (Override PLC (Assign TBAssign TB))

Assign register directly to I5193, based on address map of S/W Ref.

TIMEBASE_M = CUTTING_TIMEBASE

TIMEBASE_M = FPR_TIMEBASE

TIMEBASE_M M360-> X:$2001,0,20,U (I5193)

FPR_TIMEBASE $10F4

CUTTING_TIMEBASE $2000

Page 35: PMAC-NC Standard Header Files, PLCs and Motion Programs

Handwheel PLCHandwheel PLC

Controls movement based on MPG or Handwheel input.

Initializes position, jog speed, and feedrate override.

Moves axis until handwheel request has been satisfied.

Restores jog speeds and feedrate.

Page 36: PMAC-NC Standard Header Files, PLCs and Motion Programs

Handwheel PLC (Handwheel PLC (cont.cont.))

If the machine is in manual mode and handwheel is selected, this PLC initializes handle counts, target position, scaling multiplier and handwheel jog speed, then enables loop.

PREV_HANDLE_COUNT = HANDLE_COUNT_M

TARGET_POS_1_M = DESIRED_POS1_M/(I108*32)

HANDLE_FACTOR_1=PULSES_PER_UNIT_1/400

PREV_1_JOG_SPEED = I122

INIT_HANDLE = TRUE

Page 37: PMAC-NC Standard Header Files, PLCs and Motion Programs

Handwheel PLC (Handwheel PLC (cont.cont.))

// If mode is set for handwheel enter while loop. Set feed override to 100%, delay for TA for FO to take effect, set jog speed for handwheel and initialize counts.

VS_FEED_OVERRIDE_M = 100.0

@START_TIMER(TIMER_1_M,70)

WHILE (@TIMER_RUNNING(TIMER_1_M))

ENDWHILE

I122 = 100

HANDLE_CHANGE = (HANDLE_COUNT_M - PREV_HANDLE_COUNT)%-32768

PREV_HANDLE_COUNT = HANDLE_COUNT_M

Page 38: PMAC-NC Standard Header Files, PLCs and Motion Programs

Handwheel PLC (Handwheel PLC (cont.cont.))

During while loop, update target position by adding the scaled handwheel input to the current position and commanding a jog for the appropriate axis. Then, exit the while loop.

IF (S_AXIS_M = SEL_AXIS_X AND HANDLE_CHANGE != 0)

IF (PLUS_LIMIT1_M = 1 AND HANDLE_CHANGE > 0)

HANDLE_CHANGE = 0

ENDIF

IF (NEG_LIMIT1_M = 1 AND HANDLE_CHANGE < 0)

HANDLE_CHANGE = 0

ENDIF

TARGET_POS_1 = TARGET_POS_1 + VS_HAND_STEP_M*HANDLE_FACTOR_1*HANDLE_CHANGE

TARGET_POS1_M = TARGET_POS_1+ POS_BIAS1_M/(I108*32)

JOG_X_INCR //CMD”#1J=*”

ENDIF

Page 39: PMAC-NC Standard Header Files, PLCs and Motion Programs

Handwheel PLC (Handwheel PLC (cont.cont.))

On exiting while loop, reset loop enabling to false, restore previous jog speed and set commanded feedrate to 0.

IF (INIT_HANDLE = TRUE)

INIT_HANDLE = FALSE

I122 = PREV_1_JOG_SPEED

C_FEED_M = 0

ENDIF

Page 40: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLCSpindle PLC

Can be configured for either closed or open loop control, closed is default.

Initializes variables and issues commands to put spindle into a known state.

Runs in loop updating spindle information, arming triggers, and commanding spindle velocity.

Page 41: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Set the counts per revolution of the spindle, counts per revolution of the X axis, the maximum RPM (from AutoPilot entries), and the tolerance in RPM to consider the spindle at speed.

VS_SPINDLE_COUNTS_REV_M = 2000 // Spindle

VS_SPINDLE_CSS_UNITS_M = 25400 // X-Axis

VS_SPINDLE_MAX_RPM_M=6000

VS_SPINDLE_MAX_LIM_M=6000

SPINDLE_ERR_ALLOWED=35 // in RPM

Page 42: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

For open loop spindles AutoPilot points the DAC output variable to an unused register.

I402 = $10F5

For each system the integrator will need to determine the ratio of volts to RPMs for the spindle. Maximum Voltage/Maximum RPM

VOLTS_PER_RPM = 10/6000

Page 43: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Issue spindle a stop command, set commanded speed 0, set spindle feedrate override to 100% and insure spindle is in FPM mode.

VS_SPINDLE_OVERRIDE_M=100

C_SPND_M = SEL_SPND_OFF

@SET_OFF(CS_COMMAND3_M,CS_SPND_AT_SPEED)

@SET_OFF(CS_COMMAND3_M,CS_SPND_AT_ZERO)

@SET_OFF(CS_COMMAND3_M,CS_SPND_FEED)

@SET_OFF(CS_COMMAND3_M,CS_SPND_CSS)

Page 44: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Enable processing loop after initialization is complete and begin regular update routine.

SCAN = TRUE

Calculate the RPM by converting the actual velocity of motor 4 (register X:$21D, see the S/W Ref) to RPMs.

VS_SPINDLE_ACT_RPM_M = ABS (SPINDLE _MOTOR_VEL) / (I409*32) * 8388608/I10 * 60000 / VS_SPINDLE_COUNTS_REV_M

Page 45: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Set the spindle at zero bit at 5 RPMs or less.IF ( VS_SPINDLE_ACT_RPM_M < 5 )

@SET_ON(CS_STATUS3_M,CS_SPND_AT_ZERO)

ELSE

@SET_OFF(CS_STATUS3_M,CS_SPND_AT_ZERO)

If timebase is frozen then arm for threading.IF(THREAD_PROC_BITS_M = $90)

THREAD_PROC_BITS_M = $B0

Page 46: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Monitor for spindle off command, set last direction to stop and execute stop sequence.

IF(S_SPND_M = SEL_SPND_OFF )

LAST_SPND_DIR = SEL_SPND_OFF

For closed loop spindle, issue a #4j/.

JOG_STOP

Page 47: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

For open loop set DAC to 0 output plus the DAC bias, thereby reducing the effective output to 0 volts; wait for friction to slow spindle and disable spindle when moving at less than 5 RPMs.

SPINDLE_DAC_M = 0 + I429

IF ( VS_SPINDLE_ACT_RPM_M < 5 )

SPINDLE_ENA_M = 0

ENDIF

Page 48: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Only execute the rest of the PLC if movement is commanded for the spindle.

Based on spindle’s speed, set the “at speed” bit.IF( ABS(VS_SPINDLE_ACT_RPM_M - VS_SPINDLE_CMD_RPM_M) <

SPINDLE_ERR_ALLOWED )

@SET_ON(CS_STATUS3_M,CS_SPND_AT_SPEED)

ELSE

@SET_OFF(CS_STATUS3_M,CS_SPND_AT_SPEED)

Page 49: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

For CSS, calculate radius of X axis in counts and insure the value is not zero.

IF(@ON(CS_STATUS3_M,CS_SPND_CSS))

SPINDLE_CSS_RADIUS = ABS((SPINDLE_CSS_POS + POS_BIAS1_M) / (I108 * 32) - VS_X_ABS_M * VS_SPINDLE_CSS_UNITS_M) / VS_SPINDLE_CSS_UNITS_M

IF(SPINDLE_CSS_RADIUS < 0.0001)

SPINDLE_CSS_RADIUS = 0.0001

ENDIF

Page 50: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Calculate basic commanded RPM by converting VS_SPINDLE_CSS_M, the specified surface speed in FPM or MPM, from user units to counts and then dividing by the circumference.

IF(@OFF(CS_STATUS6_M,CS_METRIC_MODE))

SPINDLE_TEMP = (12.0 * VS_SPINDLE_CSS_M) / (2 * 3.14159272 * SPINDLE_CSS_RADIUS)

Page 51: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

For other modes than CSS: SPINDLE_TEMP = VS_SPINDLE_RPM_M

For CSS and non-CSS, calculate Command RPM with spindle override included.

VS_SPINDLE_CMD_RPM_M = SPINDLE_TEMP * VS_SPINDLE_OVERRIDE_M * 0.01

Saturate speed at the maximum RPM allowed. IF (VS_SPINDLE_CMD_RPM_M > S_SPINDLE_MAX_RPM_M)

VS_SPINDLE_CMD_RPM_M = VS_SPINDLE_MAX_RPM_M

Page 52: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

Calculate “Scale Factor” by dividing 2^17 by the RTIF, which is the maximum counts per revolution, insuring it is not zero, and writing it directly to the Encoder Conversion Table. RTIF = VS_SPINDLE_COUNTS_REV_M * VS_SPINDLE_MAX_LIM_M / 60000

IF(RTIF > 0)

IF(S_SPND_M = SEL_SPND_CW)

FPR_SCALE_M = 131072 / RTIF

Page 53: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

If there is a change in the commanded RPM calculate new output and set previous speed direction to current.

IF( ABS(LAST_CMD_RPM - VS_SPINDLE_CMD_RPM_M) > 1 ) OR (LAST_SPND_DIR != S_SPND_M )

LAST_SPND_DIR = SEL_SPND_CW

LAST_CMD_RPM = VS_SPINDLE_CMD_RPM_M

Page 54: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

For open loop spindles calculate value to write to DAC as the commanded RPM * the Volts to RPM ratio * the DAC bits to volts conversion, add the DAC bias and enable the spindle.

IF (S_SPND_M = SEL_SPND_CW)

SPINDLE_ENA_M = 1

SPINDLE_DAC_M = VS_SPINDLE_CMD_RPM_M * VOLTS_PER_RPM * 3276.7 + I429

Page 55: PMAC-NC Standard Header Files, PLCs and Motion Programs

Spindle PLC (Spindle PLC (cont.cont.))

For closed loop spindles calculate the motor jog velocity as the commanded RPM * the Counts per Revolution * the minute to ms conversion. and issue a jog command for motor 4.

IF (S_SPND_M = SEL_SPND_CW)

I422 = VS_SPINDLE_CMD_RPM_M / VS_SPINDLE_COUNTS_REV_M / 60000

IF (S_SPND_M = SEL_SPND_CW)

JOG_CW

Page 56: PMAC-NC Standard Header Files, PLCs and Motion Programs

Integrator PLCsIntegrator PLCs

Integrators will need to create PLCs to handle various aspects of the machine not covered in the basic 4 supplied PLCs.

Some PLCs you might consider creating are: Startup, Brake, Lube, Error, Chuck, Home, E-Stop and Shutdown.

The Turret and Coolant PLCs are covered in G, M, and T code section.

Page 57: PMAC-NC Standard Header Files, PLCs and Motion Programs

Integrator PLCs (Integrator PLCs (Cont.Cont.))

Startup - put machine into a known state and enable all PLCs.

Brake - enable brake when axis not in use. Home - perform any special functions or

sequence needed for homing routine. E-Stop - used to lock spindle, set brake, and

perform power-down actions. Shutdown - used to shut down computer.

Page 58: PMAC-NC Standard Header Files, PLCs and Motion Programs

Lube PLCLube PLC

First, recall that in the NCPanel PLC we have variables mirroring the Acc 34 boards.OUT_2_M M251->DP:$DFE9

Next, create a variable that defines the lube output on the first Acc 34 as output # 10.#define LUBE_M M909

#define LUBE_ADR Y:$DFE9,9,1

LUBE_M->LUBE_ADR

Page 59: PMAC-NC Standard Header Files, PLCs and Motion Programs

Lube PLC (Lube PLC (cont.cont.))

Now create a timer to wait 10 minutes and then enable the Lube.

@START_TIMER(TIMER_3_M,600000)

while(@TIMER_RUNNING(TIMER_3_M))

endwhile

LUBE_M=1

Page 60: PMAC-NC Standard Header Files, PLCs and Motion Programs

Lube PLC (Lube PLC (cont.cont.))

Now start the timer again in order to stop lube after 1 minute.

@START_TIMER(TIMER_3_M,60000)

while(@TIMER_RUNNING(TIMER_3_M))

endwhile

LUBE_M=0

Page 61: PMAC-NC Standard Header Files, PLCs and Motion Programs

Error PLCError PLC

Since we know the first Acc 34 board is mirrored in the NCPanel PLC, we create an M variable pointer to look at the air pump input.

IN_2_M M231->DP:$DFE1

AIR_PRESSURE_M M801

AIR_PRESSURE_ADR Y:$DFE1,1,1

AIR_PRESSURE_M->AIR_PRESSURE_ADR

Page 62: PMAC-NC Standard Header Files, PLCs and Motion Programs

Error PLC (Error PLC (Cont.Cont.))

We will define a low air pressure as error number 18, and use the built in C/S 2 error capability of PMAC-NC.

ES_ERR_MSG_M M226->DP:$DF66

#define AIR_PRESSURE_MSG 131072 // 2^17

With a compiler, we can modify the nc.dll to display a custom message. (NC Int. S/W 5-13)

Page 63: PMAC-NC Standard Header Files, PLCs and Motion Programs

Error PLC (Error PLC (cont.cont.))

Next, monitor the input to notify the operator when the air pressure is low.IF( AIR_PRESSURE_M = 0 )

@SET_ON( ES_ERR_MSG_M , AIR_PRESSURE_MSG )

ELSE

@SET_OFF( ES_ERR_MSG_M , AIR_PRESSURE_MSG )

This will display as: “0018 PLC Message Error 32”

Page 64: PMAC-NC Standard Header Files, PLCs and Motion Programs

Error PLC (Error PLC (cont.cont.))

Question: You want to set error number 21 to be a warning if your machine door is open. The input for the door is on the first Acc 34 at bit 6. Using the Windows Calc program, the Address.H file, and what you know about PLCs: create a PLC to display:

“0021 PLC Warning Message 21”

Page 65: PMAC-NC Standard Header Files, PLCs and Motion Programs

Error PLC (Error PLC (cont.cont.))

DOOR_OPEN_M M1000

DOOR_OPEN_ADR Y:$DFE1,5,1

DOOR_OPEN_M->DOOR_OPEN_ADR

DOOR_OPEN_MSG 1048576

IF( DOOR_OPEN_M = 0 )

@SET_ON(ES_ERR_WARN_M , DOOR_OPEN_MSG )

ELSE

@SET_OFF( ES_ERR_WARN_M , DOOR_OPEN_MSG)

ENDIF

Page 66: PMAC-NC Standard Header Files, PLCs and Motion Programs

QuizQuiz

Using the PMAC S/W Reference’s Map of the Gate Array in chapter 8, and what you have learned so far, create a PLC that monitors for amplifier faults, waits 1 second, rechecks the fault, then turns on an output LED off the second Acc 34, output bit 31. The machine is a turning center, so you will only need to worry about axes 1,3, and 4.

Page 67: PMAC-NC Standard Header Files, PLCs and Motion Programs

Quiz (Quiz (AnswerAnswer))

AMP1_FAULT_M M1001

AMP3_FAULT_M M1003

AMP4_FAULT_M M1004

AMP1_FAULT_ADR X:$C000,23,1

AMP3_FAULT_ADR X:$C008,23,1

AMP4_FAULT_ADR X:$C00C,23,1

AMP1_FAULT_M->AMP1_FAULT_ADR

AMP3_FAULT_M->AMP3_FAULT_ADR

AMP4_FAULT_M->AMP4_FAULT_ADR

Page 68: PMAC-NC Standard Header Files, PLCs and Motion Programs

Quiz (Quiz (AnswerAnswer))

#define AMP_FAULT_LED_M M1005

#define AMP_FAULT_LED_ADR X:$DFEA,14,1

AMP_FAULT_LED_M->AMP_FAULT_LED_ADR

AMP_FAULT_FLAG P1000

OPEN PLC15 CLEAR

IF(AMP1_FAULT_M+AMP3_FAULT_M+AMP4_FAULT_M>0)

@START_TIMER(TIMER_3_M,1000)

while(@TIMER_RUNNING(TIMER_3_M))

endwhile

Page 69: PMAC-NC Standard Header Files, PLCs and Motion Programs

Quiz (Quiz (AnswerAnswer))

AMP_FAULT_FLAG=1

ENDIF

IF(AMP_FAULT_FLAG=1) IF(AMP1_FAULT_M + AMP3_FAULT_M + AMP4_FAULT_M >

0)

AMP_FAULT_LED_M=1

ELSE

AMP_FAULT_FLAG=0

ENDIF

ENDIF

CLOSE

Page 70: PMAC-NC Standard Header Files, PLCs and Motion Programs

SummarySummary

PMAC’s software based PLCs can take the place of hardware PLCs.

The PMAC PLCs interact easily with host programs through DP RAM

By modifying and writing PLCs, the integrator can easily tailor the machine to operate for a specific customer’s needs.