# 1 "/ssnmrpulprogs/hCANH.mpibpc"
; 3D (H)CANH developed at CRMN in the group of G. Pintacuda and modified at the MPIBPC

; Recent notes:
; this version does not require 13C axis inversion

;Avance III version
;parameters: 
;p1 : 1H 90 pulse duration
;p3 : 13C 90 pulse duration
;p7 : 15N 90 pulse duration
;p30 : water suppression time (30-200 ms)
;cnst21 : CO offset in ppm (173.7)
;cnst22 : CA offset in ppm (53.7)
;cnst23 : CO/CO offset in ppm (113.7)
;d1 : recycle delay
;d0     : 15N initial evolution time
;d10    : 1/2 of 13CO initial evolution time
;in0    : increment for 15N evolution
;in10   : 1/2 increment for 13CA evolution
;cpdprg1 : tppm (at pl13) or waltz (at pl13)
;cpdprg4 : cwY (at pl12)
;cpdprg5 : cwX (at pl12)
;pcpd1   : pulse length in decoupling sequence (2xtau_r for tppm, 25us for 10kHz waltz)
;pl1    : power level of 1H hard pulse
;pl12   : power level of decoupling (10-15 kHz)
;pl13   : power level for water suppression
;spnam1  : 1H shape for 1H->13CA CP (ramp 10-20%)
;spoal1  : N/A
;spoff1 : [ON/RES]
;sp1    : 1H power level during 1H->13CA CP
;spnam10 : 1H shape for 15N->1H(N) CP (ramp 10-20%)
;spoal10  : N/A
;spoff10 : [ON/RES]
;sp10    : 1H power level during 15N->1H CP
;cpdprg2 : 15N decoupling pattern during acq (waltz-16)
;p17     : contact time 15N->1H(N) CP (300-500 us)
;pcpd2   : pulse length in 15N decoupling sequence (25 us)
;pl7    : power level for 15N hard pulse
;pl16   : power level for 15N decoupling (corr. to 10 kHz)
;pl2    : power level for 15N hard pulse
;pl20   : 15N power level for 15N->1H CP
;spnam2  : 15N shape for 13CA->15N CP (tan-c100-w10pct)
;sp2    : 15N power level for 13CA->15N CP
;spoal2  : N/A
;spoff2 : [ON/RES]
;p15     : contact time 1H->13CA CP (5 ms)
;p16     : contact time 13CA->15N CP (10 ms)
;p18     : Q3 CO pulse duration
;p19     : Q3 CA pulse duration
;pcpd3   : pulse length in 13C decoupling sequence (25 us)
;cpdprg3 : 13CO/CA decoupling pattern during 15N evol (waltz-16)
;pl3    : power level of 13C hard pulse [REFERENCE]
;pl17   : power level for 13CO/CA decoupling (10 kHz)
;spnam9  : 13C shape for 13CA->15N CP (rectangle)
;sp9     : 13C power for 13CA->15N CP
;spoal9  : N/A
;spoff9 : [ON/RES CO]
;spnam18 : 13CO selective pulse shape (Q3)
;spoal18  : N/A
;spoff18 : [ON/RES CO]
;spnam19 : 13CA selective pulse shape (Q3)
;spoal19  : N/A
;spoff19 : [ON/RES CA]
;spnam29 : 13C shape for 1H->13CO CP (rectangle)
;sp29   : 13C power level for 1H->13CO CP
;spoal29  : N/A
;spoff29 : [ON/RES CO]
;zgoptns : -Dfslg, -Dlacq, or blank
# 70 "/ssnmrpulprogs/hCANH.mpibpc"
;$COMMENT=Inverse Cp with INEPT CBCA mixing
;$CLASS=Solids
;$DIM=3D
;$TYPE=H detect
;$SUBTYPE=Heteronuclear
;$OWNER=CRMN

# 1 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl" 1
;Avancesolids.incl
;   for TCU3
;
;version 1 28.2.2001, written by HF
;	   4.4.2006, complemented by Ste

;$CLASS=Solids INCL
;$COMMENT=definitions for setrtp and setnmr
# 10 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;switch between 1H or 19F output (H amplifier) 


# 14 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;gating pulse for RX, ADC and HPPR auto mode


# 18 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;explicit blanking of preamp, receiver, adc, not implemented yet


# 26 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;generate dwell clock


;turn dwell clock on/off
# 32 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;


# 36 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;define data sampling for WAHUHA type experiments, samples analogue or digitally for d9, closes receiver


# 40 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/Avancesolids.incl"
;explicit transmitter blanking, not supported yet

;NCO switching, to be implemented

;$id: $
# 77 "/ssnmrpulprogs/hCANH.mpibpc" 2
# 79 "/ssnmrpulprogs/hCANH.mpibpc"
; Start evolutions from exactly 0
"d0=0.0"
"d10=0.0"

