*-----------------------------------------------------------------------------
*  Hirth Verzahnung X,Y,Z,4,5,6,7,8,9
*-----------------------------------------------------------------------------
*  Modul-Beschreibung
*
*-----------------------------------------------------------------------------

#define /s    KL_absolut_mit_Soft_End_ohne_DCM         K %1010
#define /s    KL_inaktiv                               K +0

#define /s    ML_PLC_Pos_noetig                        M[32]
#define /s    ML_Pos_plus_aktiv                        M[32]
#define /s    ML_Pos_minus_aktiv                       M[32]
#define /s    ML_PLC_Posit_Hilfs_Achse_aktiv           M[32]
#define /s    ML_Fehler_Hirth_Position                 M
#define /s    ML_Stack_synchronisieren                 M
#define /s    BL_Fehlercode                            B

#include Mac_Lib.inc

EXTERN Absolut
EXTERN Start_Posit
EXTERN Start_Posit_Parameter

GLOBAL Hirth

;----------------------------
LBL Hirth
;----------------------------

  L      K+0
  =X

  L      MG_Eins_Merker
  R      PN_Fehler_Hirth_Position

  REPEAT
    L      DG_Hirth_Achsen
    AN     NP_D1116_Referenz_notwendig
    BTX
    A      MG_Maschinenparameter_gelesen
    CMT    Hirth_Achsen

    INCX

    LX
    >=     KG_max_Achs_Anzahl
  UNTILT

  LD     ML_PLC_Pos_noetig
  =      DG_PLC_Posit_Hirth_noetig

EM

;----------------------------
LBL Hirth_Achsen

  CM     Hirth_Position

  L      DG_WZM_Achsen
  BTX
  A[
    L      MG_WZW_Service
    O      MG_WZW_Help
    O      MG_WZM_Beladen_aktiv
  ]
  EMT

  L      PN_D1144_Manuelles_Verfahren_plus
  A      NP_D1104_Achsen_in_Position
  BTX
  S      ML_Pos_plus_aktiv[X]

  L      PN_D1148_Manuelles_Verfahren_minus
  A      NP_D1104_Achsen_in_Position
  BTX
  S      ML_Pos_minus_aktiv[X]

  LN     NP_D1104_Achsen_in_Position
  AN     NP_D1116_Referenz_notwendig
  AN     DG_PLC_Hilfs_Achsen
  BTX
  A      MG_BA_Manuell
  AN     NP_M4156_BA_Softkey_Manual_Operation
  AN     MG_PLC_Posit_aktiv[X]
  A[
    LN     NP_M4155_BA_Referenzaufnahme
    O      MG_Referenz_auto_NC_Start_gesperrt
  ]
  A[
    L      WG_Nummer_aktives_NC_Macro
    <=     KL_inaktiv
  ]
  S      ML_PLC_Pos_noetig[X]

  LN     NP_D1104_Achsen_in_Position
  AN     NP_D1116_Referenz_notwendig
  A      DG_PLC_Hilfs_Achsen
  BTX
  AN     ML_PLC_Posit_Hilfs_Achse_aktiv[X]
  A[
    L      WG_Nummer_aktives_NC_Macro
    <=     KL_inaktiv
  ]
  S      ML_PLC_Pos_noetig[X]

  L      NP_D1104_Achsen_in_Position
  BTX
  A      ML_PLC_Pos_noetig[X]
*$WS
;  AN     NP_M4176_Stern_ein_oder_blinkt
  CMT    Posit_auf_Raster

  L      NP_D1104_Achsen_in_Position
  A      DG_PLC_Hilfs_Achsen
  BTX
  R      ML_PLC_Posit_Hilfs_Achse_aktiv[X]

EM

