Exemplo n.º 1
0
pulsesequence()
{



/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
            mag_flg[MAXSTR],      /* magic-angle coherence transfer gradients */
 	    TROSY[MAXSTR];			    /* To check for TROSY flag */
 
int         icosel,          			  /* used to get n and p type */
            t1_counter,  		        /* used for states tppi in t1 */
            t2_counter,  	 	        /* used for states tppi in t2 */
	    ni2 = getval("ni2");

double      p_d,
	    rfd,
	    ncyc,
	    COmix = getval("COmix"),
	    p_trim,
	    rftrim,
	    tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
            timeTN = getval("timeTN"),     /* constant time for 15N evolution */
	    kappa = 5.4e-3,
	    lambda = 2.4e-3,
            
	pwClvl = getval("pwClvl"), 	        /* coarse power for C13 pulse */
        pwC = getval("pwC"),          /* C13 90 degree pulse length at pwClvl */
	rf0,            	  /* maximum fine power when using pwC pulses */
      bw, ofs, ppm,  /* bandwidth, offset, ppm - temporary Pbox parameters */

/* the following pulse lengths for SLP pulses are automatically calculated    */
/* by the macro "biocal".  SLP pulse shapes, "offC3" etc are called       */
/* directly from your shapelib.                    			      */
   pwC3 = getval("pwC3"),  /*180 degree pulse at Ca(56ppm) null at CO(174ppm) */
   pwC3a,                      /* pwC3a=pwC3, but not set to zero when pwC3=0 */
   phshift3,             /* phase shift induced on CO by pwC3 ("offC3") pulse */
   pwZ,					   /* the largest of pwC3 and 2.0*pwN */
   pwZ1,	       /* the largest of pwC3a and 2.0*pwN for 1D experiments */
   pwC6,                  /* 90 degree selective sinc pulse on CO(174ppm) */
   pwC8,                 /* 180 degree selective sinc pulse on CO(174ppm) */
   rf3,	                           /* fine power for the pwC3 ("offC3") pulse */
   rf6,	                           /* fine power for the pwC6 ("offC6") pulse */
   rf8,	                           /* fine power for the pwC8 ("offC8") pulse */

   compH = getval("compH"),       /* adjustment for C13 amplifier compression */
   compC = getval("compC"),       /* adjustment for C13 amplifier compression */

   	pwHs = getval("pwHs"),	        /* H1 90 degree pulse length at tpwrs */
   	tpwrsf = getval("tpwrsf"),    /* fine power adjustment for flipback   */
   	tpwrs,	  	              /* power for the pwHs ("H2Osinc") pulse */

   	pwHd,	    		        /* H1 90 degree pulse length at tpwrd */
   	tpwrd,	  	                   /* rf for WALTZ decoupling */

        waltzB1 = getval("waltzB1"),  /* waltz16 field strength (in Hz)     */
	pwNlvl = getval("pwNlvl"),	              /* power for N15 pulses */
        pwN = getval("pwN"),          /* N15 90 degree pulse length at pwNlvl */

	sw1 = getval("sw1"),
	sw2 = getval("sw2"),

	gt1 = getval("gt1"),  		       /* coherence pathway gradients */
        gzcal  = getval("gzcal"),            /* g/cm to DAC conversion factor */
	gzlvl1 = getval("gzlvl1"),
	gzlvl2 = getval("gzlvl2"),

	gt0 = getval("gt0"),				   /* other gradients */
	gt3 = getval("gt3"),
	gt4 = getval("gt4"),
	gt5 = getval("gt5"),
	gstab = getval("gstab"),
	gzlvl0 = getval("gzlvl0"),
	gzlvl3 = getval("gzlvl3"),
	gzlvl4 = getval("gzlvl4"),
	gzlvl5 = getval("gzlvl5"),
	gzlvl6 = getval("gzlvl6");

    getstr("f1180",f1180);
    getstr("f2180",f2180);
    getstr("mag_flg",mag_flg);
    getstr("TROSY",TROSY);



/*   LOAD PHASE TABLE    */

	settable(t3,2,phi3);
	settable(t4,1,phx);
	settable(t5,4,phi5);

        settable(t8,1,phx);
	settable(t9,8,phi9);
	settable(t10,1,phx);
	settable(t11,1,phy);
	settable(t12,4,rec);


/*   INITIALIZE VARIABLES   */

    if( dpwrf < 4095 )
	{ printf("reset dpwrf=4095 and recalibrate C13 90 degree pulse");
	  psg_abort(1); }

    /* maximum fine power for pwC pulses */
	rf0 = 4095.0;

      setautocal();                      /* activate auto-calibration */   

      if (autocal[0] == 'n') 
      {
    /* offC3 - 180 degree pulse on Ca, null at CO 118ppm away */
        pwC3a = getval("pwC3a");    
        rf3 = (compC*4095.0*pwC*2.0)/pwC3a;
	  rf3 = (int) (rf3 + 0.5);  
	
    /* 90 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */	
        pwC6 = getval("pwC6");    
	  rf6 = (compC*4095.0*pwC*1.69)/pwC6;	/* needs 1.69 times more     */
	  rf6 = (int) (rf6 + 0.5);		/* power than a square pulse */

    /* 180 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */
        pwC8 = getval("pwC8");
	  rf8 = (compC*4095.0*pwC*2.0*1.65)/pwC8;	/* needs 1.65 times more     */
	  rf8 = (int) (rf8 + 0.5);		      /* power than a square pulse */

    /* selective H20 one-lobe sinc pulse */
        tpwrs = tpwr - 20.0*log10(pwHs/(compH*pw*1.69)); /* needs 1.69 times more */
        tpwrs = (int) (tpwrs);                       /* power than a square pulse */

    /* power level and pulse time for WALTZ 1H decoupling */
	  pwHd = 1/(4.0 * waltzB1) ;                          
	  tpwrd = tpwr - 20.0*log10(pwHd/(compH*pw));
	  tpwrd = (int) (tpwrd + 0.5);
      }
      else      /* if autocal = 'y'(yes), 'q'(quiet), 'r'(read) or 's'(semi) */
      {
        if(FIRST_FID)                                         /* make shapes */
        {
          ppm = getval("dfrq"); 
          bw = 118.0*ppm; ofs = -bw; 
          offC3 = pbox_make("offC3", "square180n", bw, ofs, compC*pwC, pwClvl);
          offC6 = pbox_make("offC6", "sinc90n", bw, 0.0, compC*pwC, pwClvl);
          offC8 = pbox_make("offC8", "sinc180n", bw, 0.0, compC*pwC, pwClvl);
          H2Osinc = pbox_Rsh("H2Osinc", "sinc90", pwHs, 0.0, compH*pw, tpwr);
          wz16 = pbox_Dcal("WALTZ16", 2.8*waltzB1, 0.0, compH*pw, tpwr);


          ofs_check(H1ofs, C13ofs, N15ofs, H2ofs);
        }
        pwC3a = offC3.pw; rf3 = offC3.pwrf;             /* set up parameters */
        pwC6 = offC6.pw; rf6 = offC6.pwrf; 
        pwC8 = offC8.pw; rf8 = offC8.pwrf;
        pwHs = H2Osinc.pw; tpwrs = H2Osinc.pwr-1.0;  /* 1dB correction applied */
        tpwrd = wz16.pwr; pwHd = 1.0/wz16.dmf;  
      }

      if (tpwrsf < 4095.0) tpwrs = tpwrs + 6.0;

    /* the pwC3 pulse at the middle of t1  */
	if ((ni2 > 0.0) && (ni == 1.0)) ni = 0.0;
        if (pwC3a > 2.0*pwN) pwZ = pwC3a; else pwZ = 2.0*pwN;
        if ((pwC3==0.0) && (pwC3a>2.0*pwN)) pwZ1=pwC3a-2.0*pwN; else pwZ1=0.0;
	if ( ni > 1 )     pwC3 = pwC3a;
	if ( pwC3 > 0 )   phshift3 = 48.0;
	else              phshift3 = 0.0;

 
   /* dipsi-3 decoupling on COCO */
        p_trim = 1/(4*5000*(sfrq/600.0));  /* 5 kHz trim pulse at 600MHz as per Bax */
        p_d = (5.0)/(9.0*4.0*2800.0*(sfrq/600.0)); /* 2.8 kHz DIPSI-3 at 600MHz as per Bax*/
        rftrim = (compC*4095.0*pwC)/p_trim;
        rftrim = (int)(rftrim+0.5);
        rfd = (compC*4095.0*pwC*5.0)/(p_d*9.0);
        rfd = (int) (rfd + 0.5);
        ncyc = ((COmix - 0.002)/51.8/4/p_d);
        ncyc = (int) (ncyc + 0.5);
        initval(ncyc,v9);


/* CHECK VALIDITY OF PARAMETER RANGES */

    if ( 0.5*ni2*1/(sw2) > timeTN - WFG3_START_DELAY)
       { printf(" ni2 is too big. Make ni2 equal to %d or less.\n", 
  	 ((int)((timeTN - WFG3_START_DELAY)*2.0*sw2))); psg_abort(1);}

    if ( dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' )
       { printf("incorrect dec1 decoupler flags! Should be 'nnn' "); psg_abort(1);}

    if ( dm2[A] == 'y' || dm2[B] == 'y' )
       { printf("incorrect dec2 decoupler flags! Should be 'nny' "); psg_abort(1);}

    if ( dpwr2 > 50 )
       { printf("dpwr2 too large! recheck value  "); psg_abort(1);}

    if ( pw > 50.0e-6 )
       { printf(" pw too long ! recheck value "); psg_abort(1);} 
  
    if ( (pwN > 100.0e-6) && (ni>1 || ni2>1))
       { printf(" pwN too long! recheck value "); psg_abort(1);} 
 
    if ( TROSY[A] == 'y')
      { printf(" TROSY option is not implemented"); psg_abort(1);}
      


/* PHASES AND INCREMENTED TIMES */

/*  Phase incrementation for hypercomplex 2D data, States-Haberkorn element */

    if (phase1 == 2)   tsadd(t3,1,4);  
    if (phase2 == 2)  
    {tsadd(t10,2,4); icosel = +1;}
    else 			       
    icosel = -1;    


/*  Set up f1180  */
   
    tau1 = d2;
    if((f1180[A] == 'y') && (ni > 1.0)) 
	{ tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; }


/*  Set up f2180  */

    tau2 = d3;
    if((f2180[A] == 'y') && (ni2 > 1.0)) 
	{ tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.0; }
    tau2 = tau2/2.0;


/* Calculate modifications to phases for States-TPPI acquisition          */

   if( ix == 1) d2_init = d2;
   t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 );
   if(t1_counter % 2) 
	{ tsadd(t3,2,4); tsadd(t12,2,4); }

   if( ix == 1) d3_init = d3;
   t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 );
   if(t2_counter % 2) 
	{ tsadd(t8,2,4); tsadd(t12,2,4); }



/* BEGIN PULSE SEQUENCE */

status(A);
   	delay(d1);
	rcvroff();
	obspower(tpwr);
	decpower(pwClvl);
 	dec2power(pwNlvl);
	decpwrf(rf0);
	obsoffset(tof);
	txphase(zero);
   	delay(1.0e-5);

	dec2rgpulse(pwN, zero, 0.0, 0.0);  /*destroy N15 and C13 magnetization*/
	decrgpulse(pwC, zero, 0.0, 0.0);
	zgradpulse(gzlvl0, 0.5e-3);
	delay(1.0e-4);
	dec2rgpulse(pwN, one, 0.0, 0.0);
	decrgpulse(pwC, zero, 0.0, 0.0);
	zgradpulse(0.7*gzlvl0, 0.5e-3);
	delay(5.0e-4);

   	rgpulse(pw,zero,0.0,0.0);                      /* 1H pulse excitation */

   	dec2phase(zero);
	zgradpulse(gzlvl0, gt0);
	delay(lambda - gt0);

   	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

   	txphase(one);
	zgradpulse(gzlvl0, gt0);
	delay(lambda - gt0);

 	rgpulse(pw, one, 0.0, 0.0);
    txphase(zero);
    
    obspower(tpwrs); 
    if (tpwrsf<4095.0) obspwrf(tpwrsf);
    shaped_pulse("H2Osinc", pwHs, zero, 5.0e-4, 0.0);
    obspower(tpwrd); 
    if (tpwrsf<4095.0) obspwrf(4095.0);
    zgradpulse(gzlvl3, gt3);
    delay(2.0e-4);
    dec2rgpulse(pwN, zero, 0.0, 0.0);

    txphase(one);
    delay(kappa - pwHd - 2.0e-6 - PRG_START_DELAY);

    rgpulse(pwHd,one,0.0,0.0);
    txphase(zero);
    delay(2.0e-6);
    obsprgon("waltz16", pwHd, 90.0);	          /* PRG_START_DELAY */
    xmtron();
    decphase(zero);
    dec2phase(zero);
    decpwrf(rf8);
    delay(timeTN - kappa - WFG3_START_DELAY);
   
							  /* WFG3_START_DELAY */
	sim3shaped_pulse("", "offC8", "", 0.0, pwC8, 2.0*pwN, zero, zero, zero, 
								     0.0, 0.0);
	decphase(t3);
	decpwrf(rf6);
	delay(timeTN);

	dec2rgpulse(pwN, zero, 0.0, 0.0);

    xmtroff();
    obsprgoff();
    rgpulse(pwHd,three,2.0e-6,0.0);
	zgradpulse(gzlvl3, gt3);
 	delay(2.0e-4);
 /***************************************************************/
 /* The sequence is different from here with respect to ghn_co **/
 /***************************************************************/

    rgpulse(pwHd,one,2.0e-6,0.0);	/* H1 decoupler is turned on */
    txphase(zero);
    delay(2.0e-6);
    obsprgon("waltz16", pwHd, 90.0);	          
    xmtron();
    decshaped_pulse("offC6", pwC6, t3, 0.0, 0.0);
    decphase(zero);


	/* Refocus CO, evolve CO, spinlock CO and defocus CO  */


	delay(timeTN - tau1/2 - 0.6*pwC6 - WFG3_START_DELAY);
	decpwrf(rf8);
	sim3shaped_pulse("", "offC8","",0.0,pwC8, 2.0*pwN, zero,zero,zero,0.0,0.0);
	decpwrf(rf3);
	delay(timeTN - WFG3_STOP_DELAY - WFG_START_DELAY - pwC3a/2);
	decshaped_pulse("offC3",pwC3a,zero,0.0,0.0);
	if (tau1 > 0)
	delay(tau1/2 - WFG_STOP_DELAY - pwC3a/2 - 2.0e-6);
	else
	  delay(tau1/2);
	  
/*******DO SPINLOCK ********/

	decpwrf(rftrim);		
	decrgpulse(0.002,zero,2.0e-6,0.0);
	decpwrf(rfd);
	starthardloop(v9);
		decrgpulse(6.4*p_d,zero,0.0,0.0);
		decrgpulse(8.2*p_d,two,0.0,0.0);
		decrgpulse(5.8*p_d,zero,0.0,0.0);
		decrgpulse(5.7*p_d,two,0.0,0.0);
		decrgpulse(0.6*p_d,zero,0.0,0.0);
		decrgpulse(4.9*p_d,two,0.0,0.0);
		decrgpulse(7.5*p_d,zero,0.0,0.0);
		decrgpulse(5.3*p_d,two,0.0,0.0);
		decrgpulse(7.4*p_d,zero,0.0,0.0);
		
		decrgpulse(6.4*p_d,two,0.0,0.0);
		decrgpulse(8.2*p_d,zero,0.0,0.0);
		decrgpulse(5.8*p_d,two,0.0,0.0);
		decrgpulse(5.7*p_d,zero,0.0,0.0);
		decrgpulse(0.6*p_d,two,0.0,0.0);
		decrgpulse(4.9*p_d,zero,0.0,0.0);
		decrgpulse(7.5*p_d,two,0.0,0.0);
		decrgpulse(5.3*p_d,zero,0.0,0.0);
		decrgpulse(7.4*p_d,two,0.0,0.0);
		
		decrgpulse(6.4*p_d,two,0.0,0.0);
		decrgpulse(8.2*p_d,zero,0.0,0.0);
		decrgpulse(5.8*p_d,two,0.0,0.0);
		decrgpulse(5.7*p_d,zero,0.0,0.0);
		decrgpulse(0.6*p_d,two,0.0,0.0);
		decrgpulse(4.9*p_d,zero,0.0,0.0);
		decrgpulse(7.5*p_d,two,0.0,0.0);
		decrgpulse(5.3*p_d,zero,0.0,0.0);
		decrgpulse(7.4*p_d,two,0.0,0.0);
		
		decrgpulse(6.4*p_d,zero,0.0,0.0);
		decrgpulse(8.2*p_d,two,0.0,0.0);
		decrgpulse(5.8*p_d,zero,0.0,0.0);
		decrgpulse(5.7*p_d,two,0.0,0.0);
		decrgpulse(0.6*p_d,zero,0.0,0.0);
		decrgpulse(4.9*p_d,two,0.0,0.0);
		decrgpulse(7.5*p_d,zero,0.0,0.0);
		decrgpulse(5.3*p_d,two,0.0,0.0);
		decrgpulse(7.4*p_d,zero,0.0,0.0);
		
	endhardloop();
	decpwrf(4095.0);
	
/*   End of spinlock */

	delay(timeTN - WFG3_START_DELAY);
	decpwrf(rf8);
	sim3shaped_pulse("","offC8","",0.0,pwC8,2*pwN,zero,zero,zero,0.0,0.0);
	decpwrf(rf6);
	delay(timeTN - WFG3_STOP_DELAY);
	
 /***************************************************************/
 /*      The sequence is same as ghn_co from this point  ********/
 /***************************************************************/
 
	decshaped_pulse("offC6", pwC6, t5, 0.0, 0.0);