; 1H settings
"spoal1=0.5"   ; default value (irrelevant)
"spoff1=0.0"    ; on-resonance
"spoal10=0.5"  ; default value (irrelevant)
"spoff10=0.0"   ; on-resonance

; 15N settings
"pcpd2=25"                        ;does not work!
"plw2=plw7"
"plw16=plw2*(pow(p7/25,2))"     ; 15N waltz 10kHz decoupling power level
"spoal2=0.5"   ; default value (irrelevant)
"spoff2=0.0"     ; on-resonance
# 96 "/ssnmrpulprogs/hCANH.mpibpc"
; 13C settings
"plw17=plw3*(pow(p3/25,2))"     ; 13C waltz 10kHz decoupling power level

"cnst22 = (sfo3-bf3)*1000000/bf3"  ; CA frequency offset (ppm)
"cnst21 = cnst22+(173.7-53.7)"     ; CO frequency offset (ppm)
"cnst23 = cnst22+(113.7-53.7)"    ; the offset half-way CO and CA (ppm)

"p18=3.412/(95.0*bf3/1000000)"    ; 95 ppm bandwidth (safe)
"spw18=plw3*pow((0.5/(p18*0.1515))/(0.25/p3),2)" ;  Q3 power level
"spoal18=0.5"                      ; default value (irrelevant)
"spoff18=bf3*((cnst21-cnst22)/1000000)"
# 108 "/ssnmrpulprogs/hCANH.mpibpc"
"p19=3.412/(105.0*bf3/1000000)"      ; 95 ppm bandwidth (safe)
"spw19=plw3*pow((0.5/(p19*0.1515))/(0.25/p3),2)" ;  Q3 power level
"spoal19=0.5"                            ; default value (irrelevant)
"spoff19=0.0"                       ; CA frequency

"spoal9=0.0"                        ; needed for offset on C
"spoff9=0.0"                        ; on-resonance

"spoal29=1.0"                       ; needed for offset on C
"spoff29=0.0"                       ; on-resonance CA
# 119 "/ssnmrpulprogs/hCANH.mpibpc"
;"acqt0=1u*cnst11" ??
"in0=inf1"
"in10=inf2/2"
aqseq 312

# 1 "mc_line 124 file /ssnmrpulprogs/hCANH.mpibpc exp. def. part of mc cmd. before ze"
; dimension 3D; AQ_mode  (F2) States-TPPI (F1) States-TPPI
define delay MCWRK
define delay MCREST
define delay d0orig
"d0orig=d0"
define delay d10orig
"d10orig=d10"
define loopcounter t2loop
"t2loop=0"
define loopcounter t1loop
"t1loop=0"
define loopcounter ph1loop
"ph1loop=0"
define loopcounter ph2loop
"ph2loop=0"
define loopcounter ST1CNT
"ST1CNT = td2 / 2"
define loopcounter ST2CNT
"ST2CNT = td1 / 2"
"MCREST = d1 - 10m"
"MCWRK = 0.071429*10m"

    dccorr
# 124 "/ssnmrpulprogs/hCANH.mpibpc"
1 ze
# 1 "mc_line 124 file /ssnmrpulprogs/hCANH.mpibpc exp. def. of mc cmd. after ze"
LBLAV, MCWRK
      "d0=d0orig + t1loop * in0 "
      "phval2 = (ph1loop % 4) * 90"
      MCWRK ip2 + phval2
      "d10=d10orig + t2loop * in10 "
      "phval15 = (ph2loop % 4) * -90"
      MCWRK ip15 + phval15
# 125 "/ssnmrpulprogs/hCANH.mpibpc"

# 1 "mc_line 126 file /ssnmrpulprogs/hCANH.mpibpc exp. start label for mc cmd."
2 MCWRK  * 3 do:f2
LBLF2, MCWRK  * 3
LBLST2, MCWRK  * 4
LBLF1, MCWRK  * 3
LBLST1, MCWRK 
  MCREST
# 127 "/ssnmrpulprogs/hCANH.mpibpc"
# 1 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/p15_prot.incl" 1
;p15_prot.incl
;avance-version (13/01/29)
;Test the rf on-time and duty cycle
;protect against too long contact time
;Test the rf on-time and duty cycle 
;
;$CLASS=Solids INCL
;$COMMENT=protect against too long contact time
# 11 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/p15_prot.incl"
1m
if "p15 < 12.1m" goto Passp15
2u
print "contact time exceeds 10msec limit!"
goto HaltAcqu
Passp15, 1m


# 20 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/p15_prot.incl"
;$Id: p15_prot.incl,v 1.8 2013/01/29 15:40:14 ber Exp $
# 127 "/ssnmrpulprogs/hCANH.mpibpc" 2

