; cpXpdsd_2D.suva
;modified by land dec 2017
; written on 120627

;First implemented on 850
;2D CC correlations with single pulse and PDSD mixing 
;proton decoulpling during acquisition

;=======================
; Variables introduction
;=======================

;pl2  H 90 pulse power
;p2   H 90 pulse length
;P15  CP build up time
;pl5  (=sp1) CP power on X
;sp1  (=pl5) shape power o X
;pl6  (=sp0) CP power on H 
;sp0  (=pl6) shape power o H
;l31  (=1) ramp on H (=2) ramp on X
;cnst10 CP offset on X 
;cnst20 CP offset on H
;pl1  X 90 pulse power
;p1   X 90 pulse length
;p10 X 180 pulse length for rfdr
;pl12 H decoupling during acquisition 
;cpd2  decoupling program
;pcpd2 decoupling pulse length
;d11   PDSD/DARR mixing time 
;mix mixing time for rfdr

;==============
; Set variables
;==============

"d0     = 0.2u" 
"in0    = inf1" 

"l31    = 1"
;"sp0    = pl6" 
;"sp1    = pl5"
;"cnst63 = pl12" 

"d5 = 0.5s/cnst5 - p10/2"
"acqt0=0"
define delay mix
"mix=(2*d5+p10)*l1"
;=============================
; Include file for Protection
;=============================

#include <Avance.incl>
#include <Delay.incl>

1m
  if "p1   > 100"    goto Problem
  if "p2   > 100"    goto Problem
  if "p15  > 5100"   goto Problem
  if "aq   > 20m"    goto Problem
;  if "in0  > 50u"   goto Problem
  if "d11  > 2001m"    goto Problem
  if "cnst63 < 1.0"   goto Problem 
  if "d1   < 1.0s"  goto Problem
  goto PassParams
Problem, 1m
  print "Parameters not accepted, ending."
  goto HaltAcqu
PassParams, 1m

;=====================
; Begin Pulse program
;=====================

1  ze
	mix
;----- Relaxation & reset parameters -----

2  d1 do:f2 

   2u pl5:f1  pl2:f2 
   2u fq=cnst10:f1 
   2u fq=cnst20:f2
   2u rpp10
;----- 90 on H -----

   (p2 pl2 ph1):f2

;----- H/X CP -----

 if (l31 == 1)
   {
   (p15 pl5 ph2):f1 (p15:sp0 ph0):f2
   }

 if (l31 == 2)
   {
   (p15:sp1 ph2):f1 (p15 pl6 ph0):f2
   }

;----- F1 dimension & decoupling   -----

;   2u fq=0:f1           ; This line should be uncommented if cnst10 is non zero value 
;   1u pl12:f2
   0.5u cpds2:f2
   d0

;----- PDSD mixing time  -----
    0.5u do:f2  
   (p1 pl1 ph3):f1 

#  ifdef   PDSD
   d11
#   endif /*PDSD*/

#  ifdef   DARR
;   1u pl11:f2
   0.5u cpds3:f2
   d11
   0.5u do:f2
 
#   endif /*DARR*/

#  ifdef   RFDR
4   d5
   (p10 pl10 ph10^):f1
   d5
   lo to 4 times l1
#   endif /*RFDR*/


 (p1 pl1 ph4):f1 

;----- acquisition with decoupling  -----

  1u pl12:f2  

  go=2 ph31 cpds2:f2 
  d1 do:f2 mc #0 to 2
  F1PH(calph(ph2, +90), caldel(d0, +in0))

;----- 2D increments &  write data -----

;   10m wr #0 if #0 zd
;   1m  id0
;   1m  ip2
;   lo to 2 times td1 
HaltAcqu, 1m
exit

;----- Phase cycling -----

ph0 = 0
ph1 = 1 1  3 3 3 3  1 1
ph2 = 0 0  0 0 1 1  1 1  ;try 0 2 and ph31 of 0 0 2 2 2 2 0 0
ph3 = 1 3  1 3 2 4  2 4 
ph4 = 0 0  0 0 2 2  2 2

ph10 = 2 0 2 0  0 2 0 2  1 3 1 3   3 1 3 1

ph31= 0  2   2 0 0 2   2 0


;old cycle
;ph0 = 0
;ph1 = 1 1  1 1  3 3   3 3 
;ph2 = 0 2 ;try 0 2 and ph31 of 0 0 2 2 2 2 0 0
;ph3 = 1 1  3 3 
;ph4 = 0 2 
;ph10 = 2 0 2 0  0 2 0 2  1 3 1 3   3 1 3 1

;ph31= 0 0 2 2 2 2 0 0

;old phase cycle
;ph0 = 0
;ph1 = 1 1 1 1   1 1 1 1  3 3 3 3   3 3 3 3
;ph2 = 0
;ph3 = 1 1 1 1   3 3 3 3
;ph4 = 0 1 2 3
;ph10 = 2 0 2 0  0 2 0 2  1 3 1 3   3 1 3 1
;ph31= 0 1 2 3   2 3 0 1  2 3 0 1   0 1 2 3 

; Old phase cycling
;ph0 = 0
;ph1 = 1 1 1 1   3 3 3 3
;ph2 = 0
;ph3 = 1
;ph4 = 3 0 1 2
;ph31= 0 1 2 3   2 3 0 1

;=====================
; END Pulse program
;=====================
 