/*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 EVOLUTION    xxxxxxxxxxxxxxxxxxxxx  */

	dec2phase(t8);
	zgradpulse(gzlvl4, gt4);
	txphase(one);
	dcplrphase(zero);
 	delay(2.0e-4);
	dec2rgpulse(pwN, t8, 0.0, 0.0);

	decphase(zero);
	dec2phase(t9);
	decpwrf(rf8);
	delay(timeTN - WFG3_START_DELAY - tau2);
							 /* WFG3_START_DELAY  */
	sim3shaped_pulse("", "offC8", "", 0.0, pwC8, 2.0*pwN, zero, zero, t9, 0.0, 0.0);
	dec2phase(t10);
	decpwrf(rf3);


    if (tau2 > kappa)
	{
          delay(timeTN - pwC3a - WFG_START_DELAY);     	   /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
          delay(kappa - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
          else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else if (tau2 > (kappa - pwC3a - WFG_START_DELAY))
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);                                     /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(kappa -pwC3a -WFG_START_DELAY -gt1 -2.0*GRADIENT_DELAY -1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
          else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4)
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
          delay(kappa - tau2 - pwC3a - WFG_START_DELAY);   /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
          else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
	  obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
    	  delay(kappa-tau2-pwC3a-WFG_START_DELAY-gt1-2.0*GRADIENT_DELAY-1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
          else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);                    /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2);
	}
/*  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  */
	sim3pulse(pw, 0.0, pwN, t4, zero, t10, 0.0, 0.0);

	txphase(zero);
	dec2phase(zero);
	zgradpulse(gzlvl5, gt5);
	delay(lambda - 1.3*pwN - gt5);

	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl5, gt5);
	txphase(one);
	dec2phase(t11);
	delay(lambda - 1.3*pwN - gt5);

	sim3pulse(pw, 0.0, pwN, one, zero, t11, 0.0, 0.0);

	txphase(zero);
	dec2phase(zero);
	zgradpulse(gzlvl6, gt5);
	delay(lambda - 1.3*pwN - gt5);

	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

	dec2phase(t10);
	zgradpulse(gzlvl6, gt5);
	delay(lambda - 0.65*pwN - gt5);

	rgpulse(pw, zero, 0.0, 0.0); 

	delay((gt1/10.0) + 1.0e-4 +gstab - 0.5*pw + 2.0*GRADIENT_DELAY + POWER_DELAY);

	rgpulse(2.0*pw, zero, 0.0,0.0);
	dec2power(dpwr2);				       /* POWER_DELAY */
        if (mag_flg[A] == 'y')    magradpulse(icosel*gzcal*gzlvl2, gt1/10.0);
        else   zgradpulse(icosel*gzlvl2, gt1/10.0);            /* 2.0*GRADIENT_DELAY */
        delay(gstab);
        rcvron();