;----------------------------
LBL Hirth_Position

  L      DG_Ref_Pos_Achse[X]
  MOD    DG_MP430_Hirth_Raster[X]
  PSW
  CM     Absolut
  PLW

  PSW
  >[
    L      DG_MP430_Hirth_Raster[X]
    /      K+2
  ]
  IFT
    PLW
    -      DG_MP430_Hirth_Raster[X]
    X      K-1
    PSW
  ENDI

  PLW
  <      DG_MP1030_Pos_Fenster[X]
  A[
    LN     NP_D1116_Referenz_notwendig
    BTX
  ]
  =      MG_Achse_in_Hirth_Posit[X]

  L      NP_D1104_Achsen_in_Position
  AN     DG_Tasten_sperren
  BTX
  AN     MG_Start_Sperre_Referenz
  AN     MG_PLC_Posit_aktiv[X]
  AN     ML_PLC_Pos_noetig[X]
  AN     MG_Achse_in_Hirth_Posit[X]
  AN     MG_3D_Kopf_aktiv
  AN     MG_3D_Kopf_Anzeige
  AN     MG_3D_Kopf_Eingabe
  AN     NP_M4156_BA_Softkey_Manual_Operation
  AN     NP_M4157_BA_Restore_Position_aktiv
  =      ML_Fehler_Hirth_Position

  L      DG_Regelkreis_oeffnen_Aktivierung
  BTX
  A      ML_Fehler_Hirth_Position
  S      PN_Fehler_Hirth_Position

  M_Fehler_Hirth_Position

  LN     NP_D1104_Achsen_in_Position
  BCX
  >      K +0
  A      ML_Fehler_Hirth_Position
  A      MG_BA_Automatik
  S      PN_Fehler_Hirth_Soll_Position

  M_Fehler_Hirth_Soll_Position

EM

;----------------------------
LBL Posit_auf_Raster

  PSX

  L      ML_Pos_minus_aktiv[X]
  O      ML_Pos_plus_aktiv[X]
  A[
    LN     PN_D1144_Manuelles_Verfahren_plus
    AN     PN_D1148_Manuelles_Verfahren_minus
    BTX
  ]
  CMT    gleiche_Richtung
  CMF    kuerzester_Weg

  L      MG_DCM_aktiv
  AN     MG_Referenz_Achsen_aufgenommen
  IFT
    PS     DG_Vorschub_PLC_Pos[X]
    PS     KL_absolut_mit_Soft_End_ohne_DCM
    CM     Start_Posit_Parameter
    PL     ML_Stack_synchronisieren
  ELSE
    CM     Start_Posit
    PL     ML_Stack_synchronisieren
  ENDI

  L      DG_PLC_Hilfs_Achsen
  BTX
  S      ML_PLC_Posit_Hilfs_Achse_aktiv[X]

  L      MG_Eins_Merker
  R      ML_Pos_minus_aktiv[X]
  R      ML_Pos_plus_aktiv[X]
  R      ML_PLC_Pos_noetig[X]

EM

;----------------------------
LBL gleiche_Richtung

  L      DG_Ref_Pos_Achse[X]
  /      DG_MP430_Hirth_Raster[X]
  X      DG_MP430_Hirth_Raster[X]
  PSW                                  ;Raster links

  L      DG_Ref_Pos_Achse[X]
  <      K+0
  IFT
    PLW
    -      DG_MP430_Hirth_Raster[X]
    PSW                                ;Raster links
  ENDI

  L      ML_Pos_plus_aktiv[X]
  IFT
    PLW
    +      DG_MP430_Hirth_Raster[X]
    PSW                                ;Raster rechts
  ENDI

EM

;----------------------------
LBL kuerzester_Weg

  L      DG_MP430_Hirth_Raster[X]
  /      K+2
  +      DG_Ref_Pos_Achse[X]
  /      DG_MP430_Hirth_Raster[X]
  X      DG_MP430_Hirth_Raster[X]
  PSW                                  ;Raster links

  L      DG_MP430_Hirth_Raster[X]
  /      K+2
  +      DG_Ref_Pos_Achse[X]
  <      K+0
  IFT
    PLW
    -      DG_MP430_Hirth_Raster[X]
    PSW                                ;Raster links
  ENDI

EM