# 1 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/aq_prot.incl" 1
;aq_prot.incl
;avance-version (13/01/28)
;Test the rf on-time and duty cycle
;protect against too long acquisition time

;$CLASS=Solids INCL
;$COMMENT=protect against too long acquisition time
# 9 "/opt/topspin3.5pl6/exp/stan/nmr/lists/pp/aq_prot.incl"
1m
if "aq < 50.1m" goto Passaq
2u 
print "acquisition time exceeds 50m limit!"
goto HaltAcqu
Passaq, 1m

;$Id: aq_prot.incl,v 1.8 2013/01/28 17:39:02 ber Exp $
# 128 "/ssnmrpulprogs/hCANH.mpibpc" 2

# 130 "/ssnmrpulprogs/hCANH.mpibpc"
  ;1u fq=0:f3
  1u fq=cnst22(bf ppm):f3
  (p1 pl1 ph3):f1 

  (p15:sp29 ph15):f3 (p15:sp1 ph20):f1
  1u cpds1:f1 
  (p18:sp18 ph18):f3  ;CO selective Pi
  1u
  (p19:sp19 ph19):f3   ;CA selective Pi
  1u 
  d10
  (center (p7*2 ph0 pl7):f2 (p18:sp18 ph18):f3)  ;CO selective Pi
  d10
  1u do:f1

  (p16:sp9 ph10):f3 (p16:sp2 ph2):f2
# 147 "/ssnmrpulprogs/hCANH.mpibpc"
  1u fq=cnst23(bf ppm):f3
  1u cpds1:f1 cpds3:f3
  d0
  1u do:f1 do:f3
  (p7 pl7 ph5):f2 
 ;water suppression
  (p30*0.25 pl13 ph0):f1
  (p30*0.25 pl13 ph1):f1
  (p30*0.25 pl13 ph0):f1
  (p30*0.25 pl13 ph1):f1

;water suppression
  (p7 pl7 ph6):f2
  (p17 pl20 ph7):f2 (p17:sp10 ph11):f1

  1u cpds2:f2
  go=2 ph31  
  1m do:f2

# 1 "mc_line 165 file /ssnmrpulprogs/hCANH.mpibpc exp. mc cmd. in line"
  MCWRK  wr #0 if #0 zd 

  "ph1loop+=1"
      "d0=d0orig + t1loop * in0 "
      "phval2 = (ph1loop % 4) * 90"
      MCWRK ip2 + phval2
      "d10=d10orig + t2loop * in10 "
      "phval15 = (ph2loop % 4) * -90"
      MCWRK ip15 + phval15
  lo to LBLF2 times 2
  MCWRK 

  "t1loop+=1"
      "d0=d0orig + t1loop * in0 "
      "phval2 = (ph1loop % 4) * 90"
      MCWRK ip2 + phval2
      "d10=d10orig + t2loop * in10 "
      "phval15 = (ph2loop % 4) * -90"
      MCWRK ip15 + phval15
  lo to LBLST2 times ST2CNT
  MCWRK 
  "t1loop=0"
  "ph1loop=0"
  MCWRK 

  "ph2loop+=1"
      "d0=d0orig + t1loop * in0 "
      "phval2 = (ph1loop % 4) * 90"
      MCWRK ip2 + phval2
      "d10=d10orig + t2loop * in10 "
      "phval15 = (ph2loop % 4) * -90"
      MCWRK ip15 + phval15
  lo to LBLF1 times 2
  MCWRK 

  "t2loop+=1"
      "d0=d0orig + t1loop * in0 "
      "phval2 = (ph1loop % 4) * 90"
      MCWRK ip2 + phval2
      "d10=d10orig + t2loop * in10 "
      "phval15 = (ph2loop % 4) * -90"
      MCWRK ip15 + phval15
  lo to LBLST1 times ST1CNT
  MCWRK 
  "t2loop=0"
  "ph2loop=0"
  MCWRK rf #0
  lo to LBLAV times tdav
# 168 "/ssnmrpulprogs/hCANH.mpibpc"
# 170 "/ssnmrpulprogs/hCANH.mpibpc"
HaltAcqu, 1m  	;jump address for protection files
exit						;quit

ph0  = 0
ph1  = 1
ph3  = 0
ph2 =  3 3 1 1 3 3 1 1    ; 13C->15N CP (15N pulse)
ph5 =  0 
ph6 =  0 
ph7  = 1
ph10 = 0 2               ; 13C->15N CP (13C pulse)
ph11 = 1
ph15 = 0
ph18 = 0            
ph19 = 0                 ; 13CA(all aliph) selective pulse
ph20 =  1 1 1 1 3 3 3 3

ph31 =  3 1 1 3 1 3 3 1 ; receiver phase for joint phase cycling