statusdelay(C,1.0e-4);

	setreceiver(t12);
}		 
Exemplo n.º 2
0
pulsesequence()
{



    /* DECLARE AND LOAD VARIABLES */

    char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
                f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
                mag_flg[MAXSTR],      /* magic-angle coherence transfer gradients */
                TROSY[MAXSTR];			    /* do TROSY on N15 and H1 */

    int         icosel,          			  /* used to get n and p type */
                t1_counter,  		        /* used for states tppi in t1 */
                t2_counter,  	 	        /* used for states tppi in t2 */
                ni = getval("ni"),
                ni2 = getval("ni2");

    double      tau1,         				         /*  t1 delay */
                tau2,        				         /*  t2 delay */
                t1a,		       /* time increments for first dimension */
                BPdpwrspinlock,        /*  user-defined upper limit for spinlock(Hz) */
                BPpwrlimits,           /*  =0 for no limit, =1 for limit             */
                t1b,
                t1c,
                tauCH = getval("tauCH"), 		         /* 1/4J delay for CH */
                timeTN = getval("timeTN"),     /* constant time for 15N evolution */
                epsilon = 1.05e-3,				      /* other delays */
                zeta = 3.0e-3,
                eta = 4.6e-3,
                theta = 14.0e-3,
                kappa = 5.4e-3,
                lambda = 2.4e-3,
                sheila,  /* to transfer J evolution time hyperbolically into tau1 */
                pwClvl = getval("pwClvl"), 	        /* coarse power for C13 pulse */
                pwC = getval("pwC"),          /* C13 90 degree pulse length at pwClvl */
                rf0,            	  /* maximum fine power when using pwC pulses */

                /* 90 degree pulse at Cab(46ppm), first off-resonance null at CO (174ppm)     */
                pwC1,		              /* 90 degree pulse length on C13 at rf1 */
                rf1,		       /* fine power for 5.1 kHz rf for 600MHz magnet */

                /* 180 degree pulse at Cab(46ppm), first off-resonance null at CO(174ppm)     */
                pwC2,		                    /* 180 degree pulse length at rf2 */
                rf2,		      /* fine power for 11.4 kHz rf for 600MHz magnet */

                /* p_d is used to calculate the selective decoupling on the Cab region        */
                p_d,                  	       /* 50 degree pulse for DIPSI-3 at rfd  */
                rfd,                               /* fine power for DIPSI-3 spinlock */
                spinlock = getval("spinlock"),              /* DIPSI-3 filed strength */
                ncyc = getval("ncyc"), 			  /* no. of cycles of DIPSI-3 */


                /* the following pulse lengths for SLP pulses are automatically calculated    */
                /* by the macro "proteincal".   SLP pulse shapes, "offC4" etc are called      */
                /* directly from your shapelib.                    			      */
                pwC4 = getval("pwC4"),  /*180 degree pulse at Ca(56ppm) null at CO(174ppm) */
                pwC5 = getval("pwC5"),     /* 90 degree selective sinc pulse on CO(174ppm) */
                pwC7 = getval("pwC7"),    /* 180 degree selective sinc pulse on CO(174ppm) */
                rf4,	                           /* fine power for the pwC4 ("offC4") pulse */
                rf5,	                           /* fine power for the pwC5 ("offC5") pulse */
                rf7,	                           /* fine power for the pwC7 ("offC7") pulse */

                compH = getval("compH"),       /* adjustment for C13 amplifier compression */
                compC = getval("compC"),       /* adjustment for C13 amplifier compression */
                phi7cal = getval("phi7cal"),  /* phase in degrees of the last C13 90 pulse */

                pwH,	    		        /* H1 90 degree pulse length at tpwr1 */
                tpwr1,	  	                                    /* rf for DIPSI-2 */
                DIPSI2time,     	        /* total length of DIPSI-2 decoupling */
                waltzB1 = getval("waltzB1"), /*Dipsi-2 decoupling field strength (Hz) */
                ncyc_dec,

                pwNlvl = getval("pwNlvl"),	              /* power for N15 pulses */
                pwN = getval("pwN"),          /* N15 90 degree pulse length at pwNlvl */

                sw1 = getval("sw1"),
                sw2 = getval("sw2"),

                gt1 = getval("gt1"),  		       /* coherence pathway gradients */
                gzcal  = getval("gzcal"),            /* g/cm to DAC conversion factor */
                gzlvl1 = getval("gzlvl1"),
                gzlvl2 = getval("gzlvl2"),

                gt0 = getval("gt0"),				   /* other gradients */
                gt3 = getval("gt3"),
                gt4 = getval("gt4"),
                gt5 = getval("gt5"),
                gstab = getval("gstab"),
                gzlvl0 = getval("gzlvl0"),
                gzlvl3 = getval("gzlvl3"),
                gzlvl4 = getval("gzlvl4"),
                gzlvl5 = getval("gzlvl5"),
                gzlvl6 = getval("gzlvl6");

    getstr("f1180",f1180);
    getstr("f2180",f2180);
    getstr("mag_flg",mag_flg);
    getstr("TROSY",TROSY);



    /*   LOAD PHASE TABLE    */

    settable(t3,1,phx);
    settable(t4,1,phx);
    settable(t5,2,phi5);
    settable(t6,2,phi6);
    if (TROSY[A]=='y')
    {   settable(t8,1,phy);
        settable(t9,1,phx);
        settable(t10,1,phy);
        settable(t11,1,phx);
        settable(t12,2,recT);
    }
    else
    {   settable(t8,1,phx);
        settable(t9,8,phi9);
        settable(t10,1,phx);
        settable(t11,1,phy);
        settable(t12,4,rec);
    }



    /*   INITIALIZE VARIABLES   */

    P_getreal(GLOBAL,"BPpwrlimits",&BPpwrlimits,1);
    P_getreal(GLOBAL,"BPdpwrspinlock",&BPdpwrspinlock,1);
    if (BPpwrlimits > 0.5)
    {
        if (spinlock > BPdpwrspinlock)
        {
            spinlock = BPdpwrspinlock;
            printf("spinlock too large, reset to user-defined limit (BPdpwrspinlock)");
            psg_abort(1);
        }
    }
    if( dpwrf < 4095 )
    {   printf("reset dpwrf=4095 and recalibrate C13 90 degree pulse");
        psg_abort(1);
    }

    if( pwC > 24.0*600.0/sfrq )
    {   printf("increase pwClvl so that pwC < 24*600/sfrq");
        psg_abort(1);
    }

    /* maximum fine power for pwC pulses */
    rf0 = 4095.0;

    /* 90 degree pulse on Cab, null at CO 128ppm away */
    pwC1 = sqrt(15.0)/(4.0*128.0*dfrq);
    rf1 = (compC*4095.0*pwC)/pwC1;
    rf1 = (int) (rf1 + 0.5);

    /* 180 degree pulse on Cab, null at CO 128ppm away */
    pwC2 = sqrt(3.0)/(2.0*128.0*dfrq);
    rf2 = (4095.0*compC*pwC*2.0)/pwC2;
    rf2 = (int) (rf2 + 0.5);

    /* 180 degree pulse on Ca, null at CO 118ppm away */
    rf4 = (compC*4095.0*pwC*2.0)/pwC4;
    rf4 = (int) (rf4 + 0.5);

    /* 90 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */
    rf5 = (compC*4095.0*pwC*1.69)/pwC5;	/* needs 1.69 times more     */
    rf5 = (int) (rf5 + 0.5);		/* power than a square pulse */

    /* 180 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */
    rf7 = (compC*4095.0*pwC*2.0*1.65)/pwC7;	/* needs 1.65 times more     */
    rf7 = (int) (rf7 + 0.5);		/* power than a square pulse */

    /* power level and pulse times for DIPSI 1H decoupling */
    DIPSI2time = 2.0*3.0e-3 + 2.0*14.0e-3 + 2.0*timeTN - 5.4e-3 + 0.5*pwC1 + 2.0*pwC5 + 5.0*pwN + 2*gt3 + 1.0e-4 + 4.0*GRADIENT_DELAY + 2.0* POWER_DELAY + 8.0*PRG_START_DELAY;
    pwH = 1.0/(4.0*waltzB1);
    ncyc_dec = DIPSI2time*90/(pwH*2590*4.0);
    ncyc_dec = (int) (ncyc_dec + 0.5);

    pwH = (DIPSI2time*90.0)/(ncyc_dec*2590*4.0); /* fine correction of pwH based of ncyc_dec */
    tpwr1 = 4095.0*(compH*pw/pwH);
    tpwr1 = (int) (2.0*tpwr1 + 0.5);          /* x2 because obs atten will be reduced by 6dB */


    if (ix == 1)
    {
        fprintf(stdout, "\nNo of DIPSI-2 cycles = %4.1f\n",ncyc_dec);
        fprintf(stdout, "\nfine power for DIPSI-2 pulse =%6.1f\n",tpwr1);
    }



    /* dipsi-3 decoupling on CbCa */
    p_d = (5.0)/(9.0*4.0*spinlock);                  /* DIPSI-3 spinlock*/
    rfd = (compC*4095.0*pwC*5.0)/(p_d*9.0);
    rfd = (int) (rfd + 0.5);
    ncyc = (int) (ncyc + 0.5);
    ncyc = (int) (ncyc + 0.5);



    /* CHECK VALIDITY OF PARAMETER RANGES */

    if ( 0.5*ni2*1/(sw2) > timeTN - WFG3_START_DELAY)
    {   printf(" ni2 is too big. Make ni2 equal to %d or less.\n",
               ((int)((timeTN - WFG3_START_DELAY)*2.0*sw2)));
        psg_abort(1);
    }

    if ( dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' )
    {
        printf("incorrect dec1 decoupler flags! Should be 'nnn' ");
        psg_abort(1);
    }

    if ( dm2[A] == 'y' || dm2[B] == 'y' )
    {
        printf("incorrect dec2 decoupler flags! Should be 'nny' ");
        psg_abort(1);
    }

    if ( dm3[A] == 'y' || dm3[C] == 'y' )
    {   printf("incorrect dec3 decoupler flags! Should be 'nyn' or 'nnn' ");
        psg_abort(1);
    }
    if ( dpwr2 > 50 )
    {
        printf("dpwr2 too large! recheck value  ");
        psg_abort(1);
    }

    if ( pw > 20.0e-6 )
    {
        printf(" pw too long ! recheck value ");
        psg_abort(1);
    }

    if ( pwN > 100.0e-6 )
    {
        printf(" pwN too long! recheck value ");
        psg_abort(1);
    }

    if ( TROSY[A]=='y' && dm2[C] == 'y' )
    {
        text_error("Choose either TROSY='n' or dm2='n' ! ");
        psg_abort(1);
    }


    /* PHASES AND INCREMENTED TIMES */

    /*  Phase incrementation for hypercomplex 2D data, States-Haberkorn element */

    if (phase1 == 2)   tsadd(t3,1,4);
    if (TROSY[A]=='y')
    {   if (phase2 == 2)   				      icosel = +1;
        else 	    {
            tsadd(t4,2,4);
            tsadd(t10,2,4);
            icosel = -1;
        }
    }
    else {
        if (phase2 == 2)  {
            tsadd(t10,2,4);
            icosel = +1;
        }
        else 			       icosel = -1;
    }



    /*  C13 TIME INCREMENTATION and set up f1180  */

    /*  Set up f1180  */

    tau1 = d2;
    if((f1180[A] == 'y') && (ni > 1.0))
    {
        tau1 += ( 1.0 / (2.0*sw1) );
        if(tau1 < 0.2e-6) tau1 = 0.0;
    }
    tau1 = tau1/2.0;



    /*  Hyperbolic sheila seems superior to original zeta approach  */

    /* subtract unavoidable delays from epsilon */
    epsilon = epsilon -pwC7 -WFG_START_DELAY -gt4 -2.0*GRADIENT_DELAY -5.0e-5;

    if ((ni-1)/(2.0*sw1) > 2.0*epsilon)
    {
        if (tau1 > 2.0*epsilon) sheila = epsilon;
        else if (tau1 > 0) sheila = 1.0/(1.0/tau1+1.0/epsilon-1.0/(2.0*epsilon));
        else          sheila = 0.0;
    }
    else
    {
        if (tau1 > 0) sheila = 1.0/(1.0/tau1 + 1.0/epsilon - 2.0*sw1/((double)(ni-1)));
        else          sheila = 0.0;
    }
    t1a = tau1;
    t1b = tau1 - sheila;
    t1c = epsilon - sheila;



    /*  Set up f2180  */

    tau2 = d3;
    if((f2180[A] == 'y') && (ni2 > 1.0))
    {
        tau2 += ( 1.0 / (2.0*sw2) );
        if(tau2 < 0.2e-6) tau2 = 0.0;
    }
    tau2 = tau2/2.0;



    /* Calculate modifications to phases for States-TPPI acquisition          */

    if( ix == 1) d2_init = d2;
    t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 );
    if(t1_counter % 2)
    {
        tsadd(t3,2,4);
        tsadd(t12,2,4);
    }

    if( ix == 1) d3_init = d3;
    t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 );
    if(t2_counter % 2)
    {
        tsadd(t8,2,4);
        tsadd(t12,2,4);
    }



    /*   BEGIN PULSE SEQUENCE   */

    status(A);
    if (dm3[B]=='y') lk_sample();
    delay(d1);

    if ((ni/sw1-d2)>0)
        delay(ni/sw1-d2);       /*decreases as t1 increases for const.heating*/
    if ((ni2/sw2-d3)>0)
        delay(ni2/sw2-d3);      /*decreases as t2 increases for const.heating*/

    if ( dm3[B] == 'y' )
    {
        lk_hold();    /*freezes z0 correction, stops lock pulsing*/
        lk_sampling_off();
    }
    rcvroff();
    obspower(tpwr);
    decpower(pwClvl);
    dec2power(pwNlvl);
    decpwrf(rf0);
    obsoffset(tof);
    txphase(one);
    delay(1.0e-5);

    if (TROSY[A] == 'n')
        dec2rgpulse(pwN, zero, 0.0, 0.0);  /*destroy X magnetization*/
    decrgpulse(pwC, zero, 0.0, 0.0);
    zgradpulse(gzlvl0, 0.5e-3);
    delay(1.0e-4);
    if (TROSY[A] == 'n')
        dec2rgpulse(pwN, one, 0.0, 0.0);
    decrgpulse(pwC, zero, 0.0, 0.0);
    zgradpulse(0.7*gzlvl0, 0.5e-3);
    delay(5.0e-4);


    rgpulse(pw, one, 0.0, 0.0);                    /* 1H pulse excitation */
    /* point a */
    txphase(zero);
    decphase(zero);
    zgradpulse(gzlvl0, gt0);
    delay(tauCH - gt0);

    simpulse(2*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

    decphase(t3);
    zgradpulse(gzlvl0, gt0);
    delay(tauCH - gt0);
    /* point b */
    rgpulse(pw, zero, 0.0, 0.0);
    zgradpulse(gzlvl3, gt3);
    delay(2.0e-4);
    if ( dm3[B] == 'y' )     /* begins optional 2H decoupling */
    {
        gt4=0.0;             /* no gradients during 2H decoupling */
        dec3rgpulse(1/dmf3,one,10.0e-6,2.0e-6);
        dec3unblank();
        dec3phase(zero);
        delay(2.0e-6);
        setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
    }

    decrgpulse(pwC, t3, 0.0, 0.0);
    /* point c */

    decphase(zero);
    decpwrf(rf7);
    delay(t1a);

    decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0);

    decpwrf(rf2);
    zgradpulse(gzlvl4, gt4);		        /* 2.0*GRADIENT_DELAY */
    delay(5.0e-5);
    delay(epsilon - 2.0*pw);

    rgpulse(2.0*pw, zero, 0.0, 0.0);

    delay(t1b);

    decrgpulse(pwC2, zero, 0.0, 0.0);

    zgradpulse(gzlvl4, gt4);		        /* 2.0*GRADIENT_DELAY */
    delay(5.0e-5);
    decpwrf(rf7);
    delay(t1c);

    decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0);

    decpwrf(rfd);                                        	/* point d */
    decrgpulse(1.0e-3, zero, 2.0e-6, 0.0);
    initval(ncyc, v2);
    starthardloop(v2);
    decrgpulse(4.9*p_d,one,0.0,0.0);
    decrgpulse(7.9*p_d,three,0.0,0.0);
    decrgpulse(5.0*p_d,one,0.0,0.0);
    decrgpulse(5.5*p_d,three,0.0,0.0);
    decrgpulse(0.6*p_d,one,0.0,0.0);
    decrgpulse(4.6*p_d,three,0.0,0.0);
    decrgpulse(7.2*p_d,one,0.0,0.0);
    decrgpulse(4.9*p_d,three,0.0,0.0);
    decrgpulse(7.4*p_d,one,0.0,0.0);
    decrgpulse(6.8*p_d,three,0.0,0.0);
    decrgpulse(7.0*p_d,one,0.0,0.0);
    decrgpulse(5.2*p_d,three,0.0,0.0);
    decrgpulse(5.4*p_d,one,0.0,0.0);
    decrgpulse(0.6*p_d,three,0.0,0.0);
    decrgpulse(4.5*p_d,one,0.0,0.0);
    decrgpulse(7.3*p_d,three,0.0,0.0);
    decrgpulse(5.1*p_d,one,0.0,0.0);
    decrgpulse(7.9*p_d,three,0.0,0.0);

    decrgpulse(4.9*p_d,three,0.0,0.0);
    decrgpulse(7.9*p_d,one,0.0,0.0);
    decrgpulse(5.0*p_d,three,0.0,0.0);
    decrgpulse(5.5*p_d,one,0.0,0.0);
    decrgpulse(0.6*p_d,three,0.0,0.0);
    decrgpulse(4.6*p_d,one,0.0,0.0);
    decrgpulse(7.2*p_d,three,0.0,0.0);
    decrgpulse(4.9*p_d,one,0.0,0.0);
    decrgpulse(7.4*p_d,three,0.0,0.0);
    decrgpulse(6.8*p_d,one,0.0,0.0);
    decrgpulse(7.0*p_d,three,0.0,0.0);
    decrgpulse(5.2*p_d,one,0.0,0.0);
    decrgpulse(5.4*p_d,three,0.0,0.0);
    decrgpulse(0.6*p_d,one,0.0,0.0);
    decrgpulse(4.5*p_d,three,0.0,0.0);
    decrgpulse(7.3*p_d,one,0.0,0.0);
    decrgpulse(5.1*p_d,three,0.0,0.0);
    decrgpulse(7.9*p_d,one,0.0,0.0);

    decrgpulse(4.9*p_d,three,0.0,0.0);
    decrgpulse(7.9*p_d,one,0.0,0.0);
    decrgpulse(5.0*p_d,three,0.0,0.0);
    decrgpulse(5.5*p_d,one,0.0,0.0);
    decrgpulse(0.6*p_d,three,0.0,0.0);
    decrgpulse(4.6*p_d,one,0.0,0.0);
    decrgpulse(7.2*p_d,three,0.0,0.0);
    decrgpulse(4.9*p_d,one,0.0,0.0);
    decrgpulse(7.4*p_d,three,0.0,0.0);
    decrgpulse(6.8*p_d,one,0.0,0.0);
    decrgpulse(7.0*p_d,three,0.0,0.0);
    decrgpulse(5.2*p_d,one,0.0,0.0);
    decrgpulse(5.4*p_d,three,0.0,0.0);
    decrgpulse(0.6*p_d,one,0.0,0.0);
    decrgpulse(4.5*p_d,three,0.0,0.0);
    decrgpulse(7.3*p_d,one,0.0,0.0);
    decrgpulse(5.1*p_d,three,0.0,0.0);
    decrgpulse(7.9*p_d,one,0.0,0.0);

    decrgpulse(4.9*p_d,one,0.0,0.0);
    decrgpulse(7.9*p_d,three,0.0,0.0);
    decrgpulse(5.0*p_d,one,0.0,0.0);
    decrgpulse(5.5*p_d,three,0.0,0.0);
    decrgpulse(0.6*p_d,one,0.0,0.0);
    decrgpulse(4.6*p_d,three,0.0,0.0);
    decrgpulse(7.2*p_d,one,0.0,0.0);
    decrgpulse(4.9*p_d,three,0.0,0.0);
    decrgpulse(7.4*p_d,one,0.0,0.0);
    decrgpulse(6.8*p_d,three,0.0,0.0);
    decrgpulse(7.0*p_d,one,0.0,0.0);
    decrgpulse(5.2*p_d,three,0.0,0.0);
    decrgpulse(5.4*p_d,one,0.0,0.0);
    decrgpulse(0.6*p_d,three,0.0,0.0);
    decrgpulse(4.5*p_d,one,0.0,0.0);
    decrgpulse(7.3*p_d,three,0.0,0.0);
    decrgpulse(5.1*p_d,one,0.0,0.0);
    decrgpulse(7.9*p_d,three,0.0,0.0);
    endhardloop();	                			/* point e */
    obspwrf(tpwr1);
    obspower(tpwr-6);
    obsprgon("dipsi2", pwH, 5.0);		          /* PRG_START_DELAY */
    xmtron();

    decpwrf(rf0);
    decphase(t5);
    delay(zeta - 2.0*POWER_DELAY - PRG_START_DELAY - 0.5*10.933*pwC);

    decrgpulse(pwC*158.0/90.0, t5, 0.0, 0.0);
    decrgpulse(pwC*171.2/90.0, t6, 0.0, 0.0);
    decrgpulse(pwC*342.8/90.0, t5, 0.0, 0.0);	/* Shaka composite   */
    decrgpulse(pwC*145.5/90.0, t6, 0.0, 0.0);
    decrgpulse(pwC*81.2/90.0, t5, 0.0, 0.0);
    decrgpulse(pwC*85.3/90.0, t6, 0.0, 0.0);

    decpwrf(rf1);
    decphase(zero);
    delay(zeta - 0.5*10.933*pwC - 0.5*pwC1);
    /* point f */
    decrgpulse(pwC1, zero, 0.0, 0.0);
    decphase(t5);
    decpwrf(rf5);
    if ( dm3[B] == 'y' )   /* turns off 2H decoupling  */
    {
        setstatus(DEC3ch, FALSE, 'c', FALSE, dmf3);
        dec3rgpulse(1/dmf3,three,2.0e-6,2.0e-6);
        dec3blank();
        lk_autotrig();   /* resumes lock pulsing */
    }
    zgradpulse(gzlvl3, gt3);
    delay(2.0e-4);
    decshaped_pulse("offC5", pwC5, t5, 0.0, 0.0);
    /* point g */

    decpwrf(rf4);
    decphase(zero);
    delay(eta);

    decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0);

    decpwrf(rf7);
    dec2phase(zero);
    delay(theta - eta - pwC4 - WFG3_START_DELAY);
    /* WFG3_START_DELAY */
    sim3shaped_pulse("", "offC7", "", 0.0, pwC7, 2.0*pwN, zero, zero, zero,
                     0.0, 0.0);

    decpwrf(rf5);
    decpwrf(rf5);
    initval(phi7cal, v7);
    decstepsize(1.0);
    dcplrphase(v7);					        /* SAPS_DELAY */
    dec2phase(t8);
    delay(theta - SAPS_DELAY);
    /* point h */
    decshaped_pulse("offC5", pwC5, zero, 0.0, 0.0);

    /*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 EVOLUTION    xxxxxxxxxxxxxxxxxxxxx  */

    zgradpulse(gzlvl3, gt3);
    if (TROSY[A]=='y') {
        xmtroff();
        obsprgoff();
    }
    delay(2.0e-4);
    dcplrphase(zero);
    dec2rgpulse(pwN, t8, 0.0, 0.0);
    /* point i */
    decpwrf(rf7);
    decphase(zero);
    dec2phase(t9);
    delay(timeTN - WFG3_START_DELAY - tau2);
    /* WFG3_START_DELAY  */
    sim3shaped_pulse("", "offC7", "", 0.0, pwC7, 2.0*pwN, zero, zero, t9,
                     0.0, 0.0);

    dec2phase(t10);
    decpwrf(rf4);

    if (TROSY[A]=='y')
    {
        if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4)
        {
            txphase(t4);
            delay(timeTN - pwC4 - WFG_START_DELAY);          /* WFG_START_DELAY */
            decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0);
            delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
            if (mag_flg[A]=='y')  magradpulse(gzcal*gzlvl1, gt1);
            else  zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
            obspower(tpwr);
            obspwrf(4095.0);	       /* POWER_DELAY */
            delay(1.0e-4 - 2.0*POWER_DELAY);
        }
        else
        {
            txphase(t4);
            delay(timeTN -pwC4 -WFG_START_DELAY -gt1 -2.0*GRADIENT_DELAY -1.0e-4);
            if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
            else  zgradpulse(gzlvl1, gt1);	   	/* 2.0*GRADIENT_DELAY */
            obspower(tpwr);
            obspwrf(4095.0);	       /* POWER_DELAY */
            delay(1.0e-4 - 2.0*POWER_DELAY);                    /* WFG_START_DELAY */
            decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0);
            delay(tau2);
        }
    }
    else
    {
        if (tau2 > kappa)
        {
            delay(timeTN - pwC4 - WFG_START_DELAY);     	   /* WFG_START_DELAY */
            decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0);
            delay(tau2 - kappa - PRG_STOP_DELAY);
            xmtroff();
            obsprgoff();					    /* PRG_STOP_DELAY */
            txphase(t4);
            delay(kappa - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
            if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
            else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
            obspower(tpwr);
            obspwrf(4095.0);	       /* POWER_DELAY */
            delay(1.0e-4 - 2.0*POWER_DELAY);                    /* WFG_START_DELAY */
        }
        else if (tau2 > (kappa - pwC4 - WFG_START_DELAY))
        {
            delay(timeTN + tau2 - kappa - PRG_STOP_DELAY);
            xmtroff();
            obsprgoff();					    /* PRG_STOP_DELAY */
            txphase(t4);                                     /* WFG_START_DELAY */
            decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0);
            delay(kappa -pwC4 -WFG_START_DELAY -gt1 -2.0*GRADIENT_DELAY -1.0e-4);
            if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
            else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
            obspower(tpwr);
            obspwrf(4095.0);	       /* POWER_DELAY */
            delay(1.0e-4 - 2.0*POWER_DELAY);                    /* WFG_START_DELAY */
        }
        else if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4)
        {
            delay(timeTN + tau2 - kappa - PRG_STOP_DELAY);
            xmtroff();
            obsprgoff();					    /* PRG_STOP_DELAY */
            txphase(t4);
            delay(kappa - tau2 - pwC4 - WFG_START_DELAY);    /* WFG_START_DELAY */
            decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0);
            delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
            if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
            else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
            obspower(tpwr);
            obspwrf(4095.0);	       /* POWER_DELAY */
            delay(1.0e-4 - 2.0*POWER_DELAY);                    /* WFG_START_DELAY */
        }
        else
        {
            delay(timeTN + tau2 - kappa - PRG_STOP_DELAY);
            xmtroff();
            obsprgoff();					    /* PRG_STOP_DELAY */
            txphase(t4);
            delay(kappa-tau2-pwC4-WFG_START_DELAY-gt1-2.0*GRADIENT_DELAY-1.0e-4);
            if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
            else    zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
            obspower(tpwr);
            obspwrf(4095.0);	       /* POWER_DELAY */
            delay(1.0e-4 - 2.0*POWER_DELAY);                    /* WFG_START_DELAY */
            decshaped_pulse("offC4", pwC4, zero, 0.0, 0.0);
            delay(tau2);
        }
    }                                                            	/* point j */
    /*  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  */
    if (TROSY[A]=='y')  rgpulse(pw, t4, 0.0, 0.0);
    else                sim3pulse(pw, 0.0, pwN, t4, zero, t10, 0.0, 0.0);

    txphase(zero);
    dec2phase(zero);
    zgradpulse(gzlvl5, gt5);
    if (TROSY[A]=='y')   delay(lambda - 0.65*(pw + pwN) - gt5);
    else   delay(lambda - 1.3*pwN - gt5);

    sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

    zgradpulse(gzlvl5, gt5);
    txphase(one);
    dec2phase(t11);
    delay(lambda - 1.3*pwN - gt5);

    sim3pulse(pw, 0.0, pwN, one, zero, t11, 0.0, 0.0);

    txphase(zero);
    dec2phase(zero);
    zgradpulse(gzlvl6, gt5);
    delay(lambda - 1.3*pwN - gt5);

    sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

    dec2phase(t10);
    zgradpulse(gzlvl6, gt5);
    if (TROSY[A]=='y')   delay(lambda - 1.6*pwN - gt5);
    else   delay(lambda - 0.65*pwN - gt5);

    if (TROSY[A]=='y')   dec2rgpulse(pwN, t10, 0.0, 0.0);
    else    	     rgpulse(pw, zero, 0.0, 0.0);

    delay((gt1/10.0) + 1.0e-4 +gstab - 0.5*pw + 2.0*GRADIENT_DELAY + POWER_DELAY);

    rgpulse(2.0*pw, zero, 0.0, rof1);
    dec2power(dpwr2);				       /* POWER_DELAY */
    if (mag_flg[A] == 'y')    magradpulse(icosel*gzcal*gzlvl2, gt1/10.0);
    else   zgradpulse(icosel*gzlvl2, gt1/10.0);            /* 2.0*GRADIENT_DELAY */
    delay(gstab);
    rcvron();
    statusdelay(C,1.0e-4 - rof1);

    if (dm3[B]=='y') lk_sample();

    setreceiver(t12);
}
Exemplo n.º 3
0
void pulsesequence()
{
   


/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            mag_flg[MAXSTR],                            /*magic angle gradient*/
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
            codecseq[MAXSTR];       /* sequence for 13C' decoupling */
 
int         icosel1,          			  /* used to get n and p type */
            icosel2,
	    t1_counter,  		        /* used for states tppi in t1 */
	    ni2 = getval("ni2");

double      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
	    del = getval("del"),     /* time delays for CH coupling evolution */
	    del1 = getval("del1"),
	    del2 = getval("del2"),
            del3 = getval("del3"),
            del4 = getval("del4"),
            TC = getval("TC"),
            satpwr = getval("satpwr"),
            waltzB1 = getval("waltzB1"),
            spinlock = getval("spinlock"),
            pwco,copwr, cores,codmf,
            kappa,

	pwClvl = getval("pwClvl"), 	        /* coarse power for C13 pulse */
        pwC = getval("pwC"),          /* C13 90 degree pulse length at pwClvl */
	rf0,            	  /* maximum fine power when using pwC pulses */

/* p_d is used to calculate the isotropic mixing on the Cab region            */
        p_d,                  	       /* 50 degree pulse for DIPSI-2 at rfd  */
        rfd,                    /* fine power for 7 kHz rf for 500MHz magnet  */
	ncyc = getval("ncyc"), 			  /* no. of cycles of DIPSI-3 */


   compC = getval("compC"),         /* adjustment for C13 amplifier compression */


	pwNlvl = getval("pwNlvl"),	              /* power for N15 pulses */
        pwN = getval("pwN"),          /* N15 90 degree pulse length at pwNlvl */

        pwHd,                           /* H1 90 degree pulse length at tpwrd */
        tpwrd,                             /*rf for WALTZ decoupling */

	sw1 = getval("sw1"),
	sw2 = getval("sw2"),

	gt1 = getval("gt1"),  		       /* coherence pathway gradients */
	gzcal = getval("gzcal"),               /* G/cm to DAC coversion factor*/
        gstab = getval("gstab"),
        gzlvl1 = getval("gzlvl1"),
	gzlvl2 = getval("gzlvl2"),

	gt3 = getval("gt3"),				   /* other gradients */
	gt5 = getval("gt5"),
	gzlvl3 = getval("gzlvl3"),
	gzlvl4 = getval("gzlvl4"),
	gzlvl5 = getval("gzlvl5"),
	gzlvl6 = getval("gzlvl6");

    getstr("mag_flg",mag_flg);
    getstr("f1180",f1180);
    getstr("f2180",f2180);
    getstr("codecseq",codecseq);

/*   LOAD PHASE TABLE    */

	settable(t1,2,phi1);
	settable(t2,1,phi2);
	settable(t3,1,phi3);
	settable(t4,1,phi4);
	settable(t11,2,rec);

        

/*   INITIALIZE VARIABLES   */

    if( dpwrf < 4095 )
	{ printf("reset dpwrf=4095 and recalibrate C13 90 degree pulse");
	  psg_abort(1); }

    /* maximum fine power for pwC pulses */
	rf0 = 4095.0;

   /* dipsi-3 decoupling on CbCa */	
 	p_d = (5.0)/(9.0*4.0*spinlock); /* DIPSI-3*/
 	rfd = (compC*4095.0*pwC*5.0)/(p_d*9.0);
	rfd = (int) (rfd + 0.5);
  	ncyc = (int) (ncyc + 0.5);


   /* power level and pulse time for WALTZ 1H decoupling */
        pwHd = 1/(4.0 * waltzB1) ;    
        tpwrd = tpwr - 20.0*log10(pwHd/(pw));
        tpwrd = (int) (tpwrd + 0.5);

/* activate auto-calibration flags */
setautocal();
  if (autocal[0] == 'n')
  {
    codmf= getval("codmf");
    pwco = 1.0/codmf; /* pw for 13C' decoupling field */
    copwr = getval("copwr"); /* power level for 13C' decoupling */
    cores = getval("cores"); /* power level for 13C' decoupling */
  }
  else        /* if autocal = 'y'(yes), 'q'(quiet), r(read), or 's'(semi) */
  {
    strcpy(codecseq,"Pdec_154p");
    if(FIRST_FID)                                            /* call Pbox */
    {
      ppm = getval("dfrq");
      bw=20.0*ppm; ofs=154*ppm;
      Pdec_154p = pbox_Dsh("Pdec_154p", "WURST2", bw, ofs, compC*pwC, pwClvl);
      bw=30*ppm; ofs=0.0*ppm; nst = 1000; pws = 0.001;
      me180 = pbox_makeA("me180", "sech", bw, pws, ofs, compC*pwC, pwClvl, nst);
    }

    copwr = Pdec_154p.pwr; pwco = 1.0/Pdec_154p.dmf;
    cores = Pdec_154p.dres;
    pwme180 = me180.pw; me180pwr= me180.pwr; me180pwrf = me180.pwrf;

  }
/* CHECK VALIDITY OF PARAMETER RANGES */

    if( gt1 > 0.5*del - 1.0e-4)
    {
        printf(" gt1 is too big. Make gt1 less than %f.\n", (0.5*del - 1.0e-4));
        psg_abort(1);
    }

    if( dm[A] == 'y' )
    {
        printf("incorrect dec1 decoupler flag! Should be 'nny' or 'nnn' ");
        psg_abort(1);
    }

    if((dm2[A] == 'y' || dm2[C] == 'y'))
    {
        printf("incorrect dec2 decoupler flags! Should be 'nnn' ");
        psg_abort(1);
    }
    if((dm3[A] == 'y' || dm3[C] == 'y'))
    {
        printf("incorrect dec3 decoupler flags! Should be 'nnn' or 'nyn' ");
        psg_abort(1);
    }

    if( dpwr > 52 )
    {
        printf("don't fry the probe, DPWR too large!  ");
        psg_abort(1);
    }

    if( pw > 50.0e-6 )
    {
        printf("dont fry the probe, pw too high ! ");
        psg_abort(1);
    } 
  
    if( pwN > 100.0e-6 )
    {
        printf("dont fry the probe, pwN too high ! ");
        psg_abort(1);
    } 
 

/* PHASES AND INCREMENTED TIMES */

/*  Phase incrementation for hypercomplex 2D data, States-Haberkorn element */

    icosel1 = 1; icosel2 = 1;
    if (phase1 == 2) 
	{ tsadd(t2,2,4); icosel1 = -1;}
    if (phase2 == 2) 
	{ tsadd(t4,2,4); icosel2 = -1; tsadd(t2,2,4);}

/*  Set up f1180  */
   
    tau1 = d2;
    if((f1180[A] == 'y') && (ni > 1.0)) 
	{ tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; }
    tau1 = tau1/2.0;


/*  Set up f2180  */

    tau2 = d3;
    if((f2180[A] == 'y') && (ni2 > 1.0)) 
	{ tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.0; }
    tau2 = tau2/2.0;


/* Calculate modifications to phases for States-TPPI acquisition  */

   if( ix == 1) d2_init = d2;
   t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 );
   if(t1_counter % 2) 
	{ tsadd(t1,2,4); tsadd(t11,2,4); }

   
   if(ni > 1)
           kappa = (double)(t1_counter*(del2+pwN)) / ( (double) (ni-1) );
      else kappa = 0.0;   

