*-----------------------------------------------------------------------------
*  PLC Basic Program for iTNC 530
*-----------------------------------------------------------------------------
*  Contents
*
*
*-----------------------------------------------------------------------------
*  Version / last issue
*
*  56 / 2011-03-01
*
*-----------------------------------------------------------------------------

*-----------------------------------------------------------------------------
*  Pragma instruction
*-----------------------------------------------------------------------------

#pragma symsort
#pragma nsc
#pragma dl 0
#pragma struct
#pragma range

*$WS
*#pragma genvariantdefines
*#pragma srcpath c:\PLC\OemPGM\Standard
*#pragma nsw

*-----------------------------------------------------------------------------
*  Definition of Compiler Assignable Memory
*-----------------------------------------------------------------------------

*M1000...M1089 used for M-functions

#define /mn   7000 9999                *Marker volatile     max. 1000 - 9999
#define /mr   200  999                 *Marker non volatile max.    0 -  999 (1)

#define /bn   7000 14999               *Byte volatile       max. 2048 - 9999
#define /br   4    127                 *Byte non volatile   max.    0 -  127 (1)

* Legend:
*   (1) - can be modified in oem.cfg

*-----------------------------------------------------------------------------
*  Definition of Global Symbols
*-----------------------------------------------------------------------------

#define /g    System.Def
#define /g    ASCIICod.def
#define /g    GLB_NC.Def
#define /g    Intern.Def
#define /g    GLB_TCMB.Def

*#if CFG_HSCI  = "active"
*#define /g    GLB_IO_CONFIG.def
*#define /g    GLB_IO_CONFIG.lib
*#else
#if CFG_machine_typ = "TAKUMI"
#define /g    GLB_IO_T.Def
#else
#if CFG_machine_typ = "FOCAS"
#define /g    GLB_IO_F.Def
#else
#define /g    GLB_IO.Def
#endif
#endif
*#define /g    Profibus.Def
*#endif

#define /g    ..\Softkeys\Softkeys.def

*-----------------------------------------------------------------------------
*  Definition PLC-Program-Modules
*-----------------------------------------------------------------------------

#if CFG_HSCI = "inactive"
USES InOutput.src
EXTERN Input_read
EXTERN Output_write
#endif

USES Initial.src
EXTERN Init_after_Reset

USES MP_file.src
EXTERN MP_part_file

USES MP_read.src
EXTERN MP_read

USES MP_Data_Tab_read.src
EXTERN MP_table_edit

USES FUNC_keys.src
EXTERN Function_softkeys

USES OEM_func.src
EXTERN OEM_function_begin
EXTERN OEM_function_end

USES HRxx_Man.src
EXTERN Manual_handwheel

USES Common.src
EXTERN Common_function
EXTERN Begin_PLC_cycle
EXTERN End_PLC_Cycle

USES Diagnos.src
EXTERN Diagnostic

#if CFG_Hydraulic_system = "active"
USES Hydrauli.src
EXTERN Hydraulic
#endif

USES FN19.src
EXTERN FN19

USES M_funct.src
EXTERN M_functions

USES M_user_f.src
EXTERN User_M_functions

USES Axes_Compensation.src
EXTERN Axes_compensation

#if CFG_Temperature_Compensation = "MP_factor"
USES Temp_Cp1.src
EXTERN Temperature_comp
#endif

#if CFG_Temperature_Compensation = "Table"
USES Temp_Cp2.src
EXTERN Temperature_comp
#endif

#if CFG_Temperature_Compensation = "S_shaft"
USES TEMP_S_shaft.SRC
EXTERN Temperature_comp
#endif

USES PLC_Pset.src
EXTERN PLC_Preset

USES Axislimi.src
EXTERN Axis_limit

USES Guard.src
EXTERN Guard

USES StartStp.src
EXTERN NC_start_stop

USES Reference.src
EXTERN Reference_axes

USES Hirth.src
EXTERN Hirth

#if CFG_3D_head = "active"
USES 3D_head.src
EXTERN Head_3D
#endif

*#if 3D_head_exchange = &active
USES 3D_head_exchange.src
EXTERN Head_3D_exchange
*#endif

#if CFG_axesNT_brake_control_via_CC_UM = "active"
USES Axes_NT.src
#else
USES Axes.src
#endif
EXTERN Axes

USES IndexTab.src
EXTERN Index_table

USES Lubricat.src
EXTERN Lubrication

USES Gear.src
EXTERN Spindle_gear

