# 1 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
;cpSPINDIFF  
;
;version: 1.0/ TS3 / 6/24/2011 
;
;basic 2D homonuclear exchange experiment
;written by HF and JOS 
;updated JOS 6/24/2011
;checked by JOS 24/6/2011
;
;General Comment
;2D exchange NMR in rotating solids using PDSD mixing (PL14=120db) 
;or DARR/RAD mixing with pl14 set such that the RF field is n*spin rate, n=1-3
;rotor synchronized, set cnst31=spin rate in Hz
;rotor synchronize in F1 choose n*spin rate for SWH in F1
;DARR Dipolar assisted rotational resonance (K. Takegoshi et al Chem. Phys. Lett. 2001, 344, 631.
;RAD (RF assisted diffusion) C.R. Morcombe et al., JACS 2004, 126, 7196.
;
;requires modification to run under TS2.1 inquire with applications
;
;Avance III version
;parameters:
;d1 : recycle delay
;p1 : X 90 degree pulse
;p3 : H 90 degree pulse
;p15 : contact time at plw1 (rf-channel f1) and spw0 (rf-channel f2)
;pl11 : rf-power on X for 90 degree pulses
;pl12 : rf-power for 1H pi/2 pulse p3 and standard proton decoupling
;pl13 : e.g. used in tppm13
;pl14 : rf-power for RAD-DARR mixing pulse, calculate or measure B1 field = 1 * rotation rate
;cnst31 : spinning rate in Hz
;d8 : mixing time,recalculated for multiple rotor period, max. 500 msec
;sp0 : rf-power for contact pulse of 1H channel (rf-channel f2)
;spnam0 : file name for shaped CP pulse
;cpdprg2 : 1H decoupling sequence (spinal64, tppm15, cw, etc.)
;FnMODE: TPPI, States-TPPI or STATES
;ns : 16*n
;SWH[F1]: integer multiple of rotor frequency
;zgoptns: -Dlacq, -Dlcp15, or blank
;
;
;$CLASS=BioSolids
;$DIM=2D
;$TYPE=cross polarisation
;$SUBTYPE=homonuclear correlation
;$COMMENT=exchange NMR in rotating solids using RAD/DARR for improved spin exchange, rotor synchronised


prosol relations=<solids_cp>
# 1 "/opt/topspin/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

;switch between 1H or 19F output (H amplifier) 
# 14 "/opt/topspin/exp/stan/nmr/lists/pp/Avancesolids.incl"
;gating pulse for RX, ADC and HPPR auto mode


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


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


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


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


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

;NCO switching, to be implemented

;$Id: Avancesolids.incl,v 1.8.2.1 2017/02/22 17:02:01 ber Exp $
# 51 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF" 2
# 1 "/opt/topspin/exp/stan/nmr/lists/pp/trigg.incl" 1
;version (13/08/19)

;$COMMENT=definition of external trigger output, conn I pin 1
;$CLASS=Solids INCL

# 12 "/opt/topspin/exp/stan/nmr/lists/pp/trigg.incl"
;$Id: 6u setnmr3|28 \n 4u  setnmr3^28.incl,v 1.6.2.1 2013/08/29 14:03:54 ber Exp $
# 52 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF" 2

"cnst59=plw14"
"d31=1s/cnst31"

define pulse mixing 
define delay darrmix
define loopcounter count
define loopcounter darr
"darr=d8/d31"							
"mixing=(darr*d31)"
"l0=0"										
"in0=inf1"
"d0=1u"
"acqt0=-p1/2"
"darrmix=mixing"
# 1 "mc_line 68 file /opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF exp. def. part of mc cmd. before ze"
; dimension 2D; AQ_mode  (F1) States-TPPI
define delay MCWRK
define delay MCREST
define loopcounter ST1CNT
"ST1CNT = trunc(td1 / 2)"
"MCREST = 10m - 10m"
"MCWRK = 0.250000*10m"

    dccorr
# 68 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
# 68 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
1 ze
# 1 "mc_line 68 file /opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF exp. def. of mc cmd. after ze"
LBLAV, MCWRK
# 69 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
# 1 "/opt/topspin/exp/stan/nmr/lists/pp/rot_prot.incl" 1
;rot_prot.incl
;avance-version (13/01/29)
;Test the rf on-time and duty cycle
;protect against misset cnst31, rotation speed below 1000 Hz
;
;$CLASS=Solids INCL
;$COMMENT=protect against misset cnst31, rotation speed below 1000 Hz


1m
if "d31 < 1m" goto Passrot
2u
print "rotation period too long, cnst31 misset to less than 1000 Hz!"
goto HaltAcqu
Passrot, 1m
# 19 "/opt/topspin/exp/stan/nmr/lists/pp/rot_prot.incl"
;$Id: rot_prot.incl,v 1.8 2013/01/29 15:40:14 ber Exp $
# 69 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF" 2


# 1 "/opt/topspin/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/topspin/exp/stan/nmr/lists/pp/p15_prot.incl"
1m
if "p15 < 10.1m" goto Passp15
2u
print "contact time exceeds 10msec limit!"
goto HaltAcqu
Passp15, 1m


# 20 "/opt/topspin/exp/stan/nmr/lists/pp/p15_prot.incl"
;$Id: p15_prot.incl,v 1.8 2013/01/29 15:40:14 ber Exp $
# 71 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF" 2

			;make sure p15 does not exceed 10 msec 
			;let supervisor change this pulseprogram if 
			;more is needed

# 77 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
			;disable protection file for long acquisition change decoupling power !!! or you risk probe damage
			;if you set the label lacq (ZGOPTNS -Dlacq), the protection is disabled

# 1 "/opt/topspin/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/topspin/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 $
# 80 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF" 2

			;allows max. 50 msec acquisition time, supervisor
			;may change  to max. 1s at less than 5 % duty cycle
			;and reduced decoupling field
# 1 "/opt/topspin/exp/stan/nmr/lists/pp/darrmix2_prot.incl" 1
;darrmix_prot.incl
;Test the rf on-time and duty cycle
; rotect against misset cnst31, rotation speed below 1000 Hz and too long a mixing period
;
;
;$CLASS=BioSolids INCL
;$COMMENT=protect against mixing time  >500 msec 


1u
if "darrmix<501m"  goto Passdarr;  
# 13 "/opt/topspin/exp/stan/nmr/lists/pp/darrmix2_prot.incl"
  
1u
if "cnst59<5"  goto Passdarr; TS 3.0
1u 
print "error: DARR mixing time exceeds 500 msec with plw14 not below 5 W"
goto HaltAcqu
Passdarr, 1m


# 23 "/opt/topspin/exp/stan/nmr/lists/pp/darrmix2_prot.incl"
;$Id: darrmix2_prot.incl,v 1.5.2.1 2017/02/22 17:02:01 ber Exp $
# 85 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF" 2

  darrmix
  d31
# 1 "mc_line 88 file /opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF exp. start label for mc cmd."
2 MCWRK  do:f2
LBLSTS1, MCWRK  * 2
LBLF1, MCWRK 
  MCREST
# 89 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
  d1
  1u fq=cnst21:f2
  10u pl12:f2 pl1:f1    ;preselect pl2 drive power for F2
  6u setnmr3|28 \n 4u  setnmr3^28
  p3:f2 ph1             ;proton 90 pulse
  (p15:sp2 ph2):f1 (p15:sp0 ph10):f2        ;contact pulse
 if "l0==1"{
   "d0=in0"
   }
if "l0>0"
  {  		;use cpdprg2=tppm15, SPINAL64 or XiX
  d0 cpds2:f2
}
  (p1 pl11 ph3):f1 (1u do):f2
  (mixing pl14 ph11):f2
  (p1 ph5):f1 (1u cpds2):f2
  go=2 ph31
  1m do:f2
# 1 "mc_line 107 file /opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF exp. mc cmd. in line"
  MCWRK  wr #0 if #0 zd ip2
  lo to LBLSTS1 times 2
  MCWRK id0  MCWRK  iu0
  lo to LBLF1 times ST1CNT
  MCWRK rf #0
  lo to LBLAV times tdav
# 108 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
 
HaltAcqu, 1m
6 exit

ph1=1 3
ph2=1
ph3={0}*8 {2}*8
ph5=0 0 2 2 1 1 3 3
ph10=0
ph11=0
ph31=0 2 2 0 1 3 3 1
     2 0 0 2 3 1 1 3
# 123 "/opt/topspin/exp/stan/nmr/lists/pp/user/ts_cp_Xramp-SPINDIFF"
;$Id: cpSPINDIFF,v 1.1.6.2 2017/02/22 17:02:01 ber Exp $