/*   BEGIN PULSE SEQUENCE   */

status(A);

        decoffset(dof-140*dfrq);
	rcvroff();
	obspower(tpwr);
	decpower(pwClvl);
 	dec2power(pwNlvl);
	decpwrf(rf0);
	obsoffset(tof);
	txphase(zero);
	delay(1.0e-5);

  if (satmode[A] == 'y')
    {
      obspower(satpwr);
      txphase(zero);
      rgpulse(d1,zero,20.0e-6,20.0e-6);
      obspower(tpwr);            /* Set power for hard pulses  */
    }
  else  
    {
      obspower(tpwr); /* Set power for hard pulses  */ 
      delay(d1);
    }

	decrgpulse(pwC, zero, 0.0, 0.0);	   /*destroy C13 magnetization*/
	zgradpulse(gzlvl1, 0.5e-3);
	delay(gstab);
	decrgpulse(pwC, one, 0.0, 0.0);
	zgradpulse(0.7*gzlvl1, 0.5e-3);
	delay(1.1*gstab);

   if(dm3[B] == 'y')				  /*optional 2H decoupling on */
        { 
          dec3unblank();
          dec3rgpulse(1/dmf3, one, 0.0, 0.0); 
          dec3unblank();
          setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
         } 
	rgpulse(pw, zero, 0.0, 0.0);                    /* 1H pulse excitation */

	zgradpulse(gzlvl3, gt3);
        decphase(zero);
	delay(0.5*del - gt3);

	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl3, gt3);
        decphase(t1);
	delay(0.5*del - gt3);

	decrgpulse(pwC, t1, 0.0, 0.0);
        
      /* decoupling on for carbonyl carbon */
         decpwrf(4095.0);
         decpower(copwr);
         decprgon(codecseq,pwco,cores);
         decon();
      /* decoupling on for carbonyl carbon */

        delay((1-kappa)*tau1);

        sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

        delay((1-kappa)*tau1);
      
        rgpulse(pw, one, 0.0, 0.0); 

        zgradpulse(icosel1*gzlvl4, gt1);

	delay(0.5*del2 + kappa*tau1 - gt1);

      /* co-decoupling off */
         decoff();
         decprgoff();
      /* co-decoupling off */
         decpower(pwClvl);

	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

      /* decoupling on for carbonyl carbon */
         decpwrf(4095.0);
         decpower(copwr);
         decprgon(codecseq,pwco,cores);
         decon();
      /* decoupling on for carbonyl carbon */

	delay(0.5*del2 + pwN - kappa*tau1);
        rgpulse(2.0*pw,zero,0.0,0.0);
        delay(pwN);

      /* co-decoupling off */
         decoff();
         decprgoff();
      /* co-decoupling off */
         decpower(pwClvl);

        decphase(t2);

	decrgpulse(pwC, t2, 0.0, 0.0);

	decpwrf(rfd);
	delay(2.0e-6);
	initval(ncyc, v2);
	starthardloop(v2);
     decrgpulse(4.9*p_d,one,0.0,0.0);
     decrgpulse(7.9*p_d,three,0.0,0.0);
     decrgpulse(5.0*p_d,one,0.0,0.0);
     decrgpulse(5.5*p_d,three,0.0,0.0);
     decrgpulse(0.6*p_d,one,0.0,0.0);
     decrgpulse(4.6*p_d,three,0.0,0.0);
     decrgpulse(7.2*p_d,one,0.0,0.0);
     decrgpulse(4.9*p_d,three,0.0,0.0);
     decrgpulse(7.4*p_d,one,0.0,0.0);
     decrgpulse(6.8*p_d,three,0.0,0.0);
     decrgpulse(7.0*p_d,one,0.0,0.0);
     decrgpulse(5.2*p_d,three,0.0,0.0);
     decrgpulse(5.4*p_d,one,0.0,0.0);
     decrgpulse(0.6*p_d,three,0.0,0.0);
     decrgpulse(4.5*p_d,one,0.0,0.0);
     decrgpulse(7.3*p_d,three,0.0,0.0);
     decrgpulse(5.1*p_d,one,0.0,0.0);
     decrgpulse(7.9*p_d,three,0.0,0.0);

     decrgpulse(4.9*p_d,three,0.0,0.0);
     decrgpulse(7.9*p_d,one,0.0,0.0);
     decrgpulse(5.0*p_d,three,0.0,0.0);
     decrgpulse(5.5*p_d,one,0.0,0.0);
     decrgpulse(0.6*p_d,three,0.0,0.0);
     decrgpulse(4.6*p_d,one,0.0,0.0);
     decrgpulse(7.2*p_d,three,0.0,0.0);
     decrgpulse(4.9*p_d,one,0.0,0.0);
     decrgpulse(7.4*p_d,three,0.0,0.0);
     decrgpulse(6.8*p_d,one,0.0,0.0);
     decrgpulse(7.0*p_d,three,0.0,0.0);
     decrgpulse(5.2*p_d,one,0.0,0.0);
     decrgpulse(5.4*p_d,three,0.0,0.0);
     decrgpulse(0.6*p_d,one,0.0,0.0);
     decrgpulse(4.5*p_d,three,0.0,0.0);
     decrgpulse(7.3*p_d,one,0.0,0.0);
     decrgpulse(5.1*p_d,three,0.0,0.0);
     decrgpulse(7.9*p_d,one,0.0,0.0);

     decrgpulse(4.9*p_d,three,0.0,0.0);
     decrgpulse(7.9*p_d,one,0.0,0.0);
     decrgpulse(5.0*p_d,three,0.0,0.0);
     decrgpulse(5.5*p_d,one,0.0,0.0);
     decrgpulse(0.6*p_d,three,0.0,0.0);
     decrgpulse(4.6*p_d,one,0.0,0.0);
     decrgpulse(7.2*p_d,three,0.0,0.0);
     decrgpulse(4.9*p_d,one,0.0,0.0);
     decrgpulse(7.4*p_d,three,0.0,0.0);
     decrgpulse(6.8*p_d,one,0.0,0.0);
     decrgpulse(7.0*p_d,three,0.0,0.0);
     decrgpulse(5.2*p_d,one,0.0,0.0);
     decrgpulse(5.4*p_d,three,0.0,0.0);
     decrgpulse(0.6*p_d,one,0.0,0.0);
     decrgpulse(4.5*p_d,three,0.0,0.0);
     decrgpulse(7.3*p_d,one,0.0,0.0);
     decrgpulse(5.1*p_d,three,0.0,0.0);
     decrgpulse(7.9*p_d,one,0.0,0.0);

     decrgpulse(4.9*p_d,one,0.0,0.0);
     decrgpulse(7.9*p_d,three,0.0,0.0);
     decrgpulse(5.0*p_d,one,0.0,0.0);
     decrgpulse(5.5*p_d,three,0.0,0.0);
     decrgpulse(0.6*p_d,one,0.0,0.0);
     decrgpulse(4.6*p_d,three,0.0,0.0);
     decrgpulse(7.2*p_d,one,0.0,0.0);
     decrgpulse(4.9*p_d,three,0.0,0.0);
     decrgpulse(7.4*p_d,one,0.0,0.0);
     decrgpulse(6.8*p_d,three,0.0,0.0);
     decrgpulse(7.0*p_d,one,0.0,0.0);
     decrgpulse(5.2*p_d,three,0.0,0.0);
     decrgpulse(5.4*p_d,one,0.0,0.0);
     decrgpulse(0.6*p_d,three,0.0,0.0);
     decrgpulse(4.5*p_d,one,0.0,0.0);
     decrgpulse(7.3*p_d,three,0.0,0.0);
     decrgpulse(5.1*p_d,one,0.0,0.0);
     decrgpulse(7.9*p_d,three,0.0,0.0);
	endhardloop();

        txphase(one);
	decpwrf(rf0);
        decphase(t3);
        obspower(tpwrd);
        decoffset(dof - 155*dfrq);
        decrgpulse(pwC,t3,0.0,0.0);

        rgpulse(pwHd,one,0.0,2.0e-6);
        txphase(zero);
        obsunblank();
        obsprgon("waltz16", pwHd, 90.0);              /* PRG_START_DELAY */
        xmtron();

	delay(TC - OFFSET_DELAY - POWER_DELAY - PRG_START_DELAY - tau2);

	decrgpulse(2.0*pwC, zero, 0.0, 0.0);

        delay(TC + tau2 - POWER_DELAY - PRG_STOP_DELAY - 2*gt1 - gstab - 2.0*pw);

        xmtroff();
        obsprgoff();
        obsblank();
        rgpulse(pwHd,three,2.0e-6,0.0);
        txphase(zero);
        obspower(tpwr);

    if (mag_flg[A] =='y')
        magradpulse(gzcal*icosel2*gzlvl2, gt1);
    else
        zgradpulse(icosel2*gzlvl2, gt1);
        delay(gstab/2.0);
        rgpulse(2.0*pw,zero,0.0,0.0);
    if (mag_flg[A] =='y')
        magradpulse(gzcal*icosel2*gzlvl2, gt1);
    else
        zgradpulse(icosel2*gzlvl2, gt1);
        delay(gstab/2.0);

        decphase(zero);
        simpulse(0.0,pwC, zero, zero, 0.0, 0.0);

        zgradpulse(gzlvl5, gt5);
        delay(0.5*del1 - gt5);

        simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

        zgradpulse(gzlvl5, gt5);
        txphase(one);
        decphase(t4);
        delay(0.5*del1 - gt5);

	simpulse(pw, pwC, one, t4, 0.0, 0.0);

	zgradpulse(gzlvl6, gt5);
	txphase(zero);
	decphase(zero);
	delay(0.5*del4 - gt5);

	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl6, gt5);
	delay(0.5*del4 - gt5);

	simpulse(pw,pwC,zero,zero,0.0,0.0);
        zgradpulse(2.3*gzlvl6, gt1);

   if (autocal[A] == 'y')
       {
        decpower(me180pwr); decpwrf(me180pwrf);
	delay(0.5*del3 - gt1 - 0.0005 -2.0*POWER_DELAY- WFG2_START_DELAY);
	simshaped_pulse("","me180",2.0*pw,0.001, zero, zero, 0.0, 0.0);
        decpwrf(rf0);

       }
   else
       {
	delay(0.5*del3 - 0.5*pwC - gt1);
	simpulse(2.0*pw,2.0*pwC, zero, zero, 0.0, 0.0);
       }


   decpower(dpwr);
        if (mag_flg[A] == 'y')
            magradpulse(gzcal*((2.3*gzlvl6)+gzlvl1), gt1);
        else
            zgradpulse(((2.3*gzlvl6)+gzlvl1), gt1);

   if (autocal[A] == 'y')
   {
     if(dm3[B] == 'y')
       delay(0.5*del3 -  0.0005 -gt1 -1/dmf3 - 2.0*GRADIENT_DELAY - 2.0*POWER_DELAY);
        else
       delay(0.5*del3 -  0.0005 -gt1 - 2.0*GRADIENT_DELAY - 2.0*POWER_DELAY);
   }
   else
   {
     if(dm3[B] == 'y') 
      delay(0.5*del3 -  gt1 -1/dmf3 - 2.0*GRADIENT_DELAY - POWER_DELAY);
         else
      delay(0.5*del3 -  gt1 - 2.0*GRADIENT_DELAY - POWER_DELAY);
   }

   if(dm3[B] == 'y')			         /*optional 2H decoupling off */
        {
          dec3rgpulse(1/dmf3, three, 0.0, 0.0);
          setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
          dec3blank();
        }
 if (dm3[B]=='y') lk_sample();
 status(C); 
 setreceiver(t11);
}
Exemplo n.º 4
0
void pulsesequence()
{



/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
            mag_flg[MAXSTR],      /* magic-angle coherence transfer gradients */
 	    TROSY[MAXSTR];			    /* do TROSY on N15 and H1 */
 
int         icosel,          			  /* used to get n and p type */
            t1_counter=getval("t1_counter"),      /* used for states tppi in t1 */
            t2_counter=getval("t2_counter"),      /* used for states tppi in t2 */
	    nli = getval("nli"),
	    nli2 = getval("nli2");

double      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
            timeTN = getval("timeTN"),     /* constant time for 15N evolution */
	    kappa = 5.4e-3,
	    lambda = 2.4e-3,
            
	pwClvl = getval("pwClvl"), 	        /* coarse power for C13 pulse */
        pwC = getval("pwC"),          /* C13 90 degree pulse length at pwClvl */
	rf0,            	  /* maximum fine power when using pwC pulses */

/* the following pulse lengths for SLP pulses are automatically calculated    */
/* by the macro "proteincal".  SLP pulse shapes, "offC3" etc are called       */
/* directly from your shapelib.                    			      */
   pwC3 = getval("pwC3"),  /*180 degree pulse at Ca(56ppm) null at CO(174ppm) */
   pwC3a = getval("pwC3a"),    /* pwC3a=pwC3, but not set to zero when pwC3=0 */
   phshift3,             /* phase shift induced on CO by pwC3 ("offC3") pulse */
   pwZ,					   /* the largest of pwC3 and 2.0*pwN */
   pwZ1,	       /* the largest of pwC3a and 2.0*pwN for 1D experiments */
   pwC6 = getval("pwC6"),     /* 90 degree selective sinc pulse on CO(174ppm) */
   pwC8 = getval("pwC8"),    /* 180 degree selective sinc pulse on CO(174ppm) */
   rf3,	                           /* fine power for the pwC3 ("offC3") pulse */
   rf6,	                           /* fine power for the pwC6 ("offC6") pulse */
   rf8,	                           /* fine power for the pwC8 ("offC8") pulse */

   compH = getval("compH"),       /* adjustment for C13 amplifier compression */
   compC = getval("compC"),       /* adjustment for C13 amplifier compression */

   	pwHs = getval("pwHs"),	        /* H1 90 degree pulse length at tpwrs */
   	tpwrsf = getval("tpwrsf"),      /* fine power for pwHs pulse          */
   	tpwrs,	  	              /* power for the pwHs ("H2Osinc") pulse */

   	pwHd,	    		        /* H1 90 degree pulse length at tpwrd */
   	tpwrd,                                     /* rf for WALTZ decoupling */
        waltzB1 = getval("waltzB1"),  /* waltz16 field strength (in Hz)     */

	pwNlvl = getval("pwNlvl"),	              /* power for N15 pulses */
        pwN = getval("pwN"),          /* N15 90 degree pulse length at pwNlvl */

	sw1 = getval("sw1"),
	sw2 = getval("sw2"),

	gt1 = getval("gt1"),  		       /* coherence pathway gradients */
        gzcal  = getval("gzcal"),            /* g/cm to DAC conversion factor */
	gzlvl1 = getval("gzlvl1"),
	gzlvl2 = getval("gzlvl2"),

	gt0 = getval("gt0"),				   /* other gradients */
	gt3 = getval("gt3"),
	gt4 = getval("gt4"),
	gt5 = getval("gt5"),
	gstab = getval("gstab"),
	gzlvl0 = getval("gzlvl0"),
	gzlvl3 = getval("gzlvl3"),
	gzlvl4 = getval("gzlvl4"),
	gzlvl5 = getval("gzlvl5"),
	gzlvl6 = getval("gzlvl6");

    getstr("f1180",f1180);
    getstr("f2180",f2180);
    getstr("mag_flg",mag_flg);
    getstr("TROSY",TROSY);



/*   LOAD PHASE TABLE    */

	settable(t3,2,phi3);
	settable(t4,1,phx);
	settable(t5,4,phi5);
   if (TROSY[A]=='y')
       {settable(t8,1,phy);
	settable(t9,1,phx);
 	settable(t10,1,phy);
	settable(t11,1,phx);
	settable(t12,4,recT);}
    else
       {settable(t8,1,phx);
	settable(t9,8,phi9);
	settable(t10,1,phx);
	settable(t11,1,phy);
	settable(t12,4,rec);}




/*   INITIALIZE VARIABLES   */

    if( dpwrf < 4095 )
	{ printf("reset dpwrf=4095 and recalibrate C13 90 degree pulse");
	  psg_abort(1); }

    /* maximum fine power for pwC pulses */
	rf0 = 4095.0;

    /* 180 degree pulse on Ca, null at CO 118ppm away */
        rf3 = (compC*4095.0*pwC*2.0)/pwC3a;
	rf3 = (int) (rf3 + 0.5);

    /* the pwC3 pulse at the middle of t1  */
	if ((nli2 > 0.0) && (nli == 1.0)) nli = 0.0;
        if (pwC3a > 2.0*pwN) pwZ = pwC3a; else pwZ = 2.0*pwN;
        if ((pwC3==0.0) && (pwC3a>2.0*pwN)) pwZ1=pwC3a-2.0*pwN; else pwZ1=0.0;
	if ( nli > 1 )     pwC3 = pwC3a;
	if ( pwC3 > 0 )   phshift3 = 48.0;
	else              phshift3 = 0.0;

    /* 90 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */
	rf6 = (compC*4095.0*pwC*1.69)/pwC6;	/* needs 1.69 times more     */
	rf6 = (int) (rf6 + 0.5);		/* power than a square pulse */

    /* 180 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */
	rf8 = (compC*4095.0*pwC*2.0*1.65)/pwC8;	/* needs 1.65 times more     */
	rf8 = (int) (rf8 + 0.5);		/* power than a square pulse */
	
    /* selective H20 one-lobe sinc pulse */
    tpwrs = tpwr - 20.0*log10(pwHs/(compH*pw*1.69)); /* needs 1.69 times more */
    tpwrs = (int) (tpwrs);                       /* power than a square pulse */

    /* power level and pulse time for WALTZ 1H decoupling */
	pwHd = 1/(4.0 * waltzB1) ;         
	tpwrd = tpwr - 20.0*log10(pwHd/(compH*pw));
	tpwrd = (int) (tpwrd + 0.5);
 


/* CHECK VALIDITY OF PARAMETER RANGES */

    if ( 0.5*nli2*1/(sw2) > timeTN - WFG3_START_DELAY)
       { printf(" nli2 is too big. Make nli2 equal to %d or less.\n", 
  	 ((int)((timeTN - WFG3_START_DELAY)*2.0*sw2))); psg_abort(1);}

    if ( dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' )
       { printf("incorrect dec1 decoupler flags! Should be 'nnn' "); psg_abort(1);}

    if ( dm2[A] == 'y' || dm2[B] == 'y' )
       { printf("incorrect dec2 decoupler flags! Should be 'nny' "); psg_abort(1);}

    if ( dpwr2 > 46 )
       { printf("dpwr2 too large! recheck value  "); psg_abort(1);}

    if ( pw > 50.0e-6 )
       { printf(" pw too long ! recheck value "); psg_abort(1);} 
  
    if ( (pwN > 100.0e-6) && (nli>1 || nli2>1))
       { printf(" pwN too long! recheck value "); psg_abort(1);} 
 
    if ( TROSY[A]=='y' && dm2[C] == 'y' )
       { text_error("Choose either TROSY='n' or dm2='n' ! "); psg_abort(1);}



/* PHASES AND INCREMENTED TIMES */

/*  Phase incrementation for hypercomplex 2D data, States-Haberkorn element */

    if (phase1 == 2)   tsadd(t3,1,4);  
    if (TROSY[A]=='y')
	 {  if (phase2 == 2)   				      icosel = +1;
            else 	    {tsadd(t4,2,4);  tsadd(t10,2,4);  icosel = -1;}
	 }
    else {  if (phase2 == 2)  {tsadd(t10,2,4); icosel = +1;}
            else 			       icosel = -1;    
	 }


/*  Set up f1180  */

    if( ix == 1) d2_init = d2;
    tau1 = d2_init + (t1_counter) / sw1;

    if((f1180[A] == 'y') && (nli > 1.0)) 
	{ tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; }
    tau1 = tau1/2.0;


/*  Set up f2180  */

    if( ix == 1) d3_init = d3;
    tau2 = d3_init + (t2_counter) / sw2;

    if((f2180[A] == 'y') && (nli2 > 1.0)) 
	{ tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.0; }
    tau2 = tau2/2.0;


/* Calculate modifications to phases for States-TPPI acquisition          */

   if(t1_counter % 2) 
	{ tsadd(t3,2,4); tsadd(t12,2,4); }

   if(t2_counter % 2) 
	{ tsadd(t8,2,4); tsadd(t12,2,4); }


/* BEGIN PULSE SEQUENCE */

status(A);
   	delay(d1);
	rcvroff();
	obspower(tpwr);
	decpower(pwClvl);
 	dec2power(pwNlvl);
	decpwrf(rf0);
	obsoffset(tof);
	txphase(zero);
   	delay(1.0e-5);

       if (TROSY[A] == 'n')
	dec2rgpulse(pwN, zero, 0.0, 0.0);  /*destroy N15 and C13 magnetization*/
	decrgpulse(pwC, zero, 0.0, 0.0);
	zgradpulse(gzlvl0, 0.5e-3);
	delay(1.0e-4);
       if (TROSY[A] == 'n')
	dec2rgpulse(pwN, one, 0.0, 0.0);
	decrgpulse(pwC, zero, 0.0, 0.0);
	zgradpulse(0.7*gzlvl0, 0.5e-3);
	delay(5.0e-4);

   	rgpulse(pw,zero,0.0,0.0);                      /* 1H pulse excitation */

   	dec2phase(zero);
	zgradpulse(gzlvl0, gt0);
	delay(lambda - gt0);

   	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

   	txphase(one);
	zgradpulse(gzlvl0, gt0);
	delay(lambda - gt0);

 	rgpulse(pw, one, 0.0, 0.0);
    if (tpwrsf < 4095.0)
     {obspwrf(tpwrsf); tpwrs=tpwrs+6.0;}
    obspower(tpwrs);
if (TROSY[A]=='y')
   {txphase(two);
    shaped_pulse("H2Osinc", pwHs, two, 5.0e-4, 0.0);
    obspower(tpwr); obspwrf(4095.0);
    zgradpulse(gzlvl3, gt3);
    delay(2.0e-4);
    dec2rgpulse(pwN, zero, 0.0, 0.0);

    delay(0.5*kappa - 2.0*pw);

    rgpulse(2.0*pw, two, 0.0, 0.0);

    decphase(zero);
    dec2phase(zero);
    decpwrf(rf8);
    delay(timeTN - 0.5*kappa - WFG3_START_DELAY);
   }
else
   {txphase(zero);
    shaped_pulse("H2Osinc", pwHs, zero, 5.0e-4, 0.0);
    obspower(tpwrd); obspwrf(4095.0);
    zgradpulse(gzlvl3, gt3);
    delay(2.0e-4);
    dec2rgpulse(pwN, zero, 0.0, 0.0);

    txphase(one);
    delay(kappa - pwHd - 2.0e-6 - PRG_START_DELAY);

    rgpulse(pwHd,one,0.0,0.0);
    txphase(zero);
    delay(2.0e-6);
    obsprgon("waltz16", pwHd, 90.0);	          /* PRG_START_DELAY */
    xmtron();
    decphase(zero);
    dec2phase(zero);
    decpwrf(rf8);
    delay(timeTN - kappa - WFG3_START_DELAY);
   }
							  /* WFG3_START_DELAY */
	sim3shaped_pulse("", "offC8", "", 0.0, pwC8, 2.0*pwN, zero, zero, zero, 
								     0.0, 0.0);
	decphase(t3);
	decpwrf(rf6);
	delay(timeTN);

	dec2rgpulse(pwN, zero, 0.0, 0.0);
if (TROSY[A]=='n')
   {xmtroff();
    obsprgoff();
    rgpulse(pwHd,three,2.0e-6,0.0);}
	zgradpulse(gzlvl3, gt3);
 	delay(2.0e-4);
	decshaped_pulse("offC6", pwC6, t3, 0.0, 0.0);
	decphase(zero);

/*   xxxxxxxxxxxxxxxxxxxxxx       13CO EVOLUTION        xxxxxxxxxxxxxxxxxx    */

if ((nli>1.0) && (tau1>0.0))          /* total 13C evolution equals d2 exactly */
   {				  /* 13C evolution during pwC6 is at 60% rate */
	decpwrf(rf3);
     if(tau1 - 0.6*pwC6 - WFG3_START_DELAY - 0.5*pwZ > 0.0)
	   {
	delay(tau1 - 0.6*pwC6 - WFG3_START_DELAY - 0.5*pwZ);
							  /* WFG3_START_DELAY */
	sim3shaped_pulse("", "offC3", "", 0.0, pwC3a, 2.0*pwN, zero, zero, zero,
							   	      0.0, 0.0);
	initval(phshift3, v3);
	decstepsize(1.0);
	dcplrphase(v3);  				        /* SAPS_DELAY */
	delay(tau1 - 0.6*pwC6 - SAPS_DELAY - 0.5*pwZ- WFG_START_DELAY - 2.0e-6);
	   }
      else
	   {
	initval(180.0, v3);
	decstepsize(1.0);
	dcplrphase(v3);  				        /* SAPS_DELAY */
	delay(2.0*tau1 - 2.0*0.6*pwC6 - SAPS_DELAY - WFG_START_DELAY - 2.0e-6);
	   }
   }


else if ((nli==1.0) && (pwC3==1.0e-6))        /* 13CO evolution for dof calib. */
   {
 	decpwrf(rf8);
	delay((1.0/(dfrq*80.0)) + 2.0e-6);		   /* WFG_START_DELAY */
	decshaped_pulse("offC8", pwC8, zero, 0.0, 0.0);
   }


else if (nli==1.0)         /* special 1D check of pwC3 phase enabled when nli=1 */
   {
	decpwrf(rf3);
	delay(10.0e-6 + SAPS_DELAY + 0.5*pwZ1 + WFG_START_DELAY);
							  /* WFG3_START_DELAY */
	sim3shaped_pulse("", "offC3", "", 0.0, pwC3, 2.0*pwN, zero, zero, zero, 
							         2.0e-6 , 0.0);
	initval(phshift3, v3);
	decstepsize(1.0);
	dcplrphase(v3);  					/* SAPS_DELAY */
	delay(10.0e-6 + WFG3_START_DELAY + 0.5*pwZ1);
   }


else             /* 13CO evolution refocused for 1st increment, or when nli=0  */
   {
 	decpwrf(rf8);
	delay(12.0e-6);					   /* WFG_START_DELAY */
	decshaped_pulse("offC8", pwC8, zero, 0.0, 0.0);
	delay(10.0e-6);
   }
	decphase(t5);
	decpwrf(rf6);
	delay(2.0e-6);					   /* WFG_START_DELAY */
	decshaped_pulse("offC6", pwC6, t5, 0.0, 0.0);

/*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 EVOLUTION    xxxxxxxxxxxxxxxxxxxxx  */

	dec2phase(t8);
	zgradpulse(gzlvl4, gt4);
	txphase(one);
	dcplrphase(zero);
 	delay(2.0e-4);
        if (TROSY[A]=='n')
	   {rgpulse(pwHd,one,0.0,0.0);
	    txphase(zero);
	    delay(2.0e-6);
	    obsprgon("waltz16", pwHd, 90.0);
	    xmtron();}
	dec2rgpulse(pwN, t8, 0.0, 0.0);

	decphase(zero);
	dec2phase(t9);
	decpwrf(rf8);
	delay(timeTN - WFG3_START_DELAY - tau2);
							 /* WFG3_START_DELAY  */
	sim3shaped_pulse("", "offC8", "", 0.0, pwC8, 2.0*pwN, zero, zero, t9, 
								   0.0, 0.0);

	dec2phase(t10);
        decpwrf(rf3);

if (TROSY[A]=='y')
{    if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.5e-4 + pwHs)
	{
	  txphase(three);
          delay(timeTN - pwC3a - WFG_START_DELAY);         /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.5e-4 - pwHs);
          if (mag_flg[A]=='y')  magradpulse(icosel*gzcal*gzlvl1, gt1);
          else  zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
          obspower(tpwrs);
          if (tpwrsf<4095.0)
	   {obspwrf(tpwrsf);				       /* POWER_DELAY */
	    delay(1.0e-4 - POWER_DELAY - PWRF_DELAY);}
          else
	   delay(1.0e-4 - POWER_DELAY);
   	  shaped_pulse("H2Osinc", pwHs, three, 0.0, 0.0);
	  txphase(t4);
          obspower(tpwr);
          if (tpwrsf<4095.0)
	   {obspwrf(4095.0);				       /* POWER_DELAY */
	    delay(0.50e-4 - POWER_DELAY - PWRF_DELAY);}
          else
	   delay(0.50e-4 - POWER_DELAY);
	}

    else if (tau2 > pwHs + 0.5e-4)
	{
	  txphase(three);
          delay(timeTN-pwC3a-WFG_START_DELAY-gt1-2.0*GRADIENT_DELAY-1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else  zgradpulse(icosel*gzlvl1, gt1);	   	/* 2.0*GRADIENT_DELAY */
          obspower(tpwrs);
          if (tpwrsf<4095.0)
	   {obspwrf(tpwrsf);				       /* POWER_DELAY */
	    delay(1.0e-4 - POWER_DELAY - PWRF_DELAY);}
          else
	   delay(1.0e-4 - POWER_DELAY);
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2 - pwHs - 0.5e-4);
   	  shaped_pulse("H2Osinc", pwHs, three, 0.0, 0.0);
	  txphase(t4);
          obspower(tpwr);
          if (tpwrsf<4095.0)
	   {obspwrf(4095.0);				       /* POWER_DELAY */
	    delay(0.50e-4 - POWER_DELAY - PWRF_DELAY);}
          else
	   delay(0.50e-4 - POWER_DELAY);
	}
    else
	{
	  txphase(three);
          delay(timeTN - pwC3a - WFG_START_DELAY - gt1 - 2.0*GRADIENT_DELAY
							    - 1.5e-4 - pwHs);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else  zgradpulse(icosel*gzlvl1, gt1);	   	/* 2.0*GRADIENT_DELAY */
          obspower(tpwrs);
          if (tpwrsf<4095.0)
	   {obspwrf(tpwrsf);				       /* POWER_DELAY */
	    delay(1.0e-4 - POWER_DELAY - PWRF_DELAY);}
          else
	   delay(1.0e-4 - POWER_DELAY);
   	  shaped_pulse("H2Osinc", pwHs, three, 0.0, 0.0);
	  txphase(t4);
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2);
          obspower(tpwr);
          if (tpwrsf<4095.0)
	   {obspwrf(4095.0);				       /* POWER_DELAY */
	    delay(0.50e-4 - POWER_DELAY - PWRF_DELAY);}
          else
	   delay(0.50e-4 - POWER_DELAY);
	 }
}
else
{
    if (tau2 > kappa)
	{
          delay(timeTN - pwC3a - WFG_START_DELAY);     	   /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
          delay(kappa - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else if (tau2 > (kappa - pwC3a - WFG_START_DELAY))
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);                                     /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(kappa -pwC3a -WFG_START_DELAY -gt1 -2.0*GRADIENT_DELAY -1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4)
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
          delay(kappa - tau2 - pwC3a - WFG_START_DELAY);   /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
	  obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
    	  delay(kappa-tau2-pwC3a-WFG_START_DELAY-gt1-2.0*GRADIENT_DELAY-1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);                    /* WFG_START_DELAY */
          decshaped_pulse("offC3", pwC3a, zero, 0.0, 0.0);
          delay(tau2);
	}
}                                                          
/*  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  */
	if (TROSY[A]=='y')  rgpulse(pw, t4, 0.0, 0.0);
	else                sim3pulse(pw, 0.0, pwN, t4, zero, t10, 0.0, 0.0);

	txphase(zero);
	dec2phase(zero);
	zgradpulse(gzlvl5, gt5);
	if (TROSY[A]=='y')   delay(lambda - 0.65*(pw + pwN) - gt5);
	else   delay(lambda - 1.3*pwN - gt5);

	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl5, gt5);
	txphase(one);
	dec2phase(t11);
	delay(lambda - 1.3*pwN - gt5);

	sim3pulse(pw, 0.0, pwN, one, zero, t11, 0.0, 0.0);

	txphase(zero);
	dec2phase(zero);
	zgradpulse(gzlvl6, gt5);
	delay(lambda - 1.3*pwN - gt5);

	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

	dec2phase(t10);
	zgradpulse(gzlvl6, gt5);
	if (TROSY[A]=='y')   delay(lambda - 1.6*pwN - gt5);
	else   delay(lambda - 0.65*pwN - gt5);

	if (TROSY[A]=='y')   dec2rgpulse(pwN, t10, 0.0, 0.0); 
	else    	     rgpulse(pw, zero, 0.0, 0.0); 

	delay((gt1/10.0) + 1.0e-4 +gstab - 0.5*pw + 2.0*GRADIENT_DELAY + POWER_DELAY);

	rgpulse(2.0*pw, zero, 0.0,0.0);
	dec2power(dpwr2);				       /* POWER_DELAY */
        if (mag_flg[A] == 'y')    magradpulse(gzcal*gzlvl2, gt1/10.0);
        else   zgradpulse(gzlvl2, gt1/10.0);            /* 2.0*GRADIENT_DELAY */
        delay(gstab);
        rcvron();