USES Gear_YD.src
EXTERN Spindle_YD_gear

USES Spin_Ref.src
EXTERN Spindle_reference

USES Spindle.src
EXTERN Spindle

#if CFG_Spindle_lube = "active"
USES S_lube.src
EXTERN S_lube
#endif

USES TouchPro.src
EXTERN Touch_probe

#if CFG_TL_Blum_Laser = "active"
USES TL_Blum_laser.src
EXTERN TL_Blum_laser
#endif

USES S_Orient.src
EXTERN Spindle_Orient

USES Air.src
EXTERN Air

USES Coolant.src
EXTERN Coolant

USES Chipconv.src
EXTERN Chip_conveyor

#if Tool_changing_arm = &Single_arm
USES TC_Help1.src
EXTERN TC_Help
EXTERN Output_Backup
EXTERN Output_Restore

USES TC_Auto1.src
EXTERN TC_auto
#endif

#if Tool_changing_arm = &Pickup
USES TC_Help4.src
EXTERN TC_Help
EXTERN Output_Backup
EXTERN Output_Restore

USES TC_Auto4.src
EXTERN TC_auto
#endif

#if Tool_changing_arm = &Double_arm
USES TC_Help2.src
EXTERN TC_Help
EXTERN Output_Backup
EXTERN Output_Restore

USES TC_Auto2.src
EXTERN TC_auto
#endif

#if Tool_changing_arm = &Cam_driven_arm
USES TC_Help3.src
EXTERN TC_Help
EXTERN Output_Backup
EXTERN Output_Restore

USES TC_Auto3.src
USES TC_Arm.src
EXTERN TC_auto
#endif

#if Tool_magazine = &PLC_axis
USES TC_Mag1.src
EXTERN Tool_magazine

USES TC_Load.src
EXTERN TC_mag_loading
#endif

#if Tool_magazine = &Pulse
USES TC_Mag2.src
EXTERN Tool_magazine

USES TC_Load.src
EXTERN TC_mag_loading
#endif

USES TC_manu.src
EXTERN TC_manual

USES T_Status.src
EXTERN Tool_status

#if CFG_pallet_changer = "Alternat_table"
USES Alt_Tab.src
EXTERN Alternat_table
#endif

#if CFG_pallet_changer = "PC_2_linear"
USES PC_2_linear.src
EXTERN Pal_changer

USES PC_help.src
EXTERN PC_help
EXTERN PC_output_backup
EXTERN PC_output_restore
#endif

#if CFG_pallet_changer = "PC_2_turn"   ;20120704
USES PC_2_turn.src
EXTERN Pal_changer

USES PC_help.src
EXTERN PC_help
EXTERN PC_output_backup
EXTERN PC_output_restore
#endif

#if CFG_pallet_changer = "System_3R"
USES PC_3R.src
EXTERN Pal_changer
#endif

USES Feed.src
EXTERN Feed_release

#if CFG_free_rotation = "active"
USES Turning.src
EXTERN Turning
#endif

#if CFG_Working_area_monitoring = "active"
USES Workarea.src
EXTERN Work_area_monitor
#endif

#if CFG_Warm_up = "active"
USES Warm_up.src
EXTERN Warm_up
#endif

;USES TKM_option_1.src
;EXTERN TKM_option_1

USES Window.src
EXTERN PLC_Window

#if CFG_Error_messages_additional = "active"
USES Error.src
EXTERN Error
#endif

*#if LSV2_ActiveX_Control = &active
*USES LSV2OCX0.src
*EXTERN LSV2_OCX_Modul_0
*#endif

#if CFG_mode_RSxxx ! "inactive"
USES Data_transfer_RSxxx.src
EXTERN Data_transfer_RSxxx
#endif

#if CFG_IPC_61x0 = "active"
USES IPC_61x0.src
EXTERN IPC_61x0
#endif

USES Logbook.src
EXTERN Logbook

#if CFG_Python = "active"
USES Python.src
EXTERN Python
#endif

#if CFG_energy_option = "active"
USES PY_energy_option.src
EXTERN Energy_Option
#endif

#if CFG_PLC_PY_server ! "inactive"
USES PY_TCP_IP_Server.src
EXTERN TCP_IP_Server
#endif

#if CFG_PLC_PY_client_1  ! "inactive"
USES PY_TCP_IP_Client_1.src
EXTERN TCP_IP_Client
#endif

USES Simulation.src
EXTERN Simulation_begin
EXTERN Simulation_end