statusdelay(C,1.0e-4 );

	setreceiver(t12);
}		 
Exemplo n.º 5
0
pulsesequence()
{
/* DECLARE VARIABLES */

 char       fsat[MAXSTR],
	    fscuba[MAXSTR],
            f1180[MAXSTR],    /* Flag to start t1 @ halfdwell             */
            f2180[MAXSTR],    /* Flag to start t2 @ halfdwell             */
            Nterminus[MAXSTR], /*Flag to use BB 180 in place of reburp    */
            ch_plane[MAXSTR];    /* Flag to start t2 @ halfdwell             */

 int         phase, phase2, ni, ni2,
             t1_counter,   /* used for states tppi in t1           */ 
             t2_counter;   /* used for states tppi in t2           */ 

 double      tau1,         /*  t1 delay */
 	     tau2,         /*  t2 delay */
             taua,         /*  ~ 1/4JCH =  1.7 ms */
             taub,         /*  = 1/4JCH or 1/8JCH for editing */
             TC,           /*  ~ 1/2JCaCo =  9 ms */
             pw_ml,        /* PW90 for mlev 1H decoupling */
             pwN,          /* PW90 for 15N pulse  */
             pwC,          /* PW90 hard 13C pulse */
             pwc90,        /* PW90 for Ca or Co nucleus */
             pwc90a,       /* PW90 at d_c90a power level */
             pwreb180,     /* PW180 for reburp */
             pwcon180,     /* PW for Ca or Co on-res 180 */
             pwcoff180,    /* PW for Ca or Co off-res 180 */
             satpwr,      /* low level 1H trans.power for presat  */
             tpwrml,       /* power level for waltz decoupling */
             pwClvl,        /* power level for 13C pulses on dec1 - 64 us 
                              90 for part a of the sequence  */
             d_c90,        /* power level for pw90 on Ca or Co nucleus */
             d_c90a,       /* power level for pw90a*/
             d_c180,       /* power level for pw180 on Ca or Co nucleus */
             d_coff180,    /* power level for pbox pw180 of Co nucleus */
             d_reb,        /* power level for reburp 180 pulse */
             pwNlvl,       /* high dec2 pwr for 15N hard pulses    */
             waltzB1,      /* proton decoupling field */
             compH,        /* compression factor */
             compC,        /* compression factor */
             sw1,          /* sweep width in f1                    */             
             sw2,          /* sweep width in f2                    */             
             dof_coca,     /* offset between Co and Ca for comp180 at ~ 12.5 kHz */
             bw,ofs,ppm,   /* temporary Pbox parameters */
 

             gt0,
             gt1,
             gt2,
             gt3,
             gt4,
             gt5,
             gt6,
             gt7,
             gt8,
             gstab,
             gzlvl0,
             gzlvl1,
             gzlvl2,
             gzlvl4,
             gzlvl5,
             gzlvl7,
             gzlvl8; 

/* LOAD VARIABLES */


  getstr("fsat",fsat);
  getstr("fscuba",fscuba);
  getstr("f1180",f1180);
  getstr("f2180",f2180);
  getstr("ch_plane",ch_plane);
  getstr("Nterminus",Nterminus);

  taua   = getval("taua"); 
  taub   = getval("taub"); 
  TC   = getval("TC"); 
  pwN = getval("pwN");
  tpwr = getval("tpwr");
  satpwr = getval("satpwr");
  waltzB1 = getval("waltzB1");
  compH = getval("compH");
  compC = getval("compC");
  pwC = getval("pwC");
  pwClvl = getval("pwClvl");
  d_c180 = getval("d_c180");
  d_reb = getval("d_reb");
  dpwr = getval("dpwr");
  pwNlvl = getval("pwNlvl");
  phase = (int) ( getval("phase") + 0.5);
  phase2 = (int) ( getval("phase2") + 0.5);
  sw1 = getval("sw1");
  sw2 = getval("sw2");
  ni  = getval("ni");
  ni2  = getval("ni2");

  gt0 = getval("gt0");
  gt1 = getval("gt1");
  gt2 = getval("gt2");
  gt3 = getval("gt3");
  gt4 = getval("gt4");
  gt5 = getval("gt5");
  gt6 = getval("gt6");
  gt7 = getval("gt7");
  gt8 = getval("gt8");
  gstab = getval("gstab");

  gzlvl0 = getval("gzlvl0");
  gzlvl1 = getval("gzlvl1");
  gzlvl2 = getval("gzlvl2");
  gzlvl4 = getval("gzlvl4");
  gzlvl5 = getval("gzlvl5");
  gzlvl7 = getval("gzlvl7");
  gzlvl8 = getval("gzlvl8");

/* LOAD PHASE TABLE */

  settable(t1,1,phi1);
  settable(t2,4,phi2);
  settable(t3,2,phi3);
  settable(t4,16,phi4);
  settable(t5,1,phi5);
  settable(t6,8,rec);

   pwcon180 = 1/(2.0*(10900*(dfrq/150))) ;  /*  10.9kHz at 150 MHz 13C */
   d_c180 = pwClvl - 20.0*log10(pwcon180/(compC*2.0*pwC));
   d_c180 = (int) (d_c180 + 0.5);

   pwc90 = 1/(4.0 * (4700*(dfrq/150))) ;  /*  4.7kHz at 150 MHz 13C */
   d_c90 = pwClvl - 20.0*log10(pwc90/(compC*pwC));
   d_c90 = (int) (d_c90 + 0.5);

   pwc90a = 1/(4.0 * (15000*(dfrq/150))) ;  /*  15kHz at 150 MHz 13C */
   d_c90a = pwClvl - 20.0*log10(pwc90a/(compC*pwC));
   d_c90a = (int) (d_c90a + 0.5);

/* CHECK VALIDITY OF PARAMETER RANGES */

if( satpwr > 6 )
    {
        printf("TSATPWR too large !!!  ");
        psg_abort(1);
    }

    if( dpwr > 46 )
    {
        printf("don't fry the probe, DPWR too large!  ");
        psg_abort(1);
    }

    if( dpwr2 > 46 )
    {
        printf("don't fry the probe, DPWR2 too large!  ");
        psg_abort(1);
    }

 if( pwNlvl > 63 )
    {
        printf("don't fry the probe, DHPWR2 too large!  ");
        psg_abort(1);
    }

    if( pw > 200.0e-6 )
    {
        printf("dont fry the probe, pw too high ! ");
        psg_abort(1);
    }

    if( pwN > 200.0e-6 )
    {
        printf("dont fry the probe, pwN too high ! ");
        psg_abort(1);
    }

    if( pwC > 200.0e-6 )
    {
        printf("dont fry the probe, pwC too high ! ");
        psg_abort(1);
    }

/*  Phase incrementation for hypercomplex 2D & 3D data */

    if (phase == 2)
      tsadd(t3,1,4);

    if (phase2 == 2)
      tsadd(t5,1,4);

/*  Set up f1180  tau1 = t1               */
   
    tau1 = d2;
    if(f1180[A] == 'y') {
        tau1 += 1.0 / (2.0*sw1) - 4.0*pwC - 4.0*2.0e-6 - 2.0*(2.0/PI)*pwN ;
        if(tau1 < 0.4e-6) {
           tau1 = 0.4e-6;
           printf("tau1 is negative; decrease sw1 for proper phasing \n");
        }
    }
        tau1 = tau1/2.0;

/*  Set up f2180  tau2 = t2               */

    tau2 = d3;
    if(f2180[A] == 'y') {
        tau2 += ( 1.0 / (2.0*sw2));
    }

    tau2 = tau2 / 2.0;

/* Calculate modifications to phases for States-TPPI acquisition in t1 & t2  */

   if( ix == 1) d2_init = d2 ;
   t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5 );
   if(t1_counter % 2) {
      tsadd(t3,2,4);     
      tsadd(t6,2,4);    
    }

   if( ix == 1) d3_init = d3 ;
   t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 );
   if(t2_counter % 2) {
      tsadd(t5,2,4);     
      tsadd(t6,2,4);    
    }
  if (FIRST_FID)                                      /* call Pbox */
  {
          ppm = getval("dfrq");
          bw = 132.0*ppm; ofs = bw;                  /* carrier at 42ppm, inversion at 174ppm */
          spco180 = pbox_make("spco180","square180n", bw, ofs, compC*pwC, pwClvl);
          spreb180 = pbox_make("spreb180","reburp", 20*dfrq, -4*dfrq, compC*pwC, pwClvl);
  }
  pwcoff180=spco180.pw; d_coff180=spco180.pwrf;
  pwreb180=spreb180.pw; d_reb=spreb180.pwrf;

 if( gt0 > 10.0e-3 || gt1 > 10.0e-3 || gt2 > 10.0e-3 || gt3 >10.0e-3 ||
       gt4 > 10.0e-3 || gt5 > 10.0e-3 || gt6 > 10.0e-3 || gt7 > 10.0e-3 )
    {
        printf("gt values are too long. Must be < 10.0e-3\n");
        psg_abort(1);
    }

 if ((0.5*TC - 0.5*(ni2-1)/sw2 - pwcon180/2.0 - 2.0e-6 - pwcoff180 -2.0*2.0e-6 \
           - WFG_START_DELAY - WFG_STOP_DELAY - POWER_DELAY) < 0.4e-6)
    {
        printf("ni2 too large !\n");
        psg_abort(1);
    }

   
/* BEGIN ACTUAL PULSE SEQUENCE */

status(A);
   obsoffset(tof);
   decoffset(dof);
   dec2offset(dof2);
   obspower(satpwr);      /* Set transmitter power for 1H presaturation */
   decpower(d_c90a);        /* Set Dec1 power for hard 13C pulses         */
   dec2power(pwNlvl);      /* Set Dec2 power for 15N hard pulses         */

/* Presaturation Period */

   if (fsat[0] == 'y')
   {
	delay(2.0e-5);
        rgpulse(d1,zero,2.0e-6,2.0e-6); /* presaturation */
   	obspower(tpwr);      /* Set transmitter power for hard 1H pulses */
	delay(2.0e-5);
	if(fscuba[0] == 'y')
	{
		delay(2.2e-2);
		rgpulse(pw,zero,2.0e-6,0.0);
		rgpulse(2*pw,one,2.0e-6,0.0);
		rgpulse(pw,zero,2.0e-6,0.0);
		delay(2.2e-2);
	}
   }
   else
   {
    delay(d1);
   }
   obspower(tpwr);           /* Set transmitter power for hard 1H pulses */
   txphase(zero);
   dec2phase(zero);
   delay(1.0e-5);

/* Begin Pulses */

status(B);

   rcvroff();
   delay(20.0e-6);
   
   decrgpulse(pwc90a,zero,0.0,0.0);

   delay(0.2e-6);
   zgradpulse(gzlvl0,gt0);
   delay(gstab);

   rgpulse(pw,zero,0.0,0.0);                    /* 90 deg 1H pulse */

   zgradpulse(gzlvl1,gt1);

   delay(taua - gt1 );                /* taua <= 1/4JCH */ 

   simpulse(2*pw,2*pwc90a,zero,zero,0.0,0.0);
   
   txphase(t1); decphase(zero); 
   zgradpulse(gzlvl1,gt1);

   delay(taua - gt1 );                /* taua <= 1/4JCH */ 


   rgpulse(pw,t1,0.0,0.0);

   decpower(d_c90);

   zgradpulse(gzlvl2,gt2);
   delay(gstab);
/* Ca to N, while refocusing to H */
   decrgpulse(pwc90,zero,0.0,0.0);

   delay(taub/2.0);
   rgpulse(2.0*pw,zero,0.0,0.0);

   decpower(d_c180);

   delay(0.5*TC - taub/2.0 - 2.0*pw - POWER_DELAY  - 2.0*pwN - 2.0e-6);
   dec2rgpulse(2.0*pwN,zero,0.0,2.0e-6);
   decrgpulse(pwcon180,zero,0.0,0.0);
   delay(0.5*TC - POWER_DELAY );
 
   decphase(t2);
   decpower(d_c90);
   decrgpulse(pwc90,t2,0.0,0.0);

/* clean-up before proceeding */

   delay(2.0e-6);
   zgradpulse(gzlvl4,gt4);
     delay(gstab);

     decpower(d_c90a);
     dof_coca=dof+(110-42)*dfrq;     
     decoffset(dof_coca);	/* move C carrier to 110ppm for comp180 */
     decphase(one);

/* H decoupling on */
      pw_ml = 1/(4.0 * waltzB1) ;
        tpwrml = tpwr - 20.0*log10(pw_ml/(compH*pw));
        tpwrml = (int) (tpwrml + 0.5);

     obspower(tpwrml);
     rgpulse(pw_ml,one,2.0e-6,0.0);
     txphase(zero);
     delay(2.0e-6);
     obsprgon("waltz16",pw_ml,90.0);
     xmtron();
    
/* N evolution */

   dec2rgpulse(pwN,t3, 0.0, 2.0e-6);
   if(ch_plane[0] == 'y')
   {
     dec2phase(zero);
     delay(2.0e-6);
   }
   else {
       delay(tau1);
     decrgpulse(pwc90a, one, 0.0, 0.0);
     decrgpulse(2.0*pwc90a, zero, 2.0e-6, 2.0e-6);
     decrgpulse(pwc90a, one, 0.0, 0.0);
       dec2phase(zero);
       delay(tau1);
   }
   dec2rgpulse(pwN, zero, 2.0e-6, 0.0);

/* H decoupling off */
     xmtroff();
     obsprgoff();
     rgpulse(pw_ml,three,2.0e-6,2.0e-6);
     obspower(tpwr);

     decpower(d_c90);
     decoffset(dof);		/* move back C carrier */
     decphase(t5);

/* clean-up before proceeding */

   delay(20.0e-6);
   zgradpulse(gzlvl5,gt5);
   delay(gstab);

   decrgpulse(pwc90,t5,0.0,0.0);

/* refocus Ca-N and Ca-H couplings and constant time CA evolution */

     delay(0.5*TC - tau2 - pwcon180/2.0 - 2.0e-6 - pwcoff180 -2.0*2.0e-6 \
           - WFG_START_DELAY - WFG_STOP_DELAY - 3.0*POWER_DELAY );

     decphase(zero);
     decpower(pwClvl); decpwrf(d_coff180);
   simshaped_pulse("","spco180",2.0*pw,pwcoff180,zero,zero,2.0e-6,2.0e-6);	/* Bloch siegert correction */
     decpower(d_c180); decpwrf(4095.0);
   decrgpulse(pwcon180,t4,2.0e-6,2.0e-6);
   decpwrf(d_coff180); decpower(pwClvl);
   dec2rgpulse(2.0*pwN,zero,0.0,0.0);
     delay(tau2);
   decshaped_pulse("spco180", pwcoff180, zero, 2.0e-6, 2.0e-6);
     delay(taub/2.0);
   rgpulse(2.0*pw,zero,0.0,0.0);
     decpower(d_c90); decpwrf(4095.0);
     decphase(zero);
     delay(0.5*TC - taub/2.0 - 2.0*pw - 2.0e-6 -pwcon180/2 - 2.0*pwN - pwcoff180 \
          - 2.0*2.0e-6 - WFG_START_DELAY - WFG_STOP_DELAY \
          - 2.0*POWER_DELAY);

   decrgpulse(pwc90,zero,0.0,0.0);
 
   zgradpulse(gzlvl7,gt7);
   delay(gstab);

   rgpulse(pw,zero,0.0,0.0);

   zgradpulse(gzlvl8,gt8);
 
   txphase(zero);
   dec2phase(zero);
   if (Nterminus[A]=='y')
   {
    decpwrf(4095.0); decpower(pwClvl);
    delay(taua - 2.0*POWER_DELAY - gt8 - 0.5*pwC );
    simshaped_pulse("","",2.0*pw,2.0*pwC,zero,zero,0.0,0.0);	/* Purge all C outside 26-46 ppm */
    zgradpulse(gzlvl8,gt8);
    dec2power(dpwr2);    /* set power for 15N decoupling */
    decpower(dpwr);      /* set power for 13C decoupling */
    delay(taua - 0.5*pwreb180 - 2.0e-6 - gt8 - 2.0*POWER_DELAY);
   }
  else
   {
    decpwrf(d_reb); decpower(pwClvl);
    delay(taua - 2.0*POWER_DELAY - gt8 - 0.5*pwreb180 );
    simshaped_pulse("","spreb180",2.0*pw,pwreb180,zero,zero,0.0,0.0);	/* Purge all C outside 26-46 ppm */
    zgradpulse(gzlvl8,gt8);
    dec2power(dpwr2);    /* set power for 15N decoupling */
    decpower(dpwr);      /* set power for 13C decoupling */
    decpwrf(4095.0);
    delay(taua - 0.5*pwreb180 - 2.0e-6 - gt8 - 3.0*POWER_DELAY);
   }


   rgpulse(pw,zero,0.0,0.0);

/* BEGIN ACQUISITION */