*-----------------------------------------------------------------------------
*  Mainprogram
*-----------------------------------------------------------------------------

  CM     Begin_PLC_cycle
#if CFG_HSCI = "inactive"
  CM     Input_read
#endif

#if Tool_changing_arm ! &inactive
  CM     Output_Restore
#endif

  CM     OEM_function_begin
  CM     Function_softkeys

#if CFG_pallet_changer = "PC_2_linear"
  CM     PC_output_restore
#endif

#if CFG_pallet_changer = "PC_2_turn"   ;20120704
  CM     PC_output_restore
#endif

;  CM     TKM_Option_1

  LN     MG_TNC_initialized
  CMT    Init_after_Reset

  L      NP_M4174_1st_PLC_run_after_MP_edit
  R      MG_machine_parameter_are_read

  LN     MG_machine_parameter_are_read
  CMT    MP_read

  CM     Simulation_begin
  CM     MP_part_file

#if CFG_energy_option = "active"
  CM     Energy_Option
#endif

#if CFG_PLC_PY_server = "active"
  CM     TCP_IP_Server
#endif

#if CFG_PLC_PY_client_1 = "active"
  CM     TCP_IP_Client
#endif

#if Tool_changing_arm ! &inactive
  CM     Output_Restore
#endif

#if CFG_Python = "active"
  CM     Python
#endif

  CM     Manual_handwheel
  CM     Common_function
  CM     MP_table_edit
#if CFG_Hydraulic_system = "active"
  CM     Hydraulic
#endif
  CM     Diagnostic
  CM     FN19
  CM     M_functions
  CM     User_M_functions
#if CFG_IPC_61x0 = "active"
  CM     IPC_61x0
#endif
  CM     Axes_compensation

#if (CFG_Temperature_Compensation = "MP_factor") or (CFG_Temperature_Compensation = "Table")
  CM     Temperature_comp
#endif
  CM     PLC_Preset

  CM     Axis_limit
  CM     Guard
  CM     NC_start_stop
  CM     Reference_axes

  CM     Lubrication

  L      MG_spindle_wye_delta_switchover
  CMT    Spindle_YD_gear
  CMF    Spindle_gear
  CM     Spindle_reference
  CM     Spindle
#if CFG_Spindle_lube = "active"
  CM     S_lube
#endif
  CM     Touch_probe
#if CFG_TL_Blum_Laser = "active"
  CM     TL_Blum_laser
#endif

  CM     Spindle_Orient

#if CFG_3D_head = "active"
  CM     Head_3D
#endif

*#if 3D_head_exchange = &active
  CM     Head_3D_exchange
*#endif

  CM     Hirth
  CM     Axes

  CM     Index_table
  CM     Air
  CM     Coolant
  CM     Chip_conveyor
  CM     TC_manual

#if Tool_changing_arm ! &inactive
  CM     TC_Help
  CM     TC_auto
#endif

#if Tool_magazine ! &inactive
  CM     Tool_magazine
  CM     TC_mag_loading
#endif

  CM     Tool_status

#if CFG_pallet_changer = "Alternat_table"
  CM     Alternat_table
#endif

#if CFG_pallet_changer = "PC_2_linear"
  CM     PC_help
  CM     Pal_changer
#endif

#if CFG_pallet_changer = "PC_2_turn"   ;20120704
  CM     PC_help
  CM     Pal_changer
#endif

#if CFG_pallet_changer = "System_3R"
  CM     Pal_changer
#endif

  CM     Feed_release

#if CFG_free_rotation = "active"
  CM     Turning
#endif

#if CFG_Working_area_monitoring = "active"
  CM     Work_area_monitor
#endif

#if CFG_Warm_up = "active"
  CM     Warm_up
#endif

  CM     PLC_Window

#if CFG_Error_messages_additional = "active"
  CM     Error
#endif

*#if LSV2_ActiveX_Control = &active
*  CM     LSV2_OCX_Modul_0
*#endif

#if CFG_mode_RSxxx ! "inactive"
  CM     Data_transfer_RSxxx
#endif

  CM     Logbook
  CM     Simulation_end

#if CFG_pallet_changer = "PC_2_linear"
  CM     PC_output_backup
#endif

#if CFG_pallet_changer = "PC_2_turn"   ;20120704
  CM     PC_output_backup
#endif

#if Tool_changing_arm ! &inactive
  CM     Output_Backup
#endif

  CM     OEM_function_end
#if CFG_HSCI = "inactive"
  CM     Output_write
#endif
  CM     End_PLC_Cycle

EM