status(C);
   setreceiver(t6);

}
Exemplo n.º 6
0
void pulsesequence()
{



/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
            mag_flg[MAXSTR],      /* magic-angle coherence transfer gradients */
 	    TROSY[MAXSTR],			    /* do TROSY on N15 and H1 */
	    CT_c[MAXSTR],
	    h1dec[MAXSTR];
 
int         icosel,          			  /* used to get n and p type */
            t1_counter=getval("t1_counter"),      /* used for states tppi in t1 */
            t2_counter=getval("t2_counter"),      /* used for states tppi in t2 */
            nli = getval("nli"),
            nli2 = getval("nli2");

double      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
	    tauCC = 7.0e-3, 		   /* delay for Ca to Cb cosy */
	    tauC = 13.3e-3,	           /* constantTime for 13Cb evolution */
            timeTN = getval("timeTN"),     /* constant time for 15N evolution */
	    kappa = 5.4e-3,
	    lambda = 2.4e-3,
	    zeta = 3.0e-3,
	    taud = 1.7e-3,
            
	pwClvl = getval("pwClvl"), 	        /* coarse power for C13 pulse */
        pwC = getval("pwC"),          /* C13 90 degree pulse length at pwClvl */
	rf0,            	  /* maximum fine power when using pwC pulses */

/* 90 degree pulse at Cab (46ppm), first off-resonance null at CO (174ppm)    */
        pwC1,		              /* 90 degree pulse length on C13 at rf1 */
        rf1,		       /* fine power for 5.1 kHz rf for 600MHz magnet */

/* 180 degree pulse at Ca (46ppm), first off-resonance null at CO(174ppm)     */
        pwC2,		                    /* 180 degree pulse length at rf2 */
        rf2,		      /* fine power for 11.4 kHz rf for 600MHz magnet */

/* the following pulse lengths for SLP pulses are automatically calculated    */
/* by the macro "proteincal".  SLP pulse shapes, "offC7" etc are called       */
/* directly from your shapelib.                    			      */
   pwC7 = getval("pwC7"),  /*180 degree pulse at CO(174ppm) null at Ca(56ppm) */
   pwC7a = getval("pwC7a"),    /* pwC7a=pwC7, but not set to zero when pwC7=0 */
   phshift7,            /* phase shift induced on Cab by pwC7 ("offC7") pulse */
   pwZ,					   /* the largest of pwC7 and 2.0*pwN */
   pwZ1,                /* the larger of pwC7a and 2.0*pwN for 1D experiments */
   rf7,	                           /* fine power for the pwC7 ("offC7") pulse */

/* the following pulse lengths for SLP pulses are automatically calculated    */
/* by the macro "proteincal".  SLP pulse shapes, "offC5" etc are called       */
/* directly from your shapelib.                                               */
   pwC5 = getval("pwC5"),  /*180 degree pulse at CO(174ppm) null at Ca(56ppm) */
   rf5,                            /* fine power for the pwC7 ("offC7") pulse */

/* g3 inversion pulse in the t1 period (centred at 150ppm)                     */
	pwCgCO_lvl = getval("pwCgCO_lvl"),
	pwCgCO = getval("pwCgCO"),



   compH = getval("compH"),       /* adjustment for C13 amplifier compression */
   compC = getval("compC"),       /* adjustment for C13 amplifier compression */

   	pwHs = getval("pwHs"),	        /* H1 90 degree pulse length at tpwrs */
   	tpwrs,	  	              /* power for the pwHs ("H2Osinc") pulse */

   	pwHd,	    		        /* H1 90 degree pulse length at tpwrd */
   	tpwrd,	  	                   /* rf for WALTZ decoupling */
        waltzB1 = getval("waltzB1"),  /* waltz16 field strength (in Hz)     */

	pwNlvl = getval("pwNlvl"),	              /* power for N15 pulses */
        pwN = getval("pwN"),          /* N15 90 degree pulse length at pwNlvl */

	sw1 = getval("sw1"),
	sw2 = getval("sw2"),

        gstab = getval("gstab"),
	gt1 = getval("gt1"),  		       /* coherence pathway gradients */
        gzcal = getval("gzcal"),             /* g/cm to DAC conversion factor */
	gzlvl1 = getval("gzlvl1"),
	gzlvl2 = getval("gzlvl2"),

	gt0 = getval("gt0"),				   /* other gradients */
	gt3 = getval("gt3"),
	gt4 = getval("gt4"),
	gt5 = getval("gt5"),
	gt7 = getval("gt7"),
	gt8 = getval("gt8"),
	gzlvl0 = getval("gzlvl0"),
	gzlvl3 = getval("gzlvl3"),
	gzlvl4 = getval("gzlvl4"),
	gzlvl5 = getval("gzlvl5"),
	gzlvl6 = getval("gzlvl6"),
	gzlvl7 = getval("gzlvl7"),
	gzlvl8 = getval("gzlvl8");

    getstr("f1180",f1180);
    getstr("f2180",f2180);
    getstr("mag_flg",mag_flg);
    getstr("TROSY",TROSY);
    getstr("CT_c",CT_c);
    getstr("h1dec",h1dec);



/*   LOAD PHASE TABLE    */

	settable(t2,1,phy);
	settable(t3,2,phi3);
	settable(t4,1,phx);
	settable(t5,4,phi5);
   if (TROSY[A]=='y')
       {settable(t8,1,phy);
	settable(t9,1,phx);
 	settable(t10,1,phy);
	settable(t11,1,phx);
	settable(t12,4,recT);}
    else
       {settable(t8,1,phx);
	settable(t9,8,phi9);
	settable(t10,1,phx);
	settable(t11,1,phy);
	settable(t12,4,rec);}




/*   INITIALIZE VARIABLES   */

    if( dpwrf < 4095 )
	{ printf("reset dpwrf=4095 and recalibrate C13 90 degree pulse");
	  psg_abort(1); }

    /* maximum fine power for pwC pulses */
	rf0 = 4095.0;

    /* 90 degree pulse on Cab, null at CO 128ppm away */
	pwC1 = sqrt(15.0)/(4.0*128.0*dfrq);
        rf1 = (compC*4095.0*pwC)/pwC1;
	rf1 = (int) (rf1 + 0.5);

    /* 180 degree pulse on Cab, null at CO 128ppm away */
        pwC2 = sqrt(3.0)/(2.0*128.0*dfrq);
	rf2 = (4095.0*compC*pwC*2.0)/pwC2;
	rf2 = (int) (rf2 + 0.5);	
	if( rf2 > 4095 )
	      { printf("Recalibrate so that C13 90 <22us*600/sfrq"); psg_abort(1);}

    /* 180 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */
	rf7 = (compC*4095.0*pwC*2.0*1.65)/pwC7a; /* needs 1.65 times more     */
	rf7 = (int) (rf7 + 0.5);		 /* power than a square pulse */

    /* 90 degree one-lobe sinc pulse on CO, null at Ca 118ppm away */
        rf5 = (compC*4095.0*pwC*1.69)/pwC5;     /* needs 1.69 times more     */
        rf5 = (int) (rf5 + 0.5);                /* power than a square pulse */

    /* the pwC7 pulse at the middle of t1  */
        if ((nli2 > 0.0) && (nli == 1.0)) nli = 0.0;
        if (pwC7a > 2.0*pwN) pwZ = pwC7a; else pwZ = 2.0*pwN;
        if ((pwC7==0.0) && (pwC7a>2.0*pwN)) pwZ1=pwC7a-2.0*pwN; else pwZ1=0.0;
	if ( nli > 1 )     pwC7 = pwC7a;
	if ( pwC7 > 0 )   phshift7 = 320.0;
	else              phshift7 = 0.0;
	
    /* selective H20 one-lobe sinc pulse */
    tpwrs = tpwr - 20.0*log10(pwHs/(compH*pw*1.69)); /* needs 1.69 times more */
    tpwrs = (int) (tpwrs);                       /* power than a square pulse */

    /* power level and pulse time for WALTZ 1H decoupling */
	pwHd = 1/(4.0 * waltzB1) ;                          
	tpwrd = tpwr - 20.0*log10(pwHd/(compH*pw));
	tpwrd = (int) (tpwrd + 0.5);
 


/* CHECK VALIDITY OF PARAMETER RANGES */


    if ( 0.5*nli2*1/(sw2) > timeTN - WFG3_START_DELAY)
       { printf(" nli2 is too big. Make nli2 equal to %d or less.\n", 
  	 ((int)((timeTN - WFG3_START_DELAY)*2.0*sw2))); psg_abort(1);}

    if ( dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' )
       { printf("incorrect dec1 decoupler flags! Should be 'nnn' "); psg_abort(1);}

    if ( dm2[A] == 'y' || dm2[B] == 'y' )
       { printf("incorrect dec2 decoupler flags! Should be 'nny' "); psg_abort(1);}

    if ( dm3[A] == 'y' || dm3[C] == 'y' )
       { printf("incorrect dec3 decoupler flags! Should be 'nyn' or 'nnn' ");
							             psg_abort(1);}	
    if ( dpwr2 > 46 )
       { printf("dpwr2 too large! recheck value  "); psg_abort(1);}

    if ( pw > 20.0e-6 )
       { printf(" pw too long ! recheck value "); psg_abort(1);} 
  
    if ( pwN > 100.0e-6 )
       { printf(" pwN too long! recheck value "); psg_abort(1);} 
 
    if ( TROSY[A]=='y' && dm2[C] == 'y')
       { text_error("Choose either TROSY='n' or dm2='n' ! "); psg_abort(1);}



/* PHASES AND INCREMENTED TIMES */

/*  Phase incrementation for hypercomplex 2D data, States-Haberkorn element */

    if (phase1 == 2)   { tsadd(t3,1,4); tsadd(t2,1,4);} 
    if (TROSY[A]=='y')
	 {  if (phase2 == 2)   				      icosel = +1;
            else 	    {tsadd(t4,2,4);  tsadd(t10,2,4);  icosel = -1;}
	 }
    else {  if (phase2 == 2)  {tsadd(t10,2,4); icosel = +1;}
            else 			       icosel = -1;    
	 }


/*  Set up f1180  */
   
    if( ix == 1) d2_init = d2;
    tau1 = d2_init + (t1_counter) / sw1;
    if((f1180[A] == 'y') && (nli > 1.0)) 
	{ tau1 += ( 1.0 / (2.0*sw1) ); if(tau1 < 0.2e-6) tau1 = 0.0; }
    tau1 = tau1/2.0;


/*  Set up f2180  */

    if( ix == 1) d3_init = d3;
    tau2 = d3_init + (t2_counter) / sw2;
    if((f2180[A] == 'y') && (nli2 > 1.0)) 
	{ tau2 += ( 1.0 / (2.0*sw2) ); if(tau2 < 0.2e-6) tau2 = 0.0; }
    tau2 = tau2/2.0;



/* Calculate modifications to phases for States-TPPI acquisition          */

   if(t1_counter % 2) 
	{ tsadd(t3,2,4); tsadd(t12,2,4); }

   if(t2_counter % 2) 
	{ tsadd(t8,2,4); tsadd(t12,2,4); }



/* BEGIN PULSE SEQUENCE */

status(A);
delay(d1);
if (dm3[B] == 'y') lk_hold();

rcvroff();
obspower(tpwr);
decpower(pwClvl);
dec2power(pwNlvl);
decpwrf(rf0);
obsoffset(tof);
txphase(zero);
decphase(zero);
dcplrphase(zero);
delay(1.0e-5);

dec2rgpulse(pwN, zero, 0.0, 0.0);  /*destroy N15 and C13 magnetization*/
decrgpulse(pwC, zero, 0.0, 0.0);
zgradpulse(gzlvl0, 0.5e-3);
delay(1.0e-4);
dec2rgpulse(pwN, one, 0.0, 0.0);
decrgpulse(pwC, zero, 0.0, 0.0);
zgradpulse(0.7*gzlvl0, 0.5e-3);
delay(5.0e-4);

rgpulse(pw,zero,0.0,0.0);                      /* 1H pulse excitation */

dec2phase(zero);
zgradpulse(gzlvl0, gt0);
delay(lambda - gt0);

sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

txphase(one);
zgradpulse(gzlvl0, gt0);
delay(lambda - gt0);

rgpulse(pw, one, 0.0, 0.0);

obspower(tpwrs);
if (TROSY[A]=='y') {
  txphase(two);
  shaped_pulse("H2Osinc", pwHs, two, 5.0e-4, 0.0);
  obspower(tpwr);
  zgradpulse(gzlvl3, gt3);
  delay(2.0e-4);
  dec2rgpulse(pwN, zero, 0.0, 0.0);

  delay(0.5*kappa - 2.0*pw);

  rgpulse(2.0*pw, two, 0.0, 0.0);

  obspower(tpwrd);	  				       /* POWER_DELAY */
  decphase(zero);
  dec2phase(zero);
  decpwrf(rf7);
  delay(timeTN - 0.5*kappa - POWER_DELAY -WFG_START_DELAY);
}
else {
  txphase(zero);
  shaped_pulse("H2Osinc", pwHs, zero, 5.0e-4, 0.0);
  obspower(tpwrd);
  zgradpulse(gzlvl3, gt3);
  delay(2.0e-4);
  dec2rgpulse(pwN, zero, 0.0, 0.0);

  txphase(one);
  delay(kappa - pwHd - 2.0e-6 - PRG_START_DELAY);

  rgpulse(pwHd,one,0.0,0.0);
  txphase(zero);
  delay(2.0e-6);
  obsprgon("waltz16", pwHd, 90.0);	          /* PRG_START_DELAY */
  xmtron();
  decphase(zero);
  dec2phase(zero);
  decpwrf(rf7);
  delay(timeTN - kappa -WFG_START_DELAY);
}

sim3shaped_pulse("","offC7","",0.0, pwC7, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

decphase(t3);
decpwrf(rf5);
delay(timeTN -WFG_STOP_DELAY -pwHd);

dec2rgpulse(pwN, zero, 0.0, 0.0);

if (TROSY[A]=='n') {
  xmtroff();
  obsprgoff();
  rgpulse(pwHd,three,2.0e-6,0.0);
}

delay(2.0e-6);
zgradpulse(gzlvl3, gt3);
delay(2.0e-4);

decpwrf(rf5); 
decshaped_pulse("offC5", pwC5, zero, 0.0, 0.0);
delay(2.0e-6);

zgradpulse(-gzlvl7, gt7);
decpwrf(rf0);
decphase(zero);
delay(zeta - gt7 - 0.5*10.933*pwC-2.0e-6);

  decrgpulse(pwC*158.0/90.0, zero, 0.0, 0.0);
  decrgpulse(pwC*171.2/90.0, two, 0.0, 0.0);
  decrgpulse(pwC*342.8/90.0, zero, 0.0, 0.0);      /* Shaka 6 composite */
  decrgpulse(pwC*145.5/90.0, two, 0.0, 0.0);
  decrgpulse(pwC*81.2/90.0, zero, 0.0, 0.0);
  decrgpulse(pwC*85.3/90.0, two, 0.0, 0.0);

delay(2.0e-6);
zgradpulse(-gzlvl7, gt7);
decpwrf(rf5);
decphase(one);
txphase(one);
delay(zeta - gt7 - 0.5*10.933*pwC - WFG_START_DELAY-2.0e-6);
                                                           /* WFG_START_DELAY */
decshaped_pulse("offC5", pwC5, one, 0.0, 0.0);

delay(2.0e-6);
zgradpulse(1.33*gzlvl3,gt3);
delay(200.0e-6);

if(dm3[B] == 'y'){                        /*optional 2H decoupling on */
  dec3unblank();
  dec3rgpulse(1/dmf3, one, 0.0, 0.0);
  dec3unblank();
  setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
}

decpwrf(rf1);
decphase(t2);
txphase(one);

if (h1dec[A]=='y') {
  rgpulse(pwHd,one,0.0,0.0);
  txphase(zero);
  delay(2.0e-6);
  obsprgon("waltz16", pwHd, 90.0);                   /* PRG_START_DELAY */
  xmtron();
}

decrgpulse(pwC1, t3, 0.0, 0.0);
decphase(zero);

decpwrf(rf2);
delay(tauCC -gt5 -202.0e-6 -POWER_DELAY- pwHd -PRG_STOP_DELAY -1/dmf3
                                            -2.0e-6 - WFG_STOP_DELAY);

if(dm3[B] == 'y') {                     /*optional 2H decoupling off */
  dec3rgpulse(1/dmf3, three, 0.0, 0.0);
  dec3blank();
  setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
  dec3blank();
}
else delay(1/dmf3 +WFG_STOP_DELAY);
 
if(h1dec[A]=='y') {
  xmtroff();
  obsprgoff();                                        /* PRG_STOP_DELAY */
  rgpulse(pwHd,three,2.0e-6,0.0);
}
else delay(pwHd +2.0e-6 +PRG_STOP_DELAY);
  
delay(2.0e-6);
zgradpulse(-gzlvl5, gt5);
delay(200.0e-6);

decrgpulse(pwC2,zero,0.0,0.0);

delay(2.0e-6);
zgradpulse(-gzlvl5, gt5);
delay(200.0e-6);
decpwrf(rf1);

if(h1dec[A]=='y'){
  rgpulse(pwHd,one,0.0,0.0);
  txphase(zero);
  delay(2.0e-6);
  obsprgon("waltz16", pwHd, 90.0);                /* PRG_START_DELAY */
  xmtron();
}
else delay(pwHd+2.0e-6+PRG_START_DELAY);

if(dm3[B] == 'y'){                        /*optional 2H decoupling on */
  dec3unblank();
  dec3rgpulse(1/dmf3, one, 0.0, 0.0);
  dec3unblank();
  setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
}
else delay(1/dmf3+WFG_START_DELAY);

delay(tauCC -gt5 -202.0e-6 -POWER_DELAY -1/dmf3 -WFG_START_DELAY
		-POWER_DELAY -pwHd -2.0e-6 -PRG_START_DELAY
		-pwHd-2.0e-6-PRG_STOP_DELAY);

if((h1dec[A]=='y') && (h1dec[B]=='n')) {
  xmtroff();
  obsprgoff();                                    /* PRG_STOP_DELAY */
  rgpulse(pwHd,one,2.0e-6,0.0);
  decrgpulse(pwC1,t2,0.0,0.0);
}
else {
  delay(pwHd+2.0e-6+PRG_STOP_DELAY-POWER_DELAY);
  if ((h1dec[A]=='y')&&(h1dec[B]=='y')) {
    delay(POWER_DELAY);
    decrgpulse(pwC1,t2,0.0,0.0);
  }
  if ((h1dec[A]=='n')&&(h1dec[B]=='n')) {
    obspower(tpwr);
    simpulse(2.0*pw,pwC1,two,t2,0.0,0.0);  /* Assuming 2.0*pw < pwC1 */
  }
}
/* It could be h1dec='ny' ??? */	

/*   xxxxxxxxxxxxxxxxxxxxxx       13Cb EVOLUTION       xxxxxxxxxxxxxxxxxx    */

if (CT_c[0]=='n') {
  if ((nli>1.0) && (tau1>0.0)) {     /* total 13C evolution equals d2 exactly */
            /* 2.0*pwC1/PI compensates for evolution at 64% rate during pwC1 */
    decpwrf(rf7);
    if(tau1 - 2.0*pwC1/PI - WFG3_START_DELAY - 0.5*pwZ > 0.0) {
      delay(tau1 - 2.0*pwC1/PI - WFG3_START_DELAY - 0.5*pwZ);
							  /* WFG3_START_DELAY */
      sim3shaped_pulse("", "offC7", "", 0.0, pwC7a, 2.0*pwN, zero, zero, zero,
								      0.0, 0.0);
      initval(phshift7, v7);
      decstepsize(1.0);
      dcplrphase(v7);  				        /* SAPS_DELAY */
      delay(tau1 - 2.0*pwC1/PI  - SAPS_DELAY - 0.5*pwZ - 2.0e-6);
    }
    else {
      initval(180.0, v7);
      decstepsize(1.0);
      dcplrphase(v7);  				        /* SAPS_DELAY */
      delay(2.0*tau1 - 4.0*pwC1/PI - SAPS_DELAY - 2.0e-6);
    }
  }

  else if (nli==1.0) {    /* special 1D check of pwC7 phase enabled when nli=1 */
 	 decpwrf(rf7);
	 delay(10.0e-6 + SAPS_DELAY + 0.5*pwZ1 + WFG_START_DELAY);
							  /* WFG3_START_DELAY */
	 sim3shaped_pulse("", "offC7", "", 0.0, pwC7, 2.0*pwN, zero, zero, zero,
							          2.0e-6, 0.0);
	 initval(phshift7, v7);
	 decstepsize(1.0);
	 dcplrphase(v7);  					/* SAPS_DELAY */
	 delay(10.0e-6 + WFG3_START_DELAY + 0.5*pwZ1);
      }

      else{		       /* 13Ca evolution refocused for 1st increment  */
	decpwrf(rf2);
	decrgpulse(pwC2, zero, 2.0e-6, 0.0);
      }
}  /* H1 dec. and H2 dec. status are not changed through nonCT evolution*/

else {		/* 13C CONSTANT TIME EVOLUTION */
  decpwrf(rf0);
  decpower(pwCgCO_lvl);
  if(h1dec[B]=='y') {
    if(tau1 - 2.0*pwC1/PI -WFG_START_DELAY -2*POWER_DELAY> 0.0) 
      delay(tau1 - 2.0*pwC1/PI -WFG_START_DELAY - 2*POWER_DELAY);
    decshaped_pulse("CgCO1",pwCgCO,zero,0.0,0.0);
    delay(tauC -gt8 -202.0e-6 -pwHd -2.0e-6 -PRG_STOP_DELAY
			-pwCgCO -pwC2 -WFG_STOP_DELAY-1/dmf3);

    if(dm3[B] == 'y') {                     /*optional 2H decoupling off */
      dec3rgpulse(1/dmf3, three, 0.0, 0.0);
      dec3blank();
      setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
      dec3blank();
    }
    else delay(1/dmf3+WFG_STOP_DELAY); 
    xmtroff();
    obsprgoff();                                        /* PRG_STOP_DELAY */
    rgpulse(pwHd,three,2.0e-6,0.0);
  }
  if ((h1dec[B]=='n')&&(dm3[B]=='n')) {
    obspower(tpwr);
    if(tau1 - 2.0*pwC1/PI -WFG_START_DELAY -3*POWER_DELAY> 0.0) {
      delay(tau1 - 2.0*pwC1/PI -WFG3_START_DELAY - 3*POWER_DELAY);
      simshaped_pulse("","CgCO1",2.0*pw,pwCgCO,two,zero,0.0,0.0);
    }
    else simshaped_pulse("","CgCO1",2.0*pw,pwCgCO,two,zero,0.0,0.0);
    obspower(tpwrd);
    delay(tauC -gt8 -202.0e-6 -pwCgCO -pwC2 -POWER_DELAY);
  }
  if ((h1dec[B]=='n')&&(dm3[B]=='y')) {
    obspower(tpwr);
    if(tau1 - 2.0*pwC1/PI - WFG_START_DELAY -3*POWER_DELAY> 0.0) {
      delay(tau1 - 2.0*pwC1/PI - WFG3_START_DELAY - 3*POWER_DELAY);
      decshaped_pulse("CgCO1",pwCgCO,zero,0.0,0.0);
    }
    else decshaped_pulse("CgCO1",pwCgCO,zero,0.0,0.0);
    delay(taud-0.5*pwC2-WFG_START_DELAY-WFG_STOP_DELAY-pwCgCO);
    rgpulse(2.0*pw,two,0.0,0.0);
    obspower(tpwrd);
    delay(tauC -taud -gt8 -202e-6 -2.0*pw -POWER_DELAY -1/dmf3
	-pwCgCO -pwC2 -WFG_STOP_DELAY);
    dec3rgpulse(1/dmf3, three, 0.0, 0.0);
    dec3blank();
    setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
    dec3blank();
  }

  delay(2.0e-6);
  zgradpulse(gzlvl8,gt8);
  delay(200.0e-6-2*POWER_DELAY);
  decpower(pwClvl);decpwrf(rf2);

  decrgpulse(pwC2,zero,0.0,0.0);

  delay(2.0e-6);
  zgradpulse(gzlvl8,gt8);        
  delay(200.0e-6-2*POWER_DELAY);

  decpower(pwCgCO_lvl);decpwrf(rf0);

  if(h1dec[A]=='y'){
    rgpulse(pwHd,one,0.0,0.0);
    txphase(zero);
    delay(2.0e-6);
    obsprgon("waltz16", pwHd, 90.0);                /* PRG_START_DELAY */
    xmtron();
  }
  else delay(pwHd+ 2.0e-6 +PRG_START_DELAY);

  if(dm3[B] == 'y'){                        /*optional 2H decoupling on */
    dec3unblank();
    dec3rgpulse(1/dmf3, one, 0.0, 0.0);
    dec3unblank();
    setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
  }
  else delay(1/dmf3+WFG_START_DELAY);

  delay(tauC -tau1 -202.0e-6 -gt8 -pwCgCO -WFG_START_DELAY
	-WFG_STOP_DELAY -POWER_DELAY -1/dmf3 -WFG_START_DELAY
	-pwHd -2.0e-6 -PRG_START_DELAY);
  decshaped_pulse("CgCO2",pwCgCO,zero,0.0,0.0);
}		/* END of C13 CONSTANT TIME EVOLUTION */

decphase(one);
decpower(pwClvl); 
decpwrf(rf1);

decrgpulse(pwC1, one, 2.0e-6, 0.0);
delay(tauCC - gt5 -202.0e-6 -2.0e-6 -pwHd -PRG_STOP_DELAY
				-1/dmf3 -WFG_STOP_DELAY);

if(dm3[B] == 'y') {                     /*optional 2H decoupling off */
  dec3rgpulse(1/dmf3, three, 0.0, 0.0);
  dec3blank();
  setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
  dec3blank();
}
else delay(1/dmf3+WFG_STOP_DELAY);

if(h1dec[B]=='y') {
  xmtroff();
  obsprgoff();                                      /* PRG_STOP_DELAY */
  rgpulse(pwHd,three,2.0e-6,0.0);
}
else delay(2.0e-6+pwHd+PRG_STOP_DELAY);

delay(2.0e-6);
zgradpulse(gzlvl5*1.33, gt5);
delay(200.0e-6-2.0*POWER_DELAY);
decpwrf(rf2);
decphase(zero);

decrgpulse(pwC2, zero, 0.0, 0.0);

delay(2.0e-6);
zgradpulse(gzlvl5*1.33,gt5);
delay(200.0e-6-2.0*POWER_DELAY);
decpwrf(rf1);
decphase(t5);

if(h1dec[A]=='y'){
  rgpulse(pwHd,one,0.0,0.0);
  txphase(zero);
  delay(2.0e-6);
  obsprgon("waltz16", pwHd, 90.0);                /* PRG_START_DELAY */
  xmtron();
}
else delay(pwHd+ 2.0e-6 +PRG_START_DELAY);

if(dm3[B] == 'y'){                        /*optional 2H decoupling on */
  dec3unblank();
  dec3rgpulse(1/dmf3, one, 0.0, 0.0);
  dec3unblank();
  setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
}
else delay(1/dmf3+WFG_START_DELAY);


delay(tauCC - gt5 -202.0e-6 -1/dmf3 -WFG_START_DELAY -2.0e-6 -pwHd 
						-PRG_START_DELAY);

/*decrgpulse(pwC1, t5, 0.0, 0.0); */
decrgpulse(pwC1, zero, 0.0, 0.0); 

decpwrf(rf5);
decshaped_pulse("offC5", pwC5, one, 0.0, 0.0);

delay(zeta - gt7 -202.0e-6 - pwHd -2.0e-6 -PRG_STOP_DELAY
      -1/dmf3 -WFG_STOP_DELAY -0.5*10.933*pwC-2.0e-6);

if(dm3[B] == 'y') {                     /*optional 2H decoupling off */
  dec3rgpulse(1/dmf3, three, 0.0, 0.0);
  dec3blank();
  setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
  dec3blank();
}
else delay(1/dmf3+WFG_STOP_DELAY);

if(h1dec[A]=='y') {
  xmtroff();
  obsprgoff();                                      /* PRG_STOP_DELAY */
  rgpulse(pwHd,three,2.0e-6,0.0);
}
else delay(2.0e-6+pwHd+PRG_STOP_DELAY);

delay(2.0e-6);
zgradpulse(-gzlvl7, gt7);
decpwrf(rf0);
decphase(zero);
delay(200.0e-6-2.0*POWER_DELAY);

  decrgpulse(pwC*158.0/90.0, zero, 0.0, 0.0);
  decrgpulse(pwC*171.2/90.0, two, 0.0, 0.0);
  decrgpulse(pwC*342.8/90.0, zero, 0.0, 0.0);      /* Shaka 6 composite */
  decrgpulse(pwC*145.5/90.0, two, 0.0, 0.0);
  decrgpulse(pwC*81.2/90.0, zero, 0.0, 0.0);
  decrgpulse(pwC*85.3/90.0, two, 0.0, 0.0);

delay(2.0e-6);
zgradpulse(-gzlvl7, gt7);
delay(200.0e-6);
decpwrf(rf5);
decphase(one);
txphase(one);

if(h1dec[A]=='y'){
  rgpulse(pwHd,one,0.0,0.0);
  txphase(zero);
  delay(2.0e-6);
  obsprgon("waltz16", pwHd, 90.0);                /* PRG_START_DELAY */
  xmtron();
}
else delay(pwHd+ 2.0e-6 +PRG_START_DELAY);

if(dm3[B] == 'y'){                        /*optional 2H decoupling on */
  dec3unblank();
  dec3rgpulse(1/dmf3, one, 0.0, 0.0);
  dec3unblank();
  setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
}
else delay(1/dmf3+WFG_START_DELAY);

delay(zeta - gt7 - 0.5*10.933*pwC - WFG_START_DELAY-2.0e-6
	-1/dmf3 -WFG_START_DELAY -pwHd -2.0e-6 -PRG_START_DELAY);
                                                           /* WFG_START_DELAY */
decshaped_pulse("offC5", pwC5, t5, 0.0, 0.0);


/*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 EVOLUTION    xxxxxxxxxxxxxxxxxxxxx  */

dec2phase(t8);
txphase(one);
dcplrphase(zero);
obspower(tpwrd);

if(dm3[B] == 'y')  {                     /*optional 2H decoupling off */
  dec3rgpulse(1/dmf3, three, 0.0, 0.0);
  dec3blank();
  setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
  dec3blank();
}

if(h1dec[A]=='y') { 
  xmtroff();
  obsprgoff();                                      /* PRG_STOP_DELAY */
  rgpulse(pwHd,three,2.0e-6,0.0);
}

zgradpulse(gzlvl4, gt4);
delay(2.0e-4);

if (TROSY[A]=='n') {
  rgpulse(pwHd,one,0.0,0.0);
  txphase(zero);
  delay(2.0e-6);
  obsprgon("waltz16", pwHd, 90.0);
  xmtron();
}

dec2rgpulse(pwN, t8, 0.0, 0.0);

decphase(zero);
dec2phase(t9);
decpwrf(rf7);
delay(timeTN - tau2);

sim3shaped_pulse("","offC7","",0.0, pwC7, 2.0*pwN, zero, zero, t9, 0.0, 0.0);

dec2phase(t10);
decpwrf(rf5);

if (TROSY[A]=='y')
{    if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.5e-4 + pwHs)
	{
	  txphase(three);
          delay(timeTN - pwC2) ;         /* WFG_START_DELAY */
          decrgpulse(pwC2, zero, 0.0, 0.0);
          delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.5e-4 - pwHs);
          if (mag_flg[A]=='y')  magradpulse(icosel*gzcal*gzlvl1, gt1);
          else  zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwrs);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
   	  shaped_pulse("H2Osinc", pwHs, three, 0.0, 0.0);
	  txphase(t4);
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(0.5e-4 - POWER_DELAY);
	}

    else if (tau2 > pwHs + 0.5e-4)
	{
	  txphase(three);
          delay(timeTN-pwC2-gt1-2.0*GRADIENT_DELAY-1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else  zgradpulse(icosel*gzlvl1, gt1);	   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwrs);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);                     /* WFG_START_DELAY */
          decrgpulse(pwC2, zero, 0.0, 0.0);
          delay(tau2 - pwHs - 0.5e-4);
   	  shaped_pulse("H2Osinc", pwHs, three, 0.0, 0.0);
	  txphase(t4);
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(0.5e-4 - POWER_DELAY);
	}
    else
	{
	  txphase(three);
          delay(timeTN - pwC2 - gt1 - 2.0*GRADIENT_DELAY
							    - 1.5e-4 - pwHs);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else  zgradpulse(icosel*gzlvl1, gt1);	   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwrs);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);                     /* WFG_START_DELAY */
   	  shaped_pulse("H2Osinc", pwHs, three, 0.0, 0.0);
	  txphase(t4);
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(0.5e-4 - POWER_DELAY);
          decrgpulse(pwC2, zero, 0.0, 0.0);
          delay(tau2);
	}
}
else
{
    if (tau2 > kappa)
	{
          delay(timeTN - pwC2);     	   /* WFG_START_DELAY */
          decrgpulse(pwC2, zero, 0.0, 0.0);
          delay(tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
          delay(kappa - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else if (tau2 > (kappa - pwC2))
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);                                     /* WFG_START_DELAY */
          decrgpulse(pwC2, zero, 0.0, 0.0);
          delay(kappa -pwC2 -gt1 -2.0*GRADIENT_DELAY -1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4)
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
          delay(kappa - tau2 - pwC2 );   /* WFG_START_DELAY */
          decrgpulse(pwC2, zero, 0.0, 0.0);
          delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);
	}
    else
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY - pwHd - 2.0e-6);
          xmtroff();
	  obsprgoff();					    /* PRG_STOP_DELAY */
	  rgpulse(pwHd,three,2.0e-6,0.0);
	  txphase(t4);
    	  delay(kappa-tau2-pwC2-gt1-2.0*GRADIENT_DELAY-1.0e-4);
          if (mag_flg[A]=='y')    magradpulse(icosel*gzcal*gzlvl1, gt1);
          else    zgradpulse(icosel*gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	  obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);                    /* WFG_START_DELAY */
          decrgpulse(pwC2, zero, 0.0, 0.0);
          delay(tau2);
	}
}
/*  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  */
	if (TROSY[A]=='y')  rgpulse(pw, t4, 0.0, 0.0);
	else                sim3pulse(pw, 0.0, pwN, t4, zero, t10, 0.0, 0.0);

	txphase(zero);
	dec2phase(zero);
	zgradpulse(gzlvl5, gt5);
	if (TROSY[A]=='y')   delay(lambda - 0.65*(pw + pwN) - gt5);
	else   delay(lambda - 1.3*pwN - gt5);

	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl5, gt5);
	txphase(one);
	dec2phase(t11);
	delay(lambda - 1.3*pwN - gt5);

	sim3pulse(pw, 0.0, pwN, one, zero, t11, 0.0, 0.0);

	txphase(zero);
	dec2phase(zero);
	zgradpulse(gzlvl6, gt5);
	delay(lambda - 1.3*pwN - gt5);

	sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);

	dec2phase(t10);
	zgradpulse(gzlvl6, gt5);
	if (TROSY[A]=='y')   delay(lambda - 1.6*pwN - gt5);
	else   delay(lambda - 0.65*pwN - gt5);

	if (TROSY[A]=='y')   dec2rgpulse(pwN, t10, 0.0, 0.0); 
	else    	     rgpulse(pw, zero, 0.0, 0.0); 

	delay((gt1/10.0) + gstab - 0.5*pw + 2.0*GRADIENT_DELAY + POWER_DELAY);

	rgpulse(2.0*pw, zero, 0.0, rof1);
	dec2power(dpwr2);				       /* POWER_DELAY */
        if (mag_flg[A] == 'y')    magradpulse(gzcal*gzlvl2, gt1/10.0);
        else   zgradpulse(gzlvl2, gt1/10.0);            /* 2.0*GRADIENT_DELAY */

statusdelay(C,gstab- rof1);
   if (dm3[B]=='y') lk_sample();

	setreceiver(t12);
}