Beispiel #1
0
pulsesequence()
{
   char   
          shname1[MAXSTR],
	  f1180[MAXSTR],
	  f2180[MAXSTR],
          n15_flg[MAXSTR];


   int    icosel,
          t1_counter,
          t2_counter,
          ni2 = getval("ni2"),
          phase;


   double d2_init=0.0,
          d3_init=0.0,
          pwS1,pwS2,pwS3,pwS4,pwS5,pwS6,
          kappa,
          lambda = getval("lambda"),
          gzlvl1 = getval("gzlvl1"),
          gzlvl2 = getval("gzlvl2"), 
          gzlvl3 = getval("gzlvl3"), 
          gzlvl4 = getval("gzlvl4"), 
          gzlvl5 = getval("gzlvl5"), 
          gzlvl6 = getval("gzlvl6"), 
          gt1 = getval("gt1"),
          gt3 = getval("gt3"),
          gt4 = getval("gt4"),
          gt5 = getval("gt5"),
          gt6 = getval("gt6"),
          gstab = getval("gstab"),
          scale = getval("scale"),
          sw1 = getval("sw1"),
          tpwrsf = getval("tpwrsf"),
          shlvl1,
          shpw1 = getval("shpw1"),
          pwClvl = getval("pwClvl"),
          pwNlvl = getval("pwNlvl"),
          pwN = getval("pwN"),
          dpwr2 = getval("dpwr2"),
          d2 = getval("d2"),
          t2a,t2b,halfT2,
          shbw = getval("shbw"),
          shofs = getval("shofs")-4.77,
          timeTN = getval("timeTN"),
          tau1 = getval("tau1"),
          tau2 = getval("tau2"),
          taunh = getval("taunh");



   getstr("shname1", shname1);
   getstr("n15_flg",n15_flg);



  phase = (int) (getval("phase") + 0.5);
   
   settable(t1,4,phi1);
   settable(t2,4,phi2);
   settable(t3,1,phi3);
   settable(t5,1,phi5);
   settable(t14,4,phi14);
   settable(t15,4,phi15);
   settable(t24,4,phi24);
   settable(t25,4,phi25);


/*   INITIALIZE VARIABLES   */
   kappa = 5.4e-3;
   //shpw1 = pw*8.0;
   shlvl1 = tpwr;
   f1180[0] ='n'; 
   f2180[0] ='n'; 

   pwS1 = c13pulsepw("co", "ca", "sinc", 90.0);
   pwS2 = c13pulsepw("co", "ca", "sinc", 180.0);
   pwS3 = c13pulsepw("ca", "co", "square", 180.0);
   pwS4 = h_shapedpw("eburp2",shbw,shofs,zero, 0.0, 0.0);
   pwS6 = h_shapedpw("reburp",shbw,shofs,zero, 0.0, 0.0);
   pwS5 = h_shapedpw("pc9f",shbw,shofs,zero, 2.0e-6, 0.0);
   if(ix==1) printf("pwS2 %g   pwS3 %g GRADIENT_DELAY %g POWER_DELAY %g PWRF_DELAY %g\n",
   pwS2,pwS3,2*GRADIENT_DELAY,4*POWER_DELAY,4*PWRF_DELAY);



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

if   ( phase2 == 2 )
        {
        tsadd ( t3,2,4  );
        tsadd ( t5,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; }
    tau1 = tau1;


/*  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;

/************************************************************/
/* modification for phase-cycling in consecutive experiments*/
/*  for kinetic measurements                                */
/************************************************************/

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

  if( ix == 1) d3_init = d3;
   t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 );
   if(t2_counter % 2)
        { tsadd(t2,2,4); tsadd(t14,2,4); tsadd(t15,2,4);tsadd(t24,2,4); tsadd(t25,2,4);  }


/* Set up CONSTANT/SEMI-CONSTANT time evolution in N15 */

   if (ni2 > 1)
   {
   halfT2 = 0.5*(ni2-1)/sw2;
   t2b = (double) t2_counter*((halfT2 - timeTN)/((double)(ni2-1)));
   if( ix==1 && halfT2 - timeTN > 0 ) printf("SCT mode on, max ni2=%g\n",timeTN*sw2*2+1);
    if(t2b < 0.0) t2b = 0.0;
   
    t2a = timeTN - tau2*0.5 + t2b;
    if(t2a < 0.2e-6)  t2a = 0.0;
    }
    else
    {
    t2b = 0.0;
    t2a = timeTN - tau2*0.5;
    }



   status(A);
      rcvroff();  

   decpower(pwClvl);
   decoffset(dof);
   dec2power(pwNlvl);
   dec2offset(dof2);
   obspwrf(tpwrsf);
   decpwrf(4095.0);
   obsoffset(tof);
   set_c13offset("co");


      dec2rgpulse(pwN*2.0,zero,0.0,0.0);
     zgradpulse(1.5*gzlvl4, gt4);
       delay(1.0e-4);

lk_sample();
       delay(d1-gt4);
lk_hold();
        h_shapedpulse("pc9f",shbw,shofs,zero, 2.0e-6, 0.0);

        delay(lambda-pwS5*0.5-pwS6*0.5);

        h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, one, zero, zero, 0.0, 0.0);

        delay(lambda-pwS5*0.5-pwS6*0.5);

   if(n15_flg[0]=='y') h_shapedpulse("pc9f_",shbw,shofs,three, 0.0, 0.0);
     else h_shapedpulse("pc9f_",shbw,shofs,one, 0.0, 0.0);


   obspower(shlvl1);
/**************************************************************************/
      dec2rgpulse(pwN,zero,0.0,0.0);

           zgradpulse(gzlvl4, gt4);
           delay(timeTN-pwS2*0.5-gt4);

      sim3_c13pulse("", "co", "ca", "sinc", "", 0.0, 180.0, 2.0*pwN,
                                             zero, zero, zero, 2.0e-6, 2.0e-6);

           zgradpulse(gzlvl4, gt4);
           delay(timeTN-pwS2*0.5-gt4);
     dec2rgpulse(pwN,one,0.0,0.0);
/**************************************************************************/
/*   xxxxxxxxxxxxxxxxxxxxxx       13CO EVOLUTION        xxxxxxxxxxxxxxxxxx    */
   
        obspower(tpwr);
	c13pulse("co", "ca", "sinc", 90.0, t1, 2.0e-6, 0.0);       
        delay(tau1*0.5);
        sim3_c13pulse("", "ca", "co", "square", "", 0.0, 180.0, 2.0*pwN,
                                                  zero, zero, zero, 2.0e-6, 0.0);
        delay(tau1*0.5);
	c13pulse("co", "ca", "sinc", 180.0, zero, 2.0e-6, 0.0);      
        sim3_c13pulse("", "ca", "co", "square", "", 0.0, 180.0, 0.0,
                                                  one, zero, zero, 2.0e-6, 0.0);
        if  (pwN*2.0 > pwS3) delay(pwN*2.0-pwS3);
	c13pulse("co", "ca", "sinc", 90.0, zero, 2.0e-6, 0.0);       

/**************************************************************************/
     dec2rgpulse(pwN,t2,0.0,0.0);

         delay(tau2*0.5);
         c13pulse("ca", "co", "square", 180.0, zero, 0.0, 0.0);
         // delay(timeTN-pwS3-pwS2-gt1-1.0e-4);
         delay(timeTN-pwS3-pwS2-gt1-1.0e-4-2.0*GRADIENT_DELAY-4*POWER_DELAY-4*PWRF_DELAY-(4/PI)*pwN);
       zgradpulse(-gzlvl1, gt1); 
       delay(1.0e-4);
        c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);
        delay (t2b);
        dec2rgpulse (2.0*pwN, zero, 0.0, 0.0);
        delay (t2a);

/**************************************************************************/
        delay(gt1/10.0+1.0e-4);
        h_shapedpulse("eburp2_",shbw,shofs,t3, 2.0e-6, 0.0);

        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.5-pwS4*scale- gt5);

        h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.5-pwS4*scale- gt5);

        h_shapedpulse("eburp2",shbw,shofs,zero, 0.0, 0.0);
        delay(gt1/10.0+1.0e-4);

     dec2rgpulse(pwN,one,0.0,0.0);
        zgradpulse(gzlvl6, gt6);

        txphase(zero);
        delay(lambda-pwS6*0.5-gt6);

        h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);
        zgradpulse(gzlvl6, gt6);

        delay(lambda-pwS6*0.5-gt6);
     dec2rgpulse(pwN,t5,0.0,0.0);
/**************************************************************************/

        zgradpulse(-icosel*gzlvl2, gt1/10.0);
        dec2power(dpwr2);                                      /* POWER_DELAY */
lk_sample();
 if (n15_flg[0] =='y')
{
   if (phase2==1) setreceiver(t14);
   else setreceiver(t15);
}
else
{
   if (phase2==1) setreceiver(t24);
   else setreceiver(t25);
}

      rcvron();
statusdelay(C,1.0e-4 );

}		 
Beispiel #2
0
pulsesequence()
{

int     t1_counter;
char	    N15refoc[MAXSTR],		/* N15 pulse in middle of t1*/
            TROSY[MAXSTR];
double
   tau1, tauxh,
   gzlvl3=getval("gzlvl3"),
   gt3=getval("gt3"),
   cor=getval("cor")*1.0e-6,
   JCH = getval("JCH"),
   pwN = getval("pwN"),
   pwNlvl = getval("pwNlvl"),      
   sw1 = getval("sw1"),
   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 */
   rfst,	                           /* fine power for the stCall pulse */

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

    getstr("N15refoc",N15refoc);
    getstr("TROSY",TROSY);

/* maximum fine power for pwC pulses (and initialize rfst) */
	rf0 = 4095.0;    rfst=0.0;

/* 180 degree adiabatic C13 pulse from 0 to 200 ppm */
       {rfst = (compC*4095.0*pwC*4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35));   
	rfst = (int) (rfst + 0.5);
	if (( 1.0/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35)) < pwC ) && (ni > 1))
           { text_error( " Not enough C13 RF. pwC must be %f usec or less.\n", 
	    (1.0e6/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35))) ); psg_abort(1); }}

   initval(0.0,v1);
   initval(3.0,v2);
   initval(1.0,v3);
   initval(2.0,v4);

/* check validity of parameter range */


    if((dm2[A] == 'y' || dm2[B] == 'y' || dm2[C] == 'y') )
	{
	printf("incorrect Dec2 decoupler flags!  ");
	psg_abort(1);
    } 


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


/* LOAD VARIABLES */

if (TROSY[A] == 'y')
 {settable(t1, 8, phT1);
  settable(t2, 8, phT2);
  settable(t3, 8, phT3);
  settable(t4,16, phi4);
  settable(t5, 8, recT);}
else
 {settable(t1, 4, phi1);
  settable(t2, 2, phi2);
  settable(t3, 8, phi3);
  settable(t4, 16, phi4);
  settable(t5, 8, rec);}

/* INITIALIZE VARIABLES */

    tauxh = ((JCH != 0.0) ? 1/(4*(JCH)) : 2.25e-3);

/* Phase incrementation for hypercomplex data */

   if ( phase1 == 2 )     /* Hypercomplex in t1 */
   {
        tsadd(t2, 1, 4); 
   } 


/* calculate modification to phases based on current t1 values
   to achieve States-TPPI acquisition */
 
 
   if(ix == 1)
      d2_init = d2;
      t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5);

      if(t1_counter %2) {
        tsadd(t2,2,4);
        tsadd(t5,2,4);
      }
   tau1 = d2;
   tau1 = tau1/2.0;

/*sequence starts!!*/

   status(A);
   obspower(tpwr);
   dec2power(pwNlvl);
   decpower(pwClvl);
   decpwrf(rfst);
   delay(d1);
   rcvroff();
   status(B);

  rgpulse(pw, v1, 0.0, 0.0);

  zgradpulse(0.3*gzlvl3,gt3);

  txphase(zero);
  dec2phase(zero);

  delay(tauxh-gt3- WFG2_START_DELAY - 0.5e-3 + 70.0e-6);               /* delay=1/4J(XH)   */

  sim3shaped_pulse("","stC200","",2*pw,1.0e-3,0.0,zero,zero,zero,0.0,0.0);

  zgradpulse(0.3*gzlvl3,gt3);

  decphase(t2);
  delay(tauxh-gt3- WFG2_START_DELAY - 0.5e-3 + 70.0e-6 );               /* delay=1/4J(XH)   */
if (TROSY[A] == 'y')

 {
  rgpulse(pw, v3, 0.0,0.0);

  zgradpulse(-0.5*gzlvl3,gt3);
  decpwrf(rf0); delay(200.0e-6);

  decrgpulse(pwC, t2, 0.0, 0.0);

  txphase(t1); decphase(zero);
  if (tau1>0.0)
   {
        if ( (N15refoc[A]=='y') && (tau1 > (pwN/2.0 +2.0*pwC/PI) ) )
           {delay(tau1 - pwN -2.0*pwC/PI);     
            dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
            delay(tau1 - pwN -2.0*pwC/PI);}     
        else
           { if (tau1>2.0*pwC/PI) 
              delay(2.0*tau1-4.0*pwC/PI);
             else
               delay(2.0*tau1);
           }
   }

  rgpulse(pw, t1, 0.0,0.0);

  decpwrf(rfst);
  zgradpulse(0.3*gzlvl3,gt3);
  delay(tauxh-gt3-WFG2_START_DELAY - 0.5e-3 + 70.0e-6);
  sim3shaped_pulse("","stC200","",2*pw,1.0e-3,0.0,zero,zero,zero,0.0,0.0);  zgradpulse(0.3*gzlvl3,gt3);
  delay(tauxh-gt3-WFG2_START_DELAY - 0.5e-3 + 70.0e-6);
  sim3pulse(pw,pwC,0.0,two,zero,one,0.0,0.0); 
   zgradpulse(gzlvl3,gt3);
   txphase(v4);

   delay(tauxh-gt3-WFG2_START_DELAY - 0.5e-3 + 70.0e-6);

   rgpulse(pw*0.231,v4,0.0,0.0);
   delay(d3);
   rgpulse(pw*0.692,v4,0.0,0.0);
   delay(d3);
   rgpulse(pw*1.462,v4,0.0,0.0);

   delay(d3/2);
   sim3shaped_pulse("","stC200","",0.0,1.0e-3,0.0,zero,zero,zero,0.0,0.0);
   txphase(v1);
   delay(d3/2);

   rgpulse(pw*1.462,v1,0.0,0.0);
   delay(d3);
   rgpulse(pw*0.692,v1,0.0,0.0);
   delay(d3);
   rgpulse(pw*0.231,v1,0.0,0.0);
   dec2phase(t3);
   zgradpulse(gzlvl3,gt3); decpwrf(rf0);
   delay(tauxh-gt3-WFG2_START_DELAY - 0.5e-3 + 70.0e-6);
   decrgpulse(pwC, t3, 0.0,0.0);}

else
   { 
  rgpulse(pw, t1, 0.0,0.0);

  zgradpulse(0.5*gzlvl3,gt3); decpwrf(rf0);
  delay(200.0e-6);

  decrgpulse(pwC, t2, 0.0, 0.0);

  txphase(t4); decphase(zero);
  if (tau1>0.0)
   {
  	if ( (N15refoc[A]=='y') && (tau1 > (pwN+2.0*pwC/PI)) )
           {delay(tau1 - pwN -2.0*pwC/PI);     
            sim3pulse(2*pw,0.0,2.0*pwN, zero, zero, zero,0.0, 0.0);
            delay(tau1 - pwN -2.0*pwC/PI);}
	else
            {
             if (tau1 > (pw +2.0*pwC/PI))
              {delay(tau1-pw -2.0*pwC/PI); rgpulse(2.0*pw, t4, 0.0, 0.0); decphase(t3); delay(tau1-pw -2.0*pwC/PI);}
             else
              {delay(tau1); decphase(t3); delay(tau1);} 
            }             
   }
  decrgpulse(pwC, t3, 0.0, 0.0);

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

  rgpulse(pw, v4, 0.0,0.0);

  decphase(zero);
  
  zgradpulse(gzlvl3,gt3);
  decpwrf(rfst);
  txphase(zero);
  dec2phase(zero);

  delay(tauxh-gt3- WFG2_START_DELAY - 0.5e-3 + 70.0e-6);               /* delay=1/4J(XH)   */
   rgpulse(pw*0.231,v2,0.0,0.0);
   delay(d3);
   rgpulse(pw*0.692,v2,0.0,0.0);
   delay(d3);
   rgpulse(pw*1.462,v2,0.0,0.0);

   delay(d3/2.0);
  sim3shaped_pulse("","stC200","",0.0,1.0e-3,0.0,zero,zero,zero,0.0,0.0);
   delay(d3/2.0);
  
   rgpulse(pw*1.462,v3,0.0,0.0);
   delay(d3);
   rgpulse(pw*0.692,v3,0.0,0.0);
   delay(d3);
   rgpulse(pw*0.231,v3,0.0,0.0);
   zgradpulse(gzlvl3,gt3);
   decpwrf(rf0);
   delay(tauxh-gt3- WFG2_START_DELAY - 0.5e-3 + 70.0e-6 +cor );}               /* delay=1/4J(XH)   */
   decpower(dpwr);
   setreceiver(t5);
status(C);
   rcvron();

}
Beispiel #3
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 */
	    h1dec[MAXSTR],		/* Flag to waltz-decouple of H1 for t1*/
	    CT_c[MAXSTR];           /* Flag to constant time evolution for C13*/
 
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      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
            timeTC = getval("timeTC"),     /* constant time for 13C evolution */
            timeTN = getval("timeTN"),     /* constant time for 15N evolution */
	    kappa = 5.4e-3,
	    lambda = 2.4e-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 Ca (56ppm), first off-resonance null at CO (174ppm)     */
        pwC1,		              /* 90 degree pulse length on C13 at rf1 */
        rf1,		       /* fine power for 4.7 kHz rf for 600MHz magnet */

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

/* the following pulse lengths for SLP pulses are automatically calculated    */
/* by the macro "BPcal".  SLP pulse shapes, "offC9" etc are called       */
/* directly from your shapelib.                    			      */
   pwC9 = getval("pwC9"),  /*180 degree pulse at CO(174ppm) null at Ca(56ppm) */
   pwC9a = getval("pwC9a"),    /* pwC9a=pwC9, but not set to zero when pwC9=0 */
   phshift9,             /* phase shift induced on Ca by pwC9 ("offC9") pulse */
   pwZ,					   /* the largest of pwC9 and 2.0*pwN */
   pwZ1,                /* the larger of pwC9a and 2.0*pwN for 1D experiments */
   rf9,	                           /* fine power for the pwC9 ("offC9") 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 */
   	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"),
	gt7 = getval("gt7"),
	gstab = getval("gstab"),
	gzlvl0 = getval("gzlvl0"),
	gzlvl3 = getval("gzlvl3"),
	gzlvl4 = getval("gzlvl4"),
	gzlvl5 = getval("gzlvl5"),
	gzlvl6 = getval("gzlvl6"),
	gzlvl7 = getval("gzlvl7");

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



/*   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;
	
     /* 90 degree pulse on Ca, null at CO 118ppm away */
       pwC1 = sqrt(15.0)/(4.0*118.0*dfrq);
        rf1 = (compC*4095.0*pwC)/pwC1;
        rf1 = (int) (rf1 + 0.5);

    /* 180 degree pulse on Ca, null at CO 118ppm away */
        pwC2 = sqrt(3.0)/(2.0*118.0*dfrq);
        rf2 = (4095.0*compC*pwC*2.0)/pwC2;
        rf2 = (int) (rf2 + 0.5);
        if( rf2 > 4095.0 )
         {printf("increase pwClvl so that C13 90 < 24us*(600/sfrq)"); psg_abort(1);}

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

    /* the pwC9 pulse at the middle of t1  */
        if ((ni2 > 0.0) && (ni == 1.0)) ni = 0.0;
        if (pwC9a > 2.0*pwN) pwZ = pwC9a; else pwZ = 2.0*pwN;
        if ((pwC9==0.0) && (pwC9a>2.0*pwN)) pwZ1=pwC9a-2.0*pwN; else pwZ1=0.0;
        if (ni > 1)  pwC9 = pwC9a;
        if ( pwC9 > 0 )  phshift9 = 320.0;
	else             phshift9 = 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*ni*1/(sw1) > timeTC)
       { printf(" ni is too big. Make ni less than %d . Check by using dps and make sure no ? appears for d2=t1max (ni/sw1).\n", 
  	 ((int)((timeTC)*2.0*sw1-7))); psg_abort(1);   }

    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 > 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);  
    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  */
   
    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(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);
if ( dm3[B] == 'y' )
  { lk_hold(); lk_sampling_off();}  /*freezes z0 correction, stops lock pulsing*/

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);

if (TROSY[A]=='y')
   {
    txphase(two);
    obspower(tpwrs);
    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);

    dec2phase(zero);
    decpwrf(rf2);
    delay(timeTN - 0.5*kappa);
   }

else
   {
    txphase(zero);
    obspower(tpwrs);
    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(rf2);
    delay(timeTN - kappa);
   }

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

	decphase(t3);
	decpwrf(rf1);
	delay(timeTN);

	dec2rgpulse(pwN, zero, 0.0, 0.0);
if (TROSY[A]=='n')
   {
    xmtroff();
    obsprgoff();
    if (h1dec[0]=='y')
      rgpulse(pwHd,three,2.0e-6,0.0);
    else
      rgpulse(pwHd,one,2.0e-6,0.0);
   }

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

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

      if ( dm3[B] == 'y' )     /* begins optional 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(pwC1,t3,0.0,0.0);
decphase(zero);
/*   xxxxxxxxxxxxxxxxxxxxxx       13Ca EVOLUTION        xxxxxxxxxxxxxxxxxx    */

if (CT_c[0]=='n')  {
  if ((ni>1.0) && (tau1>0.0))          /* total 13C evolution equals d2 exactly */
   {         /* 2.0*pwC1/PI compensates for evolution at 64% rate duting pwC1 */
	decpwrf(rf9);
     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("", "offC9", "", 0.0, pwC9a, 2.0*pwN, zero, zero, zero,
								      0.0, 0.0);
	initval(phshift9, v9);
	decstepsize(1.0);
	dcplrphase(v9);  				        /* SAPS_DELAY */
	delay(tau1 - 2.0*pwC1/PI  - SAPS_DELAY - 0.5*pwZ - 2.0e-6);
	   }
      else
	   {
	initval(180.0, v9);
	decstepsize(1.0);
	dcplrphase(v9);  				        /* SAPS_DELAY */
	delay(2.0*tau1 - 4.0*pwC1/PI - SAPS_DELAY - 2.0e-6);
	   }
   }

  else if (ni==1.0)         /* special 1D check of pwC9 phase enabled when ni=1 */
    {
	decpwrf(rf9);
	delay(10.0e-6 + SAPS_DELAY + 0.5*pwZ1);
							  /* WFG3_START_DELAY */
	sim3shaped_pulse("", "offC9", "", 0.0, pwC9, 2.0*pwN, zero, zero, zero,
							          2.0e-6, 0.0);
	initval(phshift9, v9);
	decstepsize(1.0);
	dcplrphase(v9);  					/* 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);
     }

}

else {   /* %%%%%%%%%%STARTING 13Ca Constant Time EVOLUTION %%%%%%%%%%%%%%%%%%*/
    decpwrf(rf9);
    if(tau1 - 2.0*pwC1/PI - WFG_START_DELAY -POWER_DELAY> 0.0) {
       delay(tau1 -2.0*pwC1/PI -POWER_DELAY -WFG_START_DELAY);
       sim3shaped_pulse("","offC9","",0.0,pwC9a, 2.0*pwN, zero, zero, zero, 
								0.0, 0.0);
    }
    else {
       sim3shaped_pulse("","offC9","",0.0,pwC9a, 2.0*pwN, zero, zero, zero, 
								0.0, 0.0);
    }
    if (h1dec[0]=='n'){
      delay(taud-POWER_DELAY);
      obspower(tpwr);
      rgpulse(2.0*pw,zero,0.0,0.0);
        if ( dm3[B] == 'y' )   /* turns off 2H decoupling  */
           {
           delay(timeTC -pwZ -2.0*WFG_STOP_DELAY -taud -2.0*pw -1/dmf3 -2.0e-6 -202.0e-6 -gt7);
           setstatus(DEC3ch, FALSE, 'c', FALSE, dmf3);
           dec3rgpulse(1/dmf3,three,2.0e-6,2.0e-6);
           dec3blank();
           }
      else{				       /* Should be forbidden?? */
        delay(timeTC -pwZ -WFG_STOP_DELAY -taud -2.0*pw -202.0e-6 -gt7);
      } 
    }
    else {						/*  hdec=y    */
        if ( dm3[B] == 'y' )   /* turns off 2H decoupling  */
           {
           delay(timeTC -pwZ -2.0*WFG_STOP_DELAY -PRG_STOP_DELAY -pwHd -1/dmf3
						-4.0e-6-202.0e-6-gt7);
           xmtroff();
           obsprgoff();
           rgpulse(pwHd,three,2.0e-6,2.0e-6);
           setstatus(DEC3ch, FALSE, 'c', FALSE, dmf3);
           dec3rgpulse(1/dmf3,three,2.0e-6,2.0e-6);
           dec3blank();
           }
      else{
        delay(timeTC -pwZ -WFG_STOP_DELAY -PRG_STOP_DELAY -4.0e-6 -202.0e-6
								-gt7);
        xmtroff();     
        obsprgoff();   
        rgpulse(pwHd,three,2.0e-6,2.0e-6);
     }
  }

    delay(2.0e-6);
    zgradpulse(gzlvl7,gt7);
    delay(200.0e-6-POWER_DELAY);
    decpwrf(rf2);

    decrgpulse(pwC2, zero, 0.0, 0.0); 	             /* 13Ca 180 degree pulse */ 

    delay(2.0e-6);
    zgradpulse(gzlvl7,gt7); 
    delay(200.0e-6);

    if (h1dec[0]=='n') {
      if ( dm3[B] == 'y' )     /* begins optional 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);
        delay(timeTC-tau1-202.0e-6-gt7-2.0*WFG_START_DELAY-1/dmf3-
	  2.0*POWER_DELAY-pwC9a-2.0e-6-WFG_STOP_DELAY-SAPS_DELAY);
        }
      else{                                            /* Should be forbidden??? */
        delay(timeTC -tau1 - 202.0e-6 - gt7-2.0*POWER_DELAY-pwC9a-
	  WFG_START_DELAY-WFG_STOP_DELAY-2.0e-6-SAPS_DELAY);
      }
    }
    else {
      if (dm3[B]=='y') {
	rgpulse(pwHd,one,0.0,0.0);
        txphase(zero);
        delay(2.0e-6);
        obsprgon("waltz16", pwHd, 90.0);
        xmtron();

          dec3rgpulse(1/dmf3,one,10.0e-6,2.0e-6);
          dec3unblank();
          dec3phase(zero);
          delay(2.0e-6);
          setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
        delay(timeTC-tau1-202.0e-6-gt7-2.0*WFG_START_DELAY-4.0e-6-1/dmf3-pwHd-
	           PRG_START_DELAY-2.0*POWER_DELAY-pwC9a-2.0e-6-SAPS_DELAY);
      }
      else {
        delay(2.0e-6);
        rgpulse(pwHd,one,0.0,0.0);
        txphase(zero);
        delay(2.0e-6);
        obsprgon("waltz16", pwHd, 90.0);
        xmtron();
        delay(timeTC-tau1-202.0e-6-gt7-4.0e-6-pwHd-PRG_START_DELAY-
	  2.0*POWER_DELAY-pwC9a-WFG_START_DELAY-WFG_STOP_DELAY-SAPS_DELAY);
      }
    }
    decpwrf(rf9);

    decshaped_pulse("offC9",pwC9a,zero,0.0,0.0); 
    initval(phshift9, v9);
    decstepsize(1.0);
    dcplrphase(v9);                                         /* SAPS_DELAY */

}  /* %%%%%%%%%%%%%%%%%%ENDING 13Ca Constant Time EVOLUTION %%%%%%%%%%%%%%%%%%*/


  decphase(t5);
  decpwrf(rf1);
  decrgpulse(pwC1, t5, 2.0e-6, 0.0);

  dec2phase(t8);
  dcplrphase(zero);

        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 */
           }
  if (h1dec[0]=='y')
  {
    xmtroff();
    obsprgoff();
    rgpulse(pwHd,three,2.0e-6,0.0);
    txphase(one);
  }

  delay(2.0e-6);
  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();
  }

/* %%%%%%%%%%%%%%%%%%STARTING N15 Constant Time Evolution %%%%%%%%%%%%%%%%%%*/

	dec2rgpulse(pwN, t8, 0.0, 0.0);

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

	sim3pulse(0.0, pwC2, 2.0*pwN, zero, zero, t9, 0.0, 0.0);

	dec2phase(t10);
        decpwrf(rf9);

if (TROSY[A]=='y')
{    if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.5e-4 + pwHs)
	{
	  txphase(three);
          delay(timeTN - pwC9a - WFG_START_DELAY);         /* WFG_START_DELAY */
          decshaped_pulse("offC9", pwC9a, zero, 0.0, 0.0);
          delay(tau2 - gt1 - 2.0*GRADIENT_DELAY - 1.5e-4 - pwHs);
          if (mag_flg[A]=='y')  magradpulse(gzcal*gzlvl1, gt1);
          else  zgradpulse(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-pwC9a-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(tpwrs);				       /* POWER_DELAY */
	  delay(1.0e-4 - POWER_DELAY);                     /* WFG_START_DELAY */
          decshaped_pulse("offC9", pwC9a, 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 - pwC9a - WFG_START_DELAY - gt1 - 2.0*GRADIENT_DELAY
							    - 1.5e-4 - pwHs);
          if (mag_flg[A]=='y')    magradpulse(gzcal*gzlvl1, gt1);
          else  zgradpulse(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);
          decshaped_pulse("offC9", pwC9a, zero, 0.0, 0.0);
          delay(tau2);
	}
}
else
{
    if (tau2 > kappa)
	{
          delay(timeTN - pwC9a - WFG_START_DELAY);     	   /* WFG_START_DELAY */
          decshaped_pulse("offC9", pwC9a, 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 - pwC9a - 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("offC9", pwC9a, zero, 0.0, 0.0);
          delay(kappa -pwC9a -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 - pwC9a - WFG_START_DELAY);   /* WFG_START_DELAY */
          decshaped_pulse("offC9", pwC9a, 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-pwC9a-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("offC9", pwC9a, 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, 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);
}		 
Beispiel #4
0
pulsesequence()
{
 char       f1180[MAXSTR],   
            f2180[MAXSTR],  
            mag_flg[MAXSTR],
            flg_3919[MAXSTR],
            ref_flg[MAXSTR];

 int         phase, ni2,
             t1_counter,   
             t2_counter;   

 double      gzcal = getval("gzcal"),
             factor = 0.08, /* used for 3-9-19 water gate */
             tau_3919 = getval("tau_3919"),
             flipphase = getval("flipphase"),
             tau1,         /*  t1 delay */
             tau2,         /*  t2 delay */
             taua,         /*  1/4JNH   ~ 2.3 ms   */
             taub,        /*  1/4JNH    ~ 2.3 ms  */
             bigT,         /* ~ 19  ms   */

             pwNlvl,       
             pwN,  
             gt1,
             gt2,
             gt3,
             gt4,
             gt5,
             gt6,
             gt7,
             gt8,
             gzlvl1,
             gzlvl2,
             gzlvl3,
             gzlvl4,
             gzlvl5,
             gzlvl6,
             gzlvl7,
             gzlvl8,


  compH = getval("compH"),         /* adjustment for C13 amplifier compression */
  pwHs = getval("pwHs"),	        /* H1 90 degree pulse length at tpwrs */
  tpwrsf = getval("tpwrsf"),     /* fine power adjustment for flipback pulse   */
  tpwrs;	  	              /* power for the pwHs ("H2Osinc") pulse */
	
/* LOAD VARIABLES */

  getstr("f1180",f1180);
  getstr("f2180",f2180);
  getstr("flg_3919", flg_3919);
  getstr("mag_flg", mag_flg);
  getstr("ref_flg", ref_flg);

  taua   = getval("taua"); 
  taub   = getval("taub"); 
  bigT   = getval("bigT");
   
  tpwr = getval("tpwr");
  pwNlvl = getval("pwNlvl");
  pwN = getval("pwN");
  
  dpwr = getval("dpwr");
  dpwr2 = getval("dpwr2");
  phase = (int)( getval("phase") + 0.5);
  phase2 = (int)( getval("phase2") + 0.5);
  sw1 = getval("sw1");
  sw2 = getval("sw2");  
  ni = getval("ni");
  ni2 = getval("ni2");
  
  gt1 = getval("gt1");
  gt2 = getval("gt2");
  gt3 = getval("gt3");
  gt4 = getval("gt4");
  gt5 = getval("gt5");
  gt6 = getval("gt6");
  gt7 = getval("gt7");
  gt8 = getval("gt8");
  
  gzlvl1 = getval("gzlvl1");
  gzlvl2 = getval("gzlvl2");
  gzlvl3 = getval("gzlvl3");
  gzlvl4 = getval("gzlvl4");
  gzlvl5 = getval("gzlvl5");
  gzlvl6 = getval("gzlvl6");
  gzlvl7 = getval("gzlvl7");
  gzlvl8 = getval("gzlvl8");

/* LOAD PHASE TABLE */
           
  settable(t1,4,phi1);
  settable(t2,2,phi2);
  settable(t3,8,phi3);
  settable(t4,16, phi4);

  if (ref_flg[A] == 'y')
  {
     settable(t10,8,ref);
  }
  else
  {
     settable(t10,8,rec);
  }
  

/* 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 */

/* CHECK VALIDITY OF PARAMETER RANGES */

    if (ref_flg[A] == 'y' && ni > 1)
    {
       printf(" Incorrect setting of ni and ref_flg.\n");
       printf(" Please choose either ni=1 or ref_flg=n.\n");
       psg_abort(1);
    }
    
    if (ref_flg[A] == 'y' && dps_flag)
    {
       printf(" Please use phase2 and ni2 for 2D reference spectrum\n");
       if (ni2/sw2 > 2.0*(2.0*bigT - gt5 - 200.0e-6))
       {
           printf("ni2 is too big, should be < %f\n", 2.0*sw2*(2.0*bigT-gt5-200.0e-6));
           psg_abort(1);
       }
    }

    if ((ni2/sw2 > 2.0*(bigT -  gt5 - 200.0e-6)) && (ref_flg[A] !='y'))
    {
       printf(" ni2 is too big, should be < %f\n", 2.0*sw2*(bigT-gt6-200.0e-6));
       psg_abort(1);
    }

    if(dpwr2 > 50)
    {
        printf("don't fry the probe, dpwr2 is  too large!  ");
        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);
    }

/*  Phase incrementation for hypercomplex 2D data */

    if (phase == 2)
    {
       tsadd(t1,1,4);
    }
  
    if (phase2 == 2)
    {
       tsadd(t2,1,4);   
    }

/*  Set up f1180  half_dwell time (1/sw1)/2.0           */
   
    tau1 = d2 - (4.0*pw/PI + 2.0*pwN);
    if(f1180[A] == 'y')
    {
        tau1 += (1.0/(2.0*sw1));
    }
    if(tau1 < 0.2e-6) tau1 = 0.0;
    tau1 = tau1/2.0;

/*  Set up f2180   half dwell time (1/sw2)/2.0              */

    tau2 = d3;
    if(f2180[A] == 'y')
    {
        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(t10,2,4);    
   }
   
   if( ix == 1) d3_init = d3 ;
   t2_counter = (int)((d3-d3_init)*sw2 + 0.5);
   if(t2_counter % 2) 
   {
      tsadd(t2,2,4);  
      tsadd(t10,2,4);    
   }

   if (flipphase < -0.01)  flipphase = flipphase + 360.0;
   initval(flipphase, v10);
   obsstepsize(0.25);


/* BEGIN ACTUAL PULSE SEQUENCE */

status(A);
   obspower(tpwr);
   dec2power(pwNlvl);
   txphase(zero);
   dec2phase(zero);

   delay(d1);

   if(gt1 > 0.2e-6)
   {
      dec2rgpulse(pwN, zero, 0.2e-6, 0.0);
      delay(2.0e-6);
      zgradpulse(gzlvl1, gt1);
      delay(0.001);
   }
   rcvroff();

status(B);

   rgpulse(pw, zero,rof1, 0.0);
   delay(2.0e-6);
   if (gt2 > 0.2e-6)
      zgradpulse(gzlvl2,gt2);
   delay(taua - gt2 - 2.0e-6);
   sim3pulse(2.0*pw,(double)0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);
   delay(taua - gt2 - 400.0e-6);
   if (gt2 > 0.2e-6)
   {
      zgradpulse(gzlvl2,gt2);
   }
   txphase(one);
   dec2phase(t2);
   delay(400.0e-6);
   rgpulse(pw, one, 0.0, 0.0);
   if (gt3 > 0.2e-6)
   {
      delay(2.0e-6);
      zgradpulse(gzlvl3, gt3);
      delay(200.0e-6);
   }
   txphase(zero);
   dec2rgpulse(pwN, t2, 0.0, 0.0);

   if (ref_flg[A] == 'y')
   {
      delay(tau2);
      rgpulse(2.0*pw, zero, 0.0, 0.0);
      dec2phase(t3);
      if (gt5 > 0.2e-6)
      {
         delay(2.0*bigT - gt5 - 2.0*pw - 1.0e-3);
         zgradpulse(gzlvl5, gt5);
         delay(1.0e-3);
         dec2rgpulse(2.0*pwN, t3, 0.0, 0.0);
         delay(2.0e-6);
         zgradpulse(gzlvl5, gt5);
         delay(2.0*bigT - tau2 - gt5 - 2.0e-6);
      }
      else
      {
         delay(2.0*bigT - 2.0*pw);
         dec2rgpulse(2.0*pwN, t3, 0.0, 0.0);
         delay(2.0*bigT - tau2);
      }
   }
   else
   {
      dec2phase(zero);
      if (gt4 > 0.2e-6)
      {
         delay(2.0e-6);
         zgradpulse(gzlvl4, gt4);
         delay(bigT - gt4 - 2.0e-6);
         sim3pulse(2.0*pw,(double)0.0, 2.0*pwN, zero,zero, zero, 0.0, 0.0);
         delay(2.0e-6);
         zgradpulse(gzlvl4, gt4);
         delay(1.0e-3 - 2.0e-6);
      }
      else
      {
         delay(bigT);
         sim3pulse(2.0*pw,(double)0.0, 2.0*pwN, zero,zero, zero, 0.0, 0.0);
         delay(1.0e-3);
         gt4 = 0.0;
      }

      zgradpulse(gzlvl5, gt5);
      txphase(t1);
      delay(bigT - gt4 - gt5 - 1.0e-3 - 2.0*GRADIENT_DELAY);

      rgpulse(pw, t1, 0.0, 0.0);
      delay(tau1);
      dec2rgpulse(2.0*pwN, t3, 0.0, 0.0);
      txphase(zero);
      delay(tau1);
      rgpulse(pw, zero, 0.0, 0.0);

      delay(2.0e-6);
      zgradpulse(gzlvl5, gt5);
      dec2phase(t4);

      if (gt6 > 0.2e-6)
      {
         delay(tau2 + 100.0e-6);
         zgradpulse(gzlvl6, gt6);
         delay(bigT - gt5 - gt6 - 100.0e-6 - 2.0*GRADIENT_DELAY);
         sim3pulse(2.0*pw,(double)0.0, 2.0*pwN, zero,zero, t4, 0.0, 0.0);
         delay(2.0e-6);
         dec2phase(zero);
         zgradpulse(gzlvl6, gt6);
         delay(bigT - tau2 - gt6 - 2.0e-6);
      }
      else
      {
         delay(bigT + tau2 - gt5 - 2.0*GRADIENT_DELAY);
         sim3pulse(2.0*pw,(double)0.0, 2.0*pwN, zero,zero, t4, 0.0, 0.0);
         dec2phase(zero);
         delay(bigT - tau2);
      }
   }

   if (gt7 > 0.2e-6)
   {
      dec2rgpulse(pwN, zero, 0.0,2.0e-6);
      zgradpulse(gzlvl7, gt7);
      txphase(zero);
      
      delay(200.0e-6);
      if (pwHs > 0.2e-6)
      {
         xmtrphase(v10);
         if (tpwrsf<4095.0) {obspower(tpwrs+6.0); obspwrf(tpwrsf);}
          else obspower(tpwrs);
         txphase(two);
         shaped_pulse("H2Osinc", pwHs, two, 2.0e-6, 0.0);
         xmtrphase(zero);
         obspower(tpwr); obspwrf(4095.0);
      }
      rgpulse(pw, zero, 2.0e-6, 0.0);
   }
   else
   {
      sim3pulse(pw,(double)0.0, pwN, zero,zero, zero, 0.0, 0.0);
   }


   delay(2.0e-6);
   if(mag_flg[A] == 'y')
   {
      magradpulse(gzcal*gzlvl8, gt8);
   }
   else
   {
      zgradpulse(gzlvl8, gt8);
   }
   if (flg_3919[A] == 'y')
   {
      delay(taub - 31.0*factor*pw - 2.5*tau_3919 - gt8 - 2.0e-6);
      rgpulse(pw*factor*3.0, two, 0.0, 0.0);
      delay(tau_3919);
      rgpulse(pw*factor*9.0, two, 0.0, 0.0);
      delay(tau_3919);
      rgpulse(pw*factor*19.0, two, 0.0, 0.0);
      delay(tau_3919/2.0 - pwN);
      dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
      delay(tau_3919/2.0 - pwN);
      rgpulse(pw*factor*19.0, zero, 0.0, 0.0);
      delay(tau_3919);
      rgpulse(pw*factor*9.0, zero, 0.0, 0.0);
      delay(tau_3919);
      rgpulse(pw*factor*3.0, zero, 0.0, 0.0);
      delay(taub - 31.0*factor*pw - 2.5*tau_3919 - gt8 - POWER_DELAY - 402.0e-6);
   }
   else
   {
      if (tpwrsf<4095.0) {obspower(tpwrs+6.0); obspwrf(tpwrsf);}
       else obspower(tpwrs);
      txphase(two);
      xmtrphase(v10);
      delay(taub - pwHs - gt8 - 2.0*POWER_DELAY - 2.0e-6);
      shaped_pulse("H2Osinc", pwHs, two, 0.0, 0.0);
      obspower(tpwr); obspwrf(4095.0);
      xmtrphase(zero);
      txphase(zero);
      sim3pulse(2.0*pw, (double)0.0, 2.0*pwN, zero, zero, zero, 2.0e-6, 0.0);
      if (tpwrsf<4095.0) {obspower(tpwrs+6.0); obspwrf(tpwrsf);}
       else obspower(tpwrs);
      txphase(two);
      xmtrphase(v10);
      shaped_pulse("H2Osinc", pwHs, two, 2.0e-6, 0.0);
      xmtrphase(zero);
      obspower(tpwr); obspwrf(4095.0);
      dec2power(dpwr2);
      delay(taub - pwHs  - gt8 - 3.0*POWER_DELAY - 402.0e-6);
   }
   dec2power(dpwr2);
   if(mag_flg[A] == 'y')
   {
      magradpulse(gzcal*gzlvl8, gt8);
   }
   else
   {
      zgradpulse(gzlvl8, gt8);
   }
   delay(400.0e-6);

status(C);
   setreceiver(t10);
   rcvron();
}
Beispiel #5
0
void pulsesequence()
{
   double	base,
                corr,
                presat,
                qlvl;
   char         sspul[MAXSTR];


/* LOAD VARIABLES AND CHECK CONDITIONS */
   presat = getval("presat");
   qlvl = getval("qlvl");
   getstr("sspul", sspul);

   base = 180.0 / qlvl;
   initval(2.0 * qlvl, v5);

   if ((rof1 < 9.9e-6) && (ix == 1))
      fprintf(stdout,"Warning:  ROF1 is less than 10 us\n");

/* STEADY-STATE PHASECYCLING */
/* This section determines if the phase calculations trigger off of (SS - SSCTR)
   or off of CT */

   ifzero(ssctr);
      modn(ct, v5, v10);
      divn(ct, v5, v12);
      mod2(ct, v9);
   elsenz(ssctr);
      sub(ssval, ssctr, v14);	/* v14 = 0,...,ss-1 */
      modn(v14, v5, v10);
      divn(v14, v5, v12);
      mod2(v14, v9);
   endif(ssctr);


/* CALCULATE PHASECYCLE */
/* The phasecycle first performs a (2*Q)-step cycle on the third pulse in order
   to select for MQC.  The phasecycle is then adjusted so that the receiver
   goes +- in an alternating fashion.  Second, the 2-step QIS cycle is added
   in.  Third, a 2-step cycle for axial peak suppression is performed on the
   first pulse. */

   assign(v12, v1);
   mod2(v12, v12);		/* v12=quad. image suppression */
   hlv(v1, v1);
   mod2(v1, v1);
   dbl(v1, v1);
   add(v1, v12, v4);
   add(v12, v1, v1);
   assign(v12, v2);
   assign(v12, v3);
   dbl(v9, v9);
   add(v9, v4, v4);
   assign(v4, oph);
   if (phase1 == 2)
      incr(v1);
   if (phase1 == 3)  /* TPPI */
      add(id2, v1, v1);
/* FAD added for phase=1 or phase=2 */
   if ((phase1 == 1) || (phase1 == 2))
   {
      initval(2.0*(double)(d2_index%2),v13);
      add(v1,v13,v1); add(oph,v13,oph);
   }


/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   if (newtrans)
      obsstepsize(base);

   status(A);
   if (sspul[0] == 'y')
   {
      hsdelay(hst + 0.001);
      rgpulse(pw, v1, 1.0e-6, 1.0e-6);
      hsdelay(hst + 0.001);
   }
   if ((d1 - presat) <= hst)
   {
      rcvroff();
      decon();
      hsdelay(presat);
      decoff();
      delay(1.0e-6);
      rcvron();
   }
   else
   {
      hsdelay(d1 - presat);
      decon();
      rcvroff();
      delay(presat);
      decoff();
      delay(1.0e-6);
      rcvron();
   }
   status(B);
      if (newtrans)
         xmtrphase(v10);      /* hardware digital phaseshift */
      rgpulse(pw, v1, rof1, 1.0e-6);
      corr = 1.0e-6 + rof1 + 4.0*pw/3.1416;
      if (d2  > corr)
        delay(d2-corr); 
      rgpulse(pw, v2, rof1, 0.0);
      if (newtrans)
      {
         xmtrphase(zero);       /* resets relative phase to absolute phase */
      }
      else
      {
         phaseshift(-base, v10, OBSch);   /* software small-angle phaseshift */
      }
      rgpulse(pw, v3, 1.0e-6, rof2);
   status(C);
}
Beispiel #6
0
pulsesequence()
{
   char  	hmult[MAXSTR],
                chonly[MAXSTR],
                oddeven[MAXSTR];
   double	j1xh,
         	pp,
	 	pplvl,
         	dly3,
         	dly4,
         	phase;
   int          iphase;

/* Get new variables from parameter table */
   pp = getval("pp");
   j1xh = getval("j1xh");
   getstr("hmult", hmult);
   getstr("chonly",chonly);
   getstr("oddeven",oddeven);
   phase = getval("phase");
   iphase = (int)(phase + 0.5);
   pplvl = getval("pplvl");

/* Calculate delays */
      dly3 = 1.0 / (2.0 * j1xh);

   if (chonly[0] == 'y')
      dly4 = dly3;
   else
   {
    if (iphase == 0)
      dly4 = 1.0/(3.0*j1xh);
    else
    {
     if (oddeven[0] == 'y')
      dly4 = 3.0/(4.0*j1xh);
     else
      dly4 = 1.0/(3.0*j1xh);
    }
   }
/* PHASE CYCLING CALCULATION */

   settable(t2,4,phs2);
   settable(t8,4,phs8);
   settable(t7,2,phs7);
   settable(t4,1,phs4);


   assign(zero, v1);                  /* v1 = 0 */
   if (iphase == 2)
      incr(v1);                      /* hypercomplex phase increment */


   if (iphase == 0)
    hlv(ct,v5);
   else
    assign(ct,v5);
   getelem(t2,v5,v2);
   getelem(t8,v5,v8);

   add(v8,one,v9);

   add(v2,two,v3);

   getelem(t7,v5,v7);
   getelem(t4,v5,v4);

   add(v4,one,v4); 
   mod2(ct,v13);
   if (iphase == 0)
    add(v4,v13,v4);

   add(v4,v7,oph);

   add(v7,one,v6);

   initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v12);
   add(v1,v12,v1);
   add(oph,v12,oph);

   add(oph,two,oph);

/* ACTUAL PULSE-SEQUENCE BEGINS  */


   status(A);
      if (dm[0] == 'y')
      {
         fprintf(stdout, "decoupler must be set as dm=nny\n");
         psg_abort(1);
      }
 
      decpower(pplvl);
      hsdelay(d1);


   status(B);
      rcvroff();
      delay(2.0e-5);
      decpulse(pp, v1);

      if (hmult[0] == 'y')
      {	
         if (d2 > 0.0)
          delay(d2/2.0 - (2*pp/PI) - 2.33*pw - rof1);
         else
          delay(d2/2.0);
         rgpulse(pw, v8, rof1, 0.0);
         rgpulse(2.67*pw, v9, 0.0, 0.0);
         rgpulse(pw, v8, 0.0, rof1);
         if (d2 > 0.0) 
          delay(d2/2.0 - 2.33*pw - rof1); 
         else 
          delay(d2/2.0);
      }
      else
      {
         if (d2 > 0.0) 
          delay(d2/2.0 - (4*pp/PI)); 
         else 
          delay(d2/2.0);
         decpulse(pp, v2);
         delay(dly3 - rof1 - pw - 1.5 * pp);
         rgpulse(pw, v8, rof1, 0.0);
         simpulse(2.67*pw, 2.0*pp, v9, v2, 0.0, 0.0);
         rgpulse(pw, v8, 0.0, rof1);
         delay(dly3 - rof1 - pw - 1.5*pp);
         decpulse(pp, v3);
         if (d2 > 0.0)  
          delay(d2/2.0 - (2*pp/PI));  
         else  
          delay(d2/2.0);
      }

      if (iphase == 0)
         delay(dly3 - rof1);
      else
        {
         delay(dly3/2.0 - rof1 - 2.0*pp);
                                               /* composite C & H 180's */
         simpulse(pw, pp, zero, zero, rof1, 0.0);
         simpulse(2.67*pw, 2.0*pp, one, one, 0.0, 0.0);
         simpulse(pw, pp, zero, zero, 0.0, rof1);
         delay(dly3/2.0 - 2.0*rof1 - 2*pp - (2*pp/3.1416));
        }
         simpulse(pw, pp, v7, v4, rof1, rof2);
         delay(dly4/2.0 - 2.33*pp -(2*pp/PI) - rof2 - rof1);
       
       if (iphase != 0)  
         {
          simpulse(pw, pp, v7, zero, rof1, 0.0);
          simpulse(2.0*pw, 2.67*pp, v6, one, 0.0, 0.0);
          simpulse(pw, pp, v7, zero, 0.0, rof2);
         }
      rcvron();
	decpower(dpwr);
      delay(dly4/2.0 - POWER_DELAY - 2.33*pp);
 
/* Observe period */
   status(C);
}
Beispiel #7
0
void pulsesequence()
{
/* DECLARE VARIABLES */

  char  aliph[MAXSTR],	        /* aliphatic CHn groups only */
        arom[MAXSTR],		/* aromatic CHn groups only */
        wudec[MAXSTR],		/* automatic WURST decoupling */
        CNrefoc[MAXSTR],	/* flag for refocusing 15N during indirect H1 evolution */
        SBSUPR[MAXSTR],	        /* flag for side-band suppression (use 8 step phase cycle) */

        f1180[MAXSTR],	        /* Flag to start t1 @ halfdwell */
        mag_flg[MAXSTR],	/* magic angle gradient */
        f2180[MAXSTR];	        /* Flag to start t2 @ halfdwell */

  int   icosel,		        /* used to get n and p type */
        PRexp,                  /* projection-reconstruction flag */
        t1_counter,		/* used for states tppi in t1 */ 
        t2_counter;		/* used for states tppi in t2 */ 

  double csa, sna, tau1, tau2,	/*  t1 and t2 delays */   
         bw, ofs, ppm, pwd, nst,

        rfst = 0.0,			/* fine power level for adiabatic pulse initialized */
        slpwr = getval("slpwr"),        /* spinlock power level */
        slofs = getval("slofs"),        /* spinlock offset (in Hz) from carrier frequency */

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

        pra = M_PI*getval("pra")/180.0,
        jch = getval("jch"),		/*  CH coupling constant */
        ni2 = getval("ni2"),

        pwC = getval("pwC"),		/* PW90 for 13C nucleus @ pwClvl */
        pwClvl = getval("pwClvl"),	/* high power for 13C hard pulses on dec1  */
        pwC180 = getval("pwC180"),	/* PW180 for 13C nucleus in INEPT transfers */
        pwN = getval("pwN"),		/* PW90 for 15N nucleus @ pwNlvl */
        pwNlvl = getval("pwNlvl"),	/* high power for 15N hard pulses on dec2 */

        pwClw=getval("pwClw"), 
        pwNlw=getval("pwNlw"),
        pwZlw=0.0,			/* largest of pwNlw and 2*pwClw */

        mix  = getval("mix"),		/* tocsy mix time */
        sw1  = getval("sw1"),		/* spectral width in t1 (H) */
        sw2  = getval("sw2"),		/* spectral width in t2 (C) */
        gstab = getval("gstab"),	/* gradient recovery delay (300 us recom.) */
        gsign = 1.0,
        gzcal = getval("gzcal"),	/* dac to G/cm conversion factor */
        gt0 = getval("gt0"),
        gt1 = getval("gt1"),
        gt2 = getval("gt2"),
        gt3 = getval("gt3"),
        gt4 = getval("gt4"),
        gt5 = getval("gt5"),
        gt6 = getval("gt6"),
        gzlvl0 = getval("gzlvl0"),
        gzlvl1 = getval("gzlvl1"),
        gzlvl2 = getval("gzlvl2"),
        gzlvl3 = getval("gzlvl3"),
        gzlvl4 = getval("gzlvl4"),
        gzlvl5 = getval("gzlvl5"),
        gzlvl6 = getval("gzlvl6");

/* LOAD VARIABLES */

  getstr("aliph",aliph);
  getstr("arom",arom);
  getstr("wudec",wudec);
  getstr("CNrefoc",CNrefoc);

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


/* LOAD PHASE TABLE */
  settable(t1,2,phi1);
  settable(t2,4,phi2);
  settable(t3,8,phi3);
  settable(t4,4,rec);
  settable(t5,1,phi5);

/* CHECK VALIDITY OF PARAMETER RANGES */

    if((dm[A] == 'y' || dm[C] == 'y' ))
    {
        printf("incorrect 13C decoupler flags! dm='nnnn' or 'nnny' only  ");
        psg_abort(1);
    }

    if((dm2[A] == 'y' || dm2[C] == 'y' ))
    {
        printf("incorrect 15N decoupler flags! No decoupling in relax or mix periods  ");
        psg_abort(1);
    }

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

    if( dpwr2 > 49 )
    {
        printf("don't fry the probe, DPWR2 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( slpwr > 49.0 )
    {
        printf("dont fry the probe, spinlock strength too high ! ");
        psg_abort(1);
    } 

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

    if( gt0 > 15e-3 || gt1 > 15e-3 || gt2 > 15e-3 || gt3 > 15e-3 || gt4 > 15e-3 || gt5 > 15e-3 || gt6 > 15e-3 ) 
    {
        printf("gti values < 15e-3\n");
        psg_abort(1);
    } 

   if( gzlvl3*gzlvl4 > 0.0 ) 

    if (phase1 == 2)
      tsadd(t1,1,4);

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

/* set up Projection-Reconstruction experiment */
   
    PRexp = 0;      
    if((pra > 0.0) && (pra < 90.0)) PRexp = 1;

    csa = cos(pra);
    sna = sin(pra);
    
    if(PRexp)
    {
      tau1 = d2*csa;
      tau2 = d2*sna;
    }
    else
    {
      tau1 = d2;
      tau2 = d3;
    }

    if((f1180[A] == 'y') && (ni > 1.0))    /*  Set up f1180  tau1 = t1 */
      tau1 += 1.0/(2.0*sw1);
    tau1 = tau1/2.0;

    if((PRexp == 0) && (f2180[A] == 'y') && (ni2 > 1.0)) /*  Set up f2180  tau2 = t2 */
      tau2 += 1.0/(2.0*sw2);     
    tau2 = tau2/2.0;

    if(tau1 < 0.2e-7) tau1 = 2.0e-7;

/* 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(t4,2,4); }

   if(PRexp==0)
   {
     if( ix == 1) d3_init = d3 ;
     t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 );
     if(t2_counter % 2) { tsadd(t2,2,4); tsadd(t4,2,4); } 
   }
    

/* calculate 3db lower power hard pulses for simultaneous CN decoupling during
   indirect H1 evoluion pwNlw and pwClw should be calculated by the macro that 
   calls the experiment. */

   if (CNrefoc[A] == 'y')
   {
     if (pwNlw==0.0) pwNlw = compN*pwN*exp(3.0*2.303/20.0);
     if (pwClw==0.0) pwClw = compC*pwC*exp(3.0*2.303/20.0);
     if (pwNlw > 2.0*pwClw) pwZlw=pwNlw;
     else  pwZlw=2.0*pwClw;
   }


/* make sure gt3 and gt1 have always opposite sign to help dephasing H2O */

   if (gzlvl3*gzlvl1 > 0.0) gsign=-1.0;
     else gsign=1.0; 

   ppm = getval("dfrq"); ofs = 0.0; nst = 1000;     /* number of steps */       

   if(arom[A]=='y')                /* AROMATIC spectrum only */
     bw = 40.0*ppm;
   else if(aliph[A]=='y')          /* ALIPHATIC spectrum only */
     bw = 80.0*ppm;
   else    
   {
     bw = 0.1/(pwC*compC);       /* maximum bandwidth */
     bw = pwC180*bw*bw;  
   } 
     
   if(FIRST_FID) 
   {      
     adC180 = pbox_makeA("adC180", "wurst2i", bw, pwC180, ofs, compC*pwC, pwClvl, nst);   
     wuHmix = pbox_Adec("adsl", "amwurst", 0.0, mix, slofs, 0.0, 0.0);
     pwd = 0.0013;
     if(wudec[A]=='y') 
       wuCdec = pbox_Adec("wurstC", "WURST40", bw, pwd, ofs, compC*pwC, pwClvl);
   }          
   rfst = adC180.pwrf;
   wuHmix.pwr = slpwr;
   wuHmix.pwrf = 4095.0;

/* BEGIN ACTUAL PULSE SEQUENCE */


status(A);

   presat();
   obspower(tpwr);		/* Set transmitter power for hard 1H pulses */
   decpower(pwClvl);		/* Set Dec1 power for hard 13C pulses */
   dec2power(pwNlvl);		/* Set Dec2 power for decoupling during tau1 */
   decpwrf(4095.0);       
   dec2pwrf(4095.0);       

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

   decphase(zero);       
   dec2phase(zero);       
   rcvroff();
   delay(gstab);


status(B);
   rgpulse(pw, t1, rof1 ,rof1);                  /* 90 deg 1H pulse */
   txphase(zero); 

   if (ni > 0) 
    {
     if ((CNrefoc[A]=='y') && (tau1 > pwZlw +2.0*pw/PI +3.0*SAPS_DELAY +2.0*POWER_DELAY +2.0*rof1))
      {
       decpower(pwClvl-3.0); dec2power(pwNlvl-3.0);
       delay(tau1 -pwNlw -2.0*pw/PI -3.0*SAPS_DELAY -2.0*POWER_DELAY -2.0*rof1);

       if (pwNlw > 2.0*pwClw)
         {
	  dec2rgpulse(pwNlw -2.0*pwClw,zero,rof1,0.0);
	  sim3pulse(0.0,pwClw,pwClw,zero,zero,zero,0.0,0.0);
          decphase(one);
	  sim3pulse(0.0,2*pwClw,2*pwClw,zero,one,zero,0.0,0.0);
          decphase(zero);
	  sim3pulse(0.0,pwClw,pwClw,zero,zero,zero,0.0,0.0);
	  dec2rgpulse(pwNlw -2.0*pwClw,zero,0.0,rof1);
         }
	else
         {
	  decrgpulse(2.0*pwClw-pwNlw,zero,rof1,0.0);
	  sim3pulse(0.0,pwNlw-pwClw,pwNlw-pwClw,zero,zero,zero,0.0,0.0);
          decphase(one);
	  sim3pulse(0.0,2.0*pwClw,2.0*pwClw,zero,one,zero,0.0,0.0);
          decphase(zero);
	  sim3pulse(0.0,pwNlw-pwClw,pwNlw-pwClw,zero,zero,zero,0.0,0.0);
	  decrgpulse(2.0*pwClw-pwNlw,zero,0.0,rof1);
         }

       decpower(pwClvl); dec2power(pwNlvl);
       delay(tau1 -pwZlw -2.0*pw/PI -SAPS_DELAY -2.0*POWER_DELAY -2.0*rof1);
      }     
     else if (tau1 > 2.0*pwC +2.0*pw/PI +3.0*SAPS_DELAY +2.0*rof1)
      {
       delay(tau1 -2.0*pwC -2.0*pw/PI -3.0*SAPS_DELAY -2.0*rof1);

       decrgpulse(pwC, zero, rof1, 0.0);
       decphase(one);
       decrgpulse(2.0*pwC, one, 0.0, 0.0);
       decphase(zero);
       decrgpulse(pwC, zero, 0.0, rof1);

       delay(tau1 -2.0*pwC -2.0*pw/PI -SAPS_DELAY -2.0*rof1);
      }
     else if (tau1 > 2.0*pw/PI +2.0*SAPS_DELAY +rof1)
	  delay(2.0*tau1 -4.0*pw/PI -2.0*SAPS_DELAY -2.0*rof1);
    }

   rgpulse(pw, zero, rof1, rof1);             /*  2nd 1H 90 pulse   */
status(C);

   zgradpulse(gzlvl0,gt0);
   delay(gstab);
   
   obspower(slpwr);
   xmtron();
   obsprgon(wuHmix.name, 1.0/wuHmix.dmf, wuHmix.dres);
   delay(mix);
   obsprgoff(); xmtroff();

   decrgpulse(pwC,zero,2.0e-6,2.0e-6); 
   zgradpulse(-gzlvl0,gt0);
   obspower(tpwr);
   decpwrf(rfst);                           /* fine power for inversion pulse */
   delay(gstab);

/* FIRST HSQC INEPT TRANSFER */
   rgpulse(pw,zero,0.0,0.0);
   zgradpulse(gzlvl4, gt4);
   delay(1/(4.0*jch) -gt4 -2.0*GRADIENT_DELAY -WFG2_START_DELAY -pwC180*0.45);

   simshaped_pulse("","adC180",2*pw,pwC180,zero,zero,0.0,0.0);
   decphase(zero);

   zgradpulse(gzlvl4, gt4);
   decpwrf(4095.0);
   txphase(one);
   delay(1/(4.0*jch) -gt4 -2.0*GRADIENT_DELAY -pwC180*0.45 -PWRF_DELAY -SAPS_DELAY);

   rgpulse(pw,one,0.0,0.0);
   zgradpulse(gsign*gzlvl3, gt3);
   txphase(zero);
   delay(gstab);

/* C13 EVOLUTION */
   decrgpulse(pwC,t2,0.0,0.0);   

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

   decphase(zero);
   delay(gt1 +2.0*GRADIENT_DELAY +gstab -2.0*pw -SAPS_DELAY);
   decrgpulse(2*pwC,zero,0.0,0.0);

   if (mag_flg[A] == 'y')  magradpulse(gzcal*gzlvl1, gt1);
     else  zgradpulse(gzlvl1, gt1);
   decphase(t5);
   delay(gstab);

   decrgpulse(pwC,t5,0.0,0.0);
   delay(pw);
   rgpulse(pw,zero,0.0,0.0);

   zgradpulse(gzlvl5, gt5);
   decphase(zero);
   delay(1/(8.0*jch) -gt5 -SAPS_DELAY -2.0*GRADIENT_DELAY);		/* d3 = 1/8*Jch */

   decrgpulse(2.0*pwC,zero,0.0,2.0e-6);
   rgpulse(2.0*pw,zero,0.0,0.0);

   zgradpulse(gzlvl5, gt5);
   decphase(one);
   txphase(one);
   delay(1/(8.0*jch) -gt5 -2.0*SAPS_DELAY -2.0*GRADIENT_DELAY);		/* d3 = 1/8*Jch */

   delay(pwC);
   decrgpulse(pwC,one,0.0,2.0e-6);
   rgpulse(pw,one,0.0,0.0);

   zgradpulse(gzlvl6, gt6);
   decpwrf(rfst);                           /* fine power for inversion pulse */
   decphase(zero);
   txphase(zero);
   delay(1/(4.0*jch) -gt6 -pwC180*0.45 -PWRF_DELAY 
		-WFG2_START_DELAY -2.0*SAPS_DELAY -2.0*GRADIENT_DELAY);	/* d2 = 1/4*Jch */

   simshaped_pulse("","adC180",2*pw,pwC180,zero,zero,0.0,0.0);
   decphase(zero);

   zgradpulse(gzlvl6, gt6);
   decpwrf(4095.0);
   delay(1/(4.0*jch) -gt6 -pwC180*0.45 -PWRF_DELAY -2.0*GRADIENT_DELAY);	/* d2 = 1/4*Jch */

   rgpulse(pw,zero,0.0,0.0);  

   if (SBSUPR[A]=='y') delay(gt2 +gstab +2.0*GRADIENT_DELAY +2.0*pwC 
					+SAPS_DELAY +rof2 +POWER_DELAY);
   else delay(gt2 +gstab +2.0*GRADIENT_DELAY +POWER_DELAY);

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

   if (mag_flg[A] == 'y')  magradpulse(icosel*gzcal*gzlvl2, gt2);
     else  zgradpulse(icosel*gzlvl2, gt2);
   delay(gstab);

   if (SBSUPR[A]=='y') {
       decrgpulse(pwC,zero,0.0,0.0);     
       decphase(t3);
       decrgpulse(pwC,t3,0.0,rof2);     
      }

   setreceiver(t4);
   rcvron();
   if ((wudec[A]=='y') && (dm[D] == 'y'))
   {
     decpower(wuCdec.pwr+3.0);
     decprgon("wurstC", 1.0/wuCdec.dmf, wuCdec.dres);
     decon();
   }
   else	
   { 
     decpower(dpwr);
     status(D);
   }
}
Beispiel #8
0
pulsesequence()
{
  /* DECLARE AND LOAD VARIABLES */

  char f1180[MAXSTR],		/* Flag to start t1 @ halfdwell */
       f2180[MAXSTR],		/* Flag to start t2 @ halfdwell */
       H2Opurge[MAXSTR], stCdec[MAXSTR],	/* calls STUD+ waveforms from shapelib */
       STUD[MAXSTR];		/* apply automatically calculated STUD decoupling */

  int t1_counter,		/* used for states tppi in t1 */
      t2_counter;		/* used for states tppi in t2 */

  double tau1,			/*  t1 delay */
         BPdpwrspinlock,        /*  user-defined upper limit for spinlock(Hz) */
         BPpwrlimits,           /*  =0 for no limit, =1 for limit             */
         tau2,			/*  t2 delay */
         ni = getval("ni"), ni2 = getval("ni2"),
	 stdmf = getval("dmf80"),	/* dmf for 80 ppm of STUD decoupling */
         rf80 = getval("rf80"),	/* rf in Hz for 80ppm STUD+ */
         taua = getval("taua"),	/* time delays for CH coupling evolution */
         taub = getval("taub"), tauc = getval("tauc"),
	 /* string parameter stCdec calls stud decoupling waveform from your shapelib. */
         studlvl,		/* coarse power for STUD+ decoupling */
         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-3 at rfd  */
         rfd,			/* fine power for 9.0 kHz rf at 600MHz         */
         ncyc = getval("ncyc"),	/* no. of cycles of DIPSI-3 */
         spinlock = getval("spinlock"),		/* DIPSI-3 Field Strength in Hz */
	 /* the following pulse length for the SLP pulse is automatically calculated   */
	 /* by the macro "hcch_tocsy".  The SLP pulse shape,"offC10" is called         */
	 /* directly from your shapelib.                                               */
         pwC10 = getval("pwC10"),	/* 180 degree selective sinc pulse on CO(174ppm) */
         rf7,			/* fine power for the pwC10 ("offC10") pulse */
         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 */
         sw1 = getval("sw1"), sw2 = getval("sw2"),
	 gt0 = getval("gt0"),	/* other gradients */
         gt3 = getval("gt3"), gt4 = getval("gt4"), gt5 = getval("gt5"),
         gt7 = getval("gt7"), gzlvl0 = getval("gzlvl0"), gzlvl3 = getval("gzlvl3"),
         gzlvl4 = getval("gzlvl4"), gzlvl5 = getval("gzlvl5"), gzlvl6 = getval("gzlvl6"),
         gzlvl7 = getval("gzlvl7");

  getstr("f1180", f1180);
  getstr("f2180", f2180);
  getstr("H2Opurge", H2Opurge);
  getstr("STUD", STUD);
  /* 80 ppm STUD+ decoupling */
  strcpy(stCdec, "stCdec80");
  studlvl = pwClvl + 20.0 * log10(compC * pwC * 4.0 * rf80);
  studlvl = (int) (studlvl + 0.5);

  P_getreal(GLOBAL,"BPpwrlimits",&BPpwrlimits,1);
  P_getreal(GLOBAL,"BPdpwrspinlock",&BPdpwrspinlock,1);

  /*   LOAD PHASE TABLE    */
  settable(t3, 2, phi3);
  settable(t5, 4, phi5);
  settable(t9, 8, phi9);
  settable(t11, 8, rec);


  /*   INITIALIZE VARIABLES   */
  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 > (25.0e-6 * 600.0 / sfrq)) && (ncyc > 0.0))
  {
    printf("Increase pwClvl so that pwC < 25*600/sfrq");
    psg_abort(1);
  }

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

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

  if (spinlock < 1000.0)
  {
    printf("Spinlock seems too low. Please check spinlock value ! ");
    psg_abort(1);
  }

  /* dipsi-3 spinlock 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);
/*************************For Ultra-High Field Probes***************************/
if (sfrq>590.0)
{
 if (ncyc>2)
  {
    if (pwC>15)
     {
      if (rfd > 2000)
       {
        printf("spinlock too large. Lower value for probe protection");
        psg_abort(1);
       }
     }
    else
     {
      if (pwC>14)
       {
        if (rfd > 1800)
         {
          printf("spinlock too large. Lower value for probe protection");
          psg_abort(1);
         }
       }
      else
       {
        if (pwC>13)
         {
          if (rfd > 1600)
           {
            printf("spinlock too large. Lower value for probe protection");
            psg_abort(1);
           }
         }
        else
         {
          if (pwC>12)
           {
            if (rfd > 1400)
             {
               printf("spinlock too large. Lower value for probe protection");
               psg_abort(1);
             }
           }
          else
           {
            if (pwC>11)
             {
              if (rfd > 1200)
               {
                printf("spinlock too large. Lower value for probe protection");
                psg_abort(1);
               }
             }
            else
             {
                if (rfd > 1000)
                 {
                  printf("spinlock too large. Lower value for probe protection");
                  psg_abort(1);
                 }
             }
           }
         }    
       }
     }
  }
 else 
  {
   if (ncyc == 2)
    {
     if (pwC>15)
      {
       if (rfd > 2200)
        {
         printf("spinlock too large. Lower value for probe protection");
         psg_abort(1);
        }
      }
     else
      {
       if (pwC>14)
        {
         if (rfd > 2000)
          {
           printf("spinlock too large. Lower value for probe protection");
           psg_abort(1);
          }
        }
       else
        {
         if (pwC>13)
          {
           if (rfd > 1800)
            {
             printf("spinlock too large. Lower value for probe protection");
             psg_abort(1);
            }
          }
         else
          {
           if (pwC>12)
            {
             if (rfd > 1600)
              {
                printf("spinlock too large. Lower value for probe protection");
                psg_abort(1);
              }
            }
           else
            {
             if (pwC>11)
              {
               if (rfd > 1400)
                {
                 printf("spinlock too large. Lower value for probe protection");
                 psg_abort(1);
                }
              }
             else
              {
                 if (rfd > 1200)
                  {
                   printf("spinlock too large. Lower value for probe protection");
                   psg_abort(1);
                  }
              }
            }
          }    
        }
      }
     }
   else
    {
     if (ncyc == 1)
      {
       if (pwC>15)
        {
         if (rfd > 2400)
          {
           printf("spinlock too large. Lower value for probe protection");
           psg_abort(1);
          }
        }
       else
        {
         if (pwC>14)
          {
           if (rfd > 2200)
            {
             printf("spinlock too large. Lower value for probe protection");
             psg_abort(1);
            }
          }
         else
          {
           if (pwC>13)
            {
             if (rfd > 2000)
              {
               printf("spinlock too large. Lower value for probe protection");
               psg_abort(1);
              }
            }
           else
            {
             if (pwC>12)
              {
               if (rfd > 1800)
                {
                  printf("spinlock too large. Lower value for probe protection");
                  psg_abort(1);
                }
              }
             else
              {
               if (pwC>11)
                {
                 if (rfd > 1600)
                  {
                   printf("spinlock too large. Lower value for probe protection");
                   psg_abort(1);
                  }
                }
               else
                {
                   if (rfd > 1400)
                    {
                     printf("spinlock too large. Lower value for probe protection");
                     psg_abort(1);
                    }
                }
              }
            }       
          }
        }
      }
    }

  }


}
/*********************End: For Ultra-High Field Probes***************************/

  /* CHECK VALIDITY OF PARAMETER RANGES */

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

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

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

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

  if (pw > 80.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 */
  if (phase1 == 2)
    tsadd(t3, 1, 4);
  if (phase2 == 2)
    tsadd(t5, 1, 4);

  /*  C13 TIME INCREMENTATION and set up f1180  */

  /*  Set up f1180  */
  tau1 = d2;

  if (f1180[A] == 'y')
  {
    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')
  {
    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(t11, 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(t11, 2, 4);
  }



  /*   BEGIN PULSE SEQUENCE   */

  status(A);
  if (dm3[B] == 'y')
    lk_sample();
  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 */
  delay(d1);
  if (dm3[B] == 'y')
  {
    lk_hold();
    lk_sampling_off();
  }				/*freezes z0 correction, stops lock pulsing */
  rcvroff();

  obspower(tpwr);
  decpower(pwClvl);
  dec2power(pwNlvl);
  decpwrf(rf0);
  obsoffset(tof);
  txphase(t3);
  delay(1.0e-5);

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

  if (dm3[B] == 'y')		/* begins optional 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);
  }

  rgpulse(pw, t3, 0.0, 0.0);	/* 1H pulse excitation */
  zgradpulse(gzlvl0, gt0);	/* 2.0*GRADIENT_DELAY */
  decphase(zero);
  delay(taua + tau1 - gt0 - 2.0 * GRADIENT_DELAY - 2.0 * pwC);
  decrgpulse(2.0 * pwC, zero, 0.0, 0.0);
  txphase(zero);
  delay(tau1);
  rgpulse(2.0 * pw, zero, 0.0, 0.0);
  zgradpulse(gzlvl0, gt0);
  txphase(one);
  decphase(t5);
  delay(taua - gt0);
  rgpulse(pw, one, 0.0, 0.0);
  zgradpulse(gzlvl3, gt3);
  delay(2.0e-4);
  decrgpulse(pwC, t5, 0.0, 0.0);
  delay(tau2);
  dec2rgpulse(2.0 * pwN, zero, 0.0, 0.0);
  zgradpulse(gzlvl4, gt4);	/* 2.0*GRADIENT_DELAY */
  decphase(zero);
  decpwrf(rf7);
  delay(taub - 2.0 * pwN - gt4 - 2.0 * GRADIENT_DELAY);
  decshaped_pulse("offC10", pwC10, zero, 0.0, 0.0);
  txphase(zero);
  decpwrf(rf0);
  delay(taub - 2.0 * pw);
  rgpulse(2.0 * pw, zero, 0.0, 0.0);
  delay(tau2);
  decrgpulse(2.0 * pwC, zero, 0.0, 0.0);
  decpwrf(rf7);
  delay(taub);
  decshaped_pulse("offC10", pwC10, zero, 0.0, 0.0);
  zgradpulse(gzlvl4, gt4);	/* 2.0*GRADIENT_DELAY */
  delay(taub - gt4 - 2.0 * GRADIENT_DELAY);
  decpwrf(rfd);
  decrgpulse(1.0e-3, zero, 0.0, 0.0);
  if (ncyc>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();
  }
  decrgpulse(9.0 * p_d / 5.0, t9, 2.0e-6, 0.0);
  if (H2Opurge[A] == 'y')
  {
    obspwrf(1000);
    rgpulse(900 * pw, zero, 0.0, 0.0);
    rgpulse(500 * pw, one, 0.0, 0.0);
    obspwrf(4095.0);
  }
  zgradpulse(gzlvl7, gt7);
  decpwrf(rf0);
  delay(50.0e-6);
  rgpulse(pw, zero, 0.0, 0.0);
  zgradpulse(gzlvl7, gt7 / 1.6);
  decrgpulse(pwC, three, 100.0e-6, 0.0);
  zgradpulse(gzlvl5, gt5);
  decphase(zero);
  delay(tauc - gt5);
  simpulse(2.0 * pw, 2.0 * pwC, zero, zero, 0.0, 0.0);
  zgradpulse(gzlvl5, gt5);
  delay(tauc - gt5);
  decrgpulse(pwC, zero, 0.0, 0.0);
  zgradpulse(gzlvl3, gt3);
  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 */
  }
  delay(2.0e-4);
  rgpulse(pw, zero, 0.0, 0.0);
  zgradpulse(gzlvl6, gt5);
  delay(taua - gt5 + rof1);
  simpulse(2.0 * pw, 2.0 * pwC, zero, zero, 0.0, rof1);
  zgradpulse(gzlvl6, gt5);
  if (STUD[A] == 'y')
    decpower(studlvl);
  else
    decpower(dpwr);
  dec2power(dpwr2);
  delay(taua - gt5 - 2.0 * POWER_DELAY);
  rgpulse(pw, zero, 0.0, rof2);
  rcvron();
  if (dm3[B] == 'y')
    lk_sample();
  setreceiver(t11);
  if ((STUD[A] == 'y') && (dm[C] == 'y'))
  {
    decprgon(stCdec, 1.0 / stdmf, 1.0);
    decon();
    if (dm2[C] == 'y')
    {
      setstatus(DEC2ch, TRUE, dmm2[C], FALSE, dmf2);
    }
  }
  else
    status(C);
}
pulsesequence()
{
   char   
          shname1[MAXSTR],
	  f1180[MAXSTR],
	  f2180[MAXSTR],
          n15_flg[MAXSTR],
          CT_flg[MAXSTR];


   int    icosel,
          t1_counter,
          t2_counter,
          ni2 = getval("ni2"),
          phase;


   double d2_init=0.0,
          d3_init=0.0,
          pwS1,pwS2,pwS3,pwS4,pwS5,pwS6,
          kappa,
          lambda = getval("lambda"),
          CTdelay = getval("CTdelay"),
          gzlvl1 = getval("gzlvl1"),
          gzlvl2 = getval("gzlvl2"), 
          gzlvl4 = getval("gzlvl4"), 
          gzlvl5 = getval("gzlvl5"), 
          gzlvl6 = getval("gzlvl6"), 
          gt1 = getval("gt1"),
          gt4 = getval("gt4"),
          gt5 = getval("gt5"),
          gt6 = getval("gt6"),
          gstab = getval("gstab"),
          scale = getval("scale"),
          sw1 = getval("sw1"),
          tpwrsf = getval("tpwrsf"),
          shlvl1,
          shpw1 = getval("shpw1"),
          pwC = getval("pwC"),
          pwClvl = getval("pwClvl"),
          pwNlvl = getval("pwNlvl"),
          pwN = getval("pwN"),
          dpwr2 = getval("dpwr2"),
          d2 = getval("d2"),
          t2a,t2b,halfT2,
          t1a,t1b,halfT1,
          shbw = getval("shbw"),
          shofs = getval("shofs")-4.77,
          timeTN = getval("timeTN"),
          timeTN1 = getval("timeTN1"),
          timeCN = getval("timeCN"),
          tauC = getval("tauC"),
          tauCC = getval("tauCC"),
          tau1 = getval("tau1"),
          tau2 = getval("tau2"),
          taunh = getval("taunh");



   getstr("shname1", shname1);
   getstr("f1180",f1180);
   getstr("f2180",f2180);
   getstr("n15_flg",n15_flg);
   getstr("CT_flg",CT_flg);



  phase = (int) (getval("phase") + 0.5);
   
   settable(t1,2,phi1);
   settable(t2,4,phi2);
   settable(t3,1,phi3);
   settable(t4,8,phi4);
   settable(t5,1,phi5);
   settable(t14,8,phi14);
   settable(t24,8,phi24);


/*   INITIALIZE VARIABLES   */
   kappa = 5.4e-3;
   //shpw1 = pw*8.0;
   shlvl1 = tpwr;
   f1180[0] ='n'; 
   f2180[0] ='n'; 

   pwS1 = c13pulsepw("co", "ca", "sinc", 90.0);
   pwS2 = c13pulsepw("co", "ca", "sinc", 180.0);
   pwS3 = c13pulsepw("ca", "co", "square", 180.0);
   pwS4 = h_shapedpw("eburp2",shbw,shofs,zero, 0.0, 0.0);
   pwS6 = h_shapedpw("reburp",shbw,shofs,zero, 0.0, 0.0);
   pwS5 = h_shapedpw("pc9f",shbw,shofs,zero, 2.0e-6, 0.0);



  if (phase == 1) ;
  if (phase == 2) {tsadd(t1,1,4);}

if   ( phase2 == 2 )
        {
        tsadd ( t3,2,4  );
        tsadd ( t5,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; }
    tau1 = tau1;


/*  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;

/************************************************************/

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

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


/************************************************************/
/* Set up CONSTANT/SEMI-CONSTANT time evolution in N15 */
/************************************************************/

   if (ni2 > 1)
   {
   halfT2 = 0.5*(ni2-1)/sw2;
   t2b = (double) t2_counter*((halfT2 - timeTN)/((double)(ni2-1)));
   if( ix==1 && halfT2 - timeTN > 0 ) printf("SCT mode on, max ni2=%g\n",timeTN*sw2*2+1);
    if(t2b < 0.0) t2b = 0.0;
    
    t2a = timeTN - tau2*0.5 + t2b;
    if(t2a < 0.2e-6)  t2a = 0.0;
    }
    else
    {
    t2b = 0.0;
    t2a = timeTN - tau2*0.5;
    }

/************************************************************/
   if (ni > 1)
   {
   halfT1 = 0.5*(ni-1)/sw1;
   t1b = (double) t1_counter*((halfT1 - timeTN1)/((double)(ni-1)));
    if(t1b < 0.0) t1b = 0.0;
    t1a = timeTN1 - tau1*0.5 + t1b;
    if(t1a < 0.2e-6)  t1a = 0.0;
    }
    else
    {
    t1b = 0.0;
    t1a = timeTN1 - tau1*0.5;
    }
/************************************************************/


   status(A);
      rcvroff();  

   decpower(pwClvl);
   decoffset(dof);
   dec2power(pwNlvl);
   dec2offset(dof2);
   obspwrf(tpwrsf);
   decpwrf(4095.0);
   obsoffset(tof);
   set_c13offset("co");


      dec2rgpulse(pwN*2.0,zero,0.0,0.0);
     zgradpulse(1.7*gzlvl4, gt4);
       delay(1.0e-4);

lk_sample();
       delay(d1-gt4);
lk_hold();
        h_shapedpulse("pc9f",shbw,shofs,zero, 2.0e-6, 0.0);

        delay(lambda-pwS5*0.5-pwS6*0.5);

        h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, one, zero, zero, 0.0, 0.0);

        delay(lambda-pwS5*0.5-pwS6*0.5);

   if(n15_flg[0]=='y') h_shapedpulse("pc9f_",shbw,shofs,three, 0.0, 0.0);
     else h_shapedpulse("pc9f_",shbw,shofs,one, 0.0, 0.0);

         shaped_pulse(shname1,shpw1,zero,0.0,0.0);

           zgradpulse(2.3*gzlvl4, gt4);
           delay(1.0e-4);
/**************************************************************************/
/***         N -> CO transfer             *********************************/
/**************************************************************************/
      dec2rgpulse(pwN,t1,0.0,0.0);

           delay(tau1*0.5);
         c13pulse("ca", "co", "square", 180.0, zero, 0.0, 0.0);
         delay(taunh-pwS3);
         shaped_pulse(shname1,shpw1,two,0.0,0.0);
         delay(timeTN1-pwS2-taunh-shpw1);
        c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);
        delay (t1b);
        dec2rgpulse (2.0*pwN, zero, 0.0, 0.0);
        delay (t1a);

     dec2rgpulse(pwN,zero,0.0,0.0);
/**************************************************************************/
/***        CO -> CA transfer             *********************************/
/**************************************************************************/
        c13pulse("co", "ca", "sinc", 90.0, t2, 2.0e-6, 0.0);

        zgradpulse(-gzlvl4, gt4);
        decphase(zero);
        delay(tauC - gt4 - 0.5*10.933*pwC);

        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);

        zgradpulse(-gzlvl4, gt4);
        decphase(one);
        delay(tauC - gt4 - 0.5*10.933*pwC - WFG_START_DELAY - 2.0e-6);
        c13pulse("co", "ca", "sinc", 90.0, one, 0.0, 0.0);
/**************************************************************************/
/***        CA -> N transfer             *********************************/
/**************************************************************************/
        set_c13offset("ca");

        c13pulse("ca", "co", "square", 90.0, zero, 2.0e-6, 0.0);
        delay(tauC);
        c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);
        delay(timeCN-tauC);
   sim3_c13pulse("", "cab", "co", "square", "", 0.0, 180.0, 2.0*pwN, zero, zero, zero, 2.0e-6, 2.0e-6);
        delay(timeCN);
        c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);
        c13pulse("ca", "co", "square", 90.0, one, 2.0e-6, 0.0);


/**************************************************************************/
/***        N -> CA back transfer         *********************************/
/**************************************************************************/
     dec2rgpulse(pwN,t4,0.0,0.0);

           delay(tau2*0.5);
         c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);
         //delay(timeTN-pwS3-pwS2-gt1-1.0e-4);
       
        delay(timeTN-pwS3-pwS2-gt1-1.0e-4-2.0*GRADIENT_DELAY-4*POWER_DELAY-4*PWRF_DELAY-(4/PI)*pwN);
         zgradpulse(-gzlvl1, gt1); 
       delay(1.0e-4);
        c13pulse("ca", "co", "square", 180.0, zero, 0.0, 0.0);
        delay (t2b);
        dec2rgpulse (2.0*pwN, zero, 0.0, 0.0);
        delay (t2a);

/**************************************************************************/
        delay(gt1/10.0+1.0e-4);
        h_shapedpulse("eburp2_",shbw,shofs,t3, 2.0e-6, 0.0);

        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.5-pwS4*scale- gt5);

        h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.5-pwS4*scale- gt5);

        h_shapedpulse("eburp2",shbw,shofs,zero, 0.0, 0.0);
        delay(gt1/10.0+1.0e-4);

     dec2rgpulse(pwN,one,0.0,0.0);
        zgradpulse(gzlvl6, gt6);

        txphase(zero);
        delay(lambda-pwS6*0.5-gt6);

        h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);
        zgradpulse(gzlvl6, gt6);

        delay(lambda-pwS6*0.5-gt6);
     dec2rgpulse(pwN,t5,0.0,0.0);
/**************************************************************************/

        zgradpulse(-icosel*gzlvl2, gt1/10.0);
        dec2power(dpwr2);                                      /* POWER_DELAY */
lk_sample();
 if (n15_flg[0] =='y')
{
   setreceiver(t14);
}
else
{
   setreceiver(t24);
}

      rcvron();
statusdelay(C,1.0e-4 );

}		 
Beispiel #10
0
void pulsesequence()
{
   double          ss,
                   arraydim,
                   p1lvl,
                   trim,
                   mix,
                   window,
                   cycles,
                   phase;
   int             iphase;
   char            sspul[MAXSTR];


/* LOAD AND INITIALIZE VARIABLES */
   ni = getval("ni");
   arraydim = getval("arraydim");
   mix = getval("mix");
   trim = getval("trim");
   phase = getval("phase");
   iphase = (int) (phase + 0.5);
   p1lvl = getval("p1lvl");
   ss = getval("ss");
   window=getval("window");
   getstr("sspul", sspul);

   if (iphase == 3)
   {
      initval((double)((int)((ix-1)/(arraydim/ni)+1.0e-6)), v14);
   }
   else
   {
      assign(zero, v14);
   }


/* CHECK CONDITIONS */
   if ((iphase != 3) && (arrayelements > 2))
   {
      fprintf(stdout, "PHASE=3 is required if MIX is arrayed!\n");
      psg_abort(1);
   }
   if (satdly > 9.999)
   {
      fprintf(stdout, "Presaturation period is too long.\n");
      psg_abort(1);
   }
   if (!newtransamp)
   {
      fprintf(stdout, "TOCSY requires linear amplifiers on transmitter.\n");
      fprintf(stdout, "Use DECTOCSY with the appropriate re-cabling,\n");
      psg_abort(1);
   }
   if ((p1 == 0.0) && (ix == 1))
      fprintf(stdout, "Warning:  P1 has a zero value.\n");
   if ((rof1 < 9.9e-6) && (ix == 1))
      fprintf(stdout,"Warning:  ROF1 is less than 10 us\n");

   if (satpwr > 40)
        {
         printf("satpwr too large  - acquisition aborted./n");
         psg_abort(1);
        }

/* DETERMINE STEADY-STATE MODE */
   if (ss < 0)
   {
      ss = (-1) * ss;
   }
   else
   {   
      if ((ss > 0) && (ix == 1))
      {
         ss = ss;
      }
      else
      {   
         ss = 0;
      }
   }
   initval(ss, ssctr);
   initval(ss, ssval);


/* STEADY-STATE PHASECYCLING */
/* This section determines if the phase calculations trigger off of (SS - SSCTR)
   or off of CT */

   ifzero(ssctr);
      hlv(ct, v13);
      mod2(ct, v1);
      hlv(ct, v2);
   elsenz(ssctr);
      sub(ssval, ssctr, v12);	/* v12 = 0,...,ss-1 */
      hlv(v12, v13);
      mod2(v12, v1);
      hlv(v12, v2);
   endif(ssctr);


/* CALCULATE PHASES */
/* A 2-step cycle is performed on the first pulse (90 degrees) to suppress
   axial peaks in the first instance.  Second, the 2-step F2 quadrature image
   suppression subcycle is added to all pulse phases and receiver phase.
   Finally, a 2-step cycle is performed on the spin-lock pulses. */

   mod2(v13, v13);
   dbl(v1, v1);
   incr(v1);
   hlv(v2, v2);
   mod2(v2, v2);
   dbl(v2, v2);
   incr(v2);
   add(v13, v2, v2);
   sub(v2, one, v3);
   add(two, v2, v4);
   add(two, v3, v5);
   add(v1, v13, v1);
   assign(v1, oph);
   if (iphase == 2)
      incr(v1);
   if (iphase == 3)
      add(v1, v14, v1);

 /*HYPERCOMPLEX MODE USES REDFIELD TRICK TO MOVE AXIAL PEAKS TO EDGE*/
   initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v6);
   if ((iphase==1)||(iphase==2)) {add(v1,v6,v1); add(oph,v6,oph);} 

/* CALCULATE AND INITIALIZE LOOP COUNTER */
      if (pw > 0.0)
      {
         cycles = (mix - trim) / (64.66*pw+32*window);
         cycles = 2.0*(double) (int) (cycles/2.0);
      }
      else
      {
         cycles = 0.0;
      }
      initval(cycles, v9);			/* V9 is the MIX loop count */

/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   status(A);
      rlpower(p1lvl, TODEV);
      if (sspul[0] == 'y')
      {
         rgpulse(1000*1e-6, zero, rof1, 0.0e-6);
         rgpulse(1000*1e-6, one, 0.0e-6, rof1);
      }
      hsdelay(d1);
if (getflag("wet")) wet4(zero,one);
rlpower(p1lvl, TODEV);
     if (satmode[A] == 'y')
     { rlpower(satpwr,TODEV);
      rgpulse(satdly,zero,rof1,rof2);
      rlpower(p1lvl,TODEV);}
   status(B);
      rgpulse(p1, v1, rof1, 1.0e-6);
      if (satmode[B] =='y')
       {
        if (d2 > 0.0)
         {
           rlpower(satpwr,TODEV);
           rgpulse(d2 - (2*POWER_DELAY) - 1.0e-6 - (2*p1/3.1416),zero,0.0,0.0);
         }
       }
      else
       {
        if (d2 > 0.0)
          delay(d2 - POWER_DELAY - 1.0e-6  - (2*p1/3.1416));
       } 
      rcvroff();
      rlpower(tpwr,TODEV); 
      txphase(v13);
      xmtron();
      delay(trim);
      if (cycles > 1.0)
      {
         starthardloop(v9);
            mleva(window); mleva(window); mlevb(window); mlevb(window);
            mlevb(window); mleva(window); mleva(window); mlevb(window);
            mlevb(window); mlevb(window); mleva(window); mleva(window);
            mleva(window); mlevb(window); mlevb(window); mleva(window);
            rgpulse(.66*pw,v3,rof1,rof2);
         endhardloop();
      }
      txphase(v13);
      xmtroff();

/* detection */
      delay(rof2);
      rcvron();
   status(C);
}
Beispiel #11
0
pulsesequence()
{
   char   
          shname1[MAXSTR],
	  f1180[MAXSTR],
	  f2180[MAXSTR],
          SE_flg[MAXSTR];

   int    icosel = 0,
          t1_counter,
          t2_counter,
          ni2 = getval("ni2"),
          phase;


   double d2_init=0.0,
          d3_init=0.0,
          pwS1,pwS2,pwS3,pwS4,pwS5,pwS6,pwS7,pwS8,
          lambda = getval("lambda"),
          gzlvl1 = getval("gzlvl1"),
          gzlvl2 = getval("gzlvl2"), 
          gzlvl3 = getval("gzlvl3"), 
          gzlvl4 = getval("gzlvl4"), 
          gzlvl5 = getval("gzlvl5"), 
          gzlvl6 = getval("gzlvl6"), 
          gt1 = getval("gt1"),
          gt3 = getval("gt3"),
          gt4 = getval("gt4"),
          gt5 = getval("gt5"),
          gt6 = getval("gt6"),
          gstab = getval("gstab"),
          shlvl1 = getval("shlvl1"),
          shpw1 = getval("shpw1"),
          pwClvl = getval("pwClvl"),
          pwNlvl = getval("pwNlvl"),
          pwN = getval("pwN"),
          d2 = getval("d2"),
          timeTN = getval("timeTN"),
          Delta,
          tauNCO = getval("tauNCO"),
          tauC = getval("tauC"),
          tau1 = getval("tau1"),
          tau2 = getval("tau2"),
          taunh = getval("taunh");



   getstr("shname1", shname1);
   getstr("SE_flg",SE_flg);
   getstr("f1180",f1180);
   getstr("f2180",f2180);

  phase = (int) (getval("phase") + 0.5);
   
   settable(t1,2,phi1);
   settable(t2,1,phi2);
   settable(t3,4,phi3);
   settable(t4,8,phi4);
   settable(t10,1,phi10);
   settable(t12,8,phi12);
   settable(t13,8,phi13);

/*   INITIALIZE VARIABLES   */

  Delta = timeTN-tauNCO;

   pwS1 = c13pulsepw("ca", "co", "square", 90.0);
   pwS2 = c13pulsepw("ca", "co", "square", 180.0);
   pwS3 = c13pulsepw("co", "ca", "sinc", 180.0);
   pwS7 = c13pulsepw("co", "ca", "sinc", 90.0);
   pwS8 = c_shapedpw("reburp",60.0 ,-135.0,zero, 0.0, 0.0);
   pwS4 = h_shapedpw("eburp2",4.0,3.5,zero, 0.0, 0.0);  
   pwS6 = h_shapedpw("reburp",4.0,3.5,zero, 0.0, 0.0);
   pwS5 = h_shapedpw("pc9f",4.0,3.5,zero, 2.0e-6, 0.0);



if (SE_flg[0] == 'y')
{
   if ( ni2*1/(sw2)/2.0 > (timeTN-Delta-pwS3-pwS4))
       { printf(" ni2 is too big. Make ni2 equal to %d or less.\n",
         ((int)((timeTN-Delta-pwS3-pwS4)*2.0*sw2)));    psg_abort(1);}
}
else
{

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



  if (phase == 1) ;
  if (phase == 2) {tsadd(t1,1,4);}

if (SE_flg[0] =='y')
{
  if (phase2 == 2)  {tsadd(t10,2,4); icosel = +1;}
            else 			       icosel = -1;   
}
else
{
  if (phase2 == 2) {tsadd(t3,1,4); icosel = 1;}
}
 

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

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

  
    


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

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



   status(A);
   decpower(pwClvl);
   dec2power(pwNlvl);
   set_c13offset("co");
   zgradpulse(gzlvl6, gt6);
   delay(1.0e-4);
   delay(d1-gt6);
lk_hold();
   rcvroff();

        h_shapedpulse("pc9f",4.0,3.5,zero, 2.0e-6, 0.0);  

	delay(lambda-pwS5*0.5-pwS6*0.4); 

   	h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, one, zero, zero, 0.0, 0.0);

	delay(lambda-pwS5*0.5-pwS6*0.4);

        h_shapedpulse("pc9f_",4.0,3.5,one, 2.0e-6, 0.0);  


   obspower(shlvl1);
/**************************************************************************/
/*   xxxxxxxxxxxxxxxxxxxxxx   N-> CA transfer           xxxxxxxxxxxxxxxxxx    */
/**************************************************************************/
   set_c13offset("ca");
      dec2rgpulse(pwN,zero,0.0,0.0);

           delay(timeTN);

      sim3_c13pulse("", "ca", "co", "square", "", 0.0, 180.0, 2.0*pwN,
                                             zero, zero, zero, 2.0e-6, 2.0e-6);

           delay(Delta);
	c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);      
           delay(timeTN-Delta-pwS3-taunh*0.5-shpw1);
        shaped_pulse(shname1,shpw1,two,0.0,0.0);
           delay(taunh*0.5);

     dec2rgpulse(pwN,zero,0.0,0.0);				     
        shaped_pulse(shname1,shpw1,zero,0.0,0.0);
/**************************************************************************/
/*   xxxxxxxxxxxxxxxxxxxxxx       CA->CO TRANSFER       xxxxxxxxxxxxxxxxxx    */
/**************************************************************************/
       set_c13offset("ca");
        c13pulse("ca", "co", "square", 90.0, t2, 2.0e-6, 0.0);
/*
        initval(0.0, v2);
        decstepsize(1.0);
        dcplrphase(v2);
*/

           zgradpulse(gzlvl4, gt4);
        delay(tauC*0.5-gt4);
 
       c_shapedpulse2("isnob5",20.0,0.0,"isnob5",20.0,119.0,zero,0.0,0.0);

           zgradpulse(gzlvl4, gt4);

        delay(tauC-gt4);
       c_shapedpulse2("isnob5",20.0,0.0,"isnob5",20.0,119.0,two,0.0,0.0);
        delay(tauC*0.5);

        c13pulse("ca", "co", "square", 90.0, one, 0.0, 0.0);


           zgradpulse(gzlvl3, gt3*3.5);
           delay(1.0e-4);
/**************************************************************************/
/*   xxxxxxxxxxxxxxxxxxxxxx       13CO EVOLUTION       xxxxxxxxxxxxxxxxxx    */
/**************************************************************************/

       set_c13offset("co");
        c13pulse("co", "ca", "sinc", 90.0, t1, 2.0e-6, 0.0);
        delay(tau1*0.5);
        sim3_c13pulse(shname1, "ca", "co", "square", "",shpw1, 180.0, 2.0*pwN,
                                                  zero, zero, zero, 0.0, 0.0);
        delay(tau1*0.5);
        c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);
        sim3_c13pulse(shname1, "ca", "co", "square", "",shpw1, 180.0, 0.0,
                                                  two, zero, zero, 0.0, 0.0);
        if (pwN*2.0 > pwS2) delay(pwN*2.0-pwS2);
        c13pulse("co", "ca", "sinc", 90.0, t4, 0.0, 0.0);

/***************************************************************************/
/* CA->CO transfer                                                         */
/***************************************************************************/
       set_c13offset("ca");
        c13pulse("ca", "co", "square", 90.0, zero, 2.0e-6, 0.0);

        initval(0.0, v2);
        decstepsize(1.0);
        dcplrphase(v2);

           zgradpulse(gzlvl3, gt3*2.0);
        delay(tauC*0.5-gt3*2.0);
 
       c_shapedpulse2("isnob5",20.0,0.0,"isnob5",20.0,119.0,two,0.0,0.0);

           zgradpulse(gzlvl3, gt3*2.0);

        delay(tauC-gt3*2.0);
       c_shapedpulse2("isnob5",20.0,0.0,"isnob5",20.0,119.0,zero,0.0,0.0);
        delay(tauC*0.5);

        c13pulse("ca", "co", "square", 90.0, one, 0.0, 0.0);

/*      dcplrphase(v2); */

/**************************************************************************/

   obspower(shlvl1);

        shaped_pulse(shname1,shpw1,zero,0.0,0.0);
     dec2rgpulse(pwN,t3,0.0,0.0);

 	   delay(tau2*0.5+taunh*0.5);
        shaped_pulse(shname1,shpw1,two,0.0,0.0);
           delay(timeTN-shpw1-taunh*0.5-gt1-1.0e-4);
        zgradpulse(-gzlvl1, gt1);
        delay(1.0e-4);
      sim3_c13pulse("", "ca", "co", "square", "", 0.0, 180.0, 2.0*pwN,
                                             zero, zero, zero, 2.0e-6, 2.0e-6);


      if (SE_flg[0] == 'y')
      {
       delay(Delta);
	c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);      
           delay(timeTN-tau2*0.5-pwS4-Delta-pwS3);
        h_shapedpulse("eburp2",4.0,3.5,zero, 2.0e-6, 0.0); 
	dec2rgpulse(pwN, t10, 0.0, 0.0);
      }
      else
      {
       delay(Delta);
	c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);      
       delay(timeTN-tau2*0.5-Delta-pwS3);
       dec2rgpulse(pwN, zero, 0.0, 0.0);
      }

/**************************************************************************/
if (SE_flg[0] == 'y')
{
	zgradpulse(gzlvl5, gt5);
	delay(lambda-pwS6*0.4  - gt5);

   	h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl5, gt5);
	delay(lambda-pwS6*0.4  - gt5);

	dec2rgpulse(pwN, one, 0.0, 0.0);
  
        h_shapedpulse("eburp2_",4.0,3.5,one, 0.0, 0.0); 
 

	txphase(zero);
	dec2phase(zero);
	delay(lambda-pwS4*0.5-pwS6*0.4);

   	h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

	dec2phase(t10);
	delay(lambda-pwS4*0.5-pwS6*0.4);

 
        h_shapedpulse("eburp2",4.0,3.5,zero, 0.0, 0.0); 


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

        h_shapedpulse("reburp",4.0,3.5,zero, 0.0, 0.0); 
        zgradpulse(icosel*gzlvl2, gt1/10.0);            /* 2.0*GRADIENT_DELAY */
        delay(gstab);
}
else
{
        h_shapedpulse("eburp2",4.0,3.5,zero, 2.0e-6, 0.0);
        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.4  - gt5);

        h_sim3shapedpulse("reburp",4.0,3.5,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.4  - gt5-POWER_DELAY-1.0e-4);
}

	dec2power(dpwr2);				       /* POWER_DELAY */
lk_sample();
if (SE_flg[0] == 'y')
	setreceiver(t13);
else
	setreceiver(t12);
      rcvron();  
statusdelay(C,1.0e-4 );

}		 
Beispiel #12
0
pulsesequence()
{
   int          i,
		relay;
   double       tau;

/* GET NEW PARAMETERS */
   relay = (int) (getval("relay") + 0.5);
   tau = getval("tau");


/* CHECK CONDITIONS */
   if (p1 == 0.0)
      p1 = pw;


/* CALCULATE PHASES */
   sub(ct, ssctr, v11);		     /* v11 = ct-ss */
   initval(256.0, v12);
   add(v11, v12, v11);		     /* v11 = ct-ss+256 */
   hlv(v11, v1);		     /* v1 = cyclops = 00112233 */
   for (i = 0; i < relay + 1; i++)
      hlv(v1, v1);		     /* cyclops = 2**(relay+2) 0's, 1's, 2's,
					3's */

   mod4(v11, v2);		     /* v2 = 0123 0123... */
   dbl(v2, oph);		     /* oph = 0202 0202 */
   add(v2, v1, v2);		     /* v2 = 0123 0123 + cyclops */
   add(oph, v1, oph);		     /* oph = 0202 0202 + cyclops */
   hlv(v11, v3);		     /* v3 = 0011 2233 4455 ... */


/* PULSE SEQUENCE */
   status(A);
      if (rof1 == 0.0)
      {
         rof1 = 1.0e-6;		     /* phase switching time */
         rcvroff();
      }
      hsdelay(d1);		     /* preparation period */

   status(B);
      rgpulse(pw, v1, rof1, rof1);
      delay(d2);		     /* evolution period */
   status(A);
      if (relay == 0)
         delay(tau);		     /* for delayed cosy */
      rgpulse(p1, v2, rof1, rof1);   /* start of mixing period */
      if (relay == 0)
         delay(tau);		     /* for delayed cosy */

      for (i = 0; i < relay; i++)    /* relay coherence */
      {
         hlv(v3, v3);		     /* v3=2**(relay+1) 0's, 1's, 2's, 3's */
         dbl(v3, v4);		     /* v4=2**(relay+1) 0's, 2's, 0's, 2's */
         add(v2, v4, v5);	     /* v5=v4+v2 (including cyclops) */
         delay(tau/2);
         rgpulse(2.0*pw, v2, rof1, rof1);
         delay(tau/2);
         rgpulse(pw, v5, rof1, rof1);
      }

   status(C);
      delay(rof2);
      rcvron();
}
Beispiel #13
0
void pulsesequence()
{
   double          j1xh,
		   pwx2lvl,
		   pwx2,
		hsglvl,
		hsgt,
		   tau,
		   null,
                satfrq,
                satdly,
                satpwr;

   int             iphase;
   char            sspul[MAXSTR],
		nullflg[MAXSTR],
		PFGflg[MAXSTR],
                satmode[MAXSTR];


   null = getval("null");
   pwx2lvl = getval("pwx2lvl");
   pwx2 = getval("pwx2");
   hsglvl = getval("hsglvl");
   hsgt = getval("hsgt");
   j1xh = getval("j1xh");
   getstr("PFGflg",PFGflg);
   getstr("nullflg",nullflg);
        satfrq = getval("satfrq");
        satdly = getval("satdly");
        satpwr = getval("satpwr");
        getstr("satmode",satmode);

   iphase = (int) (getval("phase") + 0.5);
   getstr("sspul",sspul);

   tau = 1.0 / (2.0*j1xh);

    if ((iphase == 1)||(iphase == 2))
     initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v14);
    else
     assign(zero, v14);


/* Check for correct DM settings */
   if ((dm2[A] == 'y') || (dm2[B] == 'y'))
   {
      printf("DM must be set to either 'nny' or 'nnn'.\n");
      psg_abort(1);
   }


   settable(t1,8,phs1);
   settable(t2,8,phs2);
   settable(t3,2,phs3);
   settable(t4,1,phs4);
   settable(t5,4,phs5);

   getelem(t3,ct,v3);
   getelem(t2,ct,oph);

   if (iphase == 2)
      incr(v3);

   add(v14, v3, v3);
   add(v14, oph, oph);


/* BEGIN ACTUAL PULSE SEQUENCE CODE */
   status(A);
      dec2power(pwx2lvl);

   if (sspul[0] == 'y')
   {
        if (PFGflg[0] == 'y')
        {
         zgradpulse(hsglvl,hsgt);
         rgpulse(pw,zero,rof1,rof1);
         zgradpulse(hsglvl,hsgt);
        }
        else
        {
        obspower(tpwr-12);
        rgpulse(500*pw,zero,rof1,rof1);
        rgpulse(500*pw,one,rof1,rof1);
        obspower(tpwr);
        }
   }

      delay(d1);

        if (satmode[0] == 'y')
        {
                if (satfrq != tof)
                obsoffset(satfrq);
                obspower(satpwr);
                rgpulse(satdly,zero,rof1,rof1);
                obspower(tpwr);
                if (satfrq != tof)
                obsoffset(tof);
        }

   status(B);
 
    
    if (PFGflg[0] == 'y')
     {
      if (nullflg[0] == 'y')
      {
        rgpulse(0.5*pw,zero,rof1,rof1);
        delay(tau);
        sim3pulse(2.0*pw,0.0,2.0*pwx2,zero,zero,zero,rof1,rof1);
        delay(tau);
        rgpulse(1.5*pw,two,rof1,rof1);
        zgradpulse(hsglvl,hsgt);
        delay(1e-3);
      }
     } 
     else
     {
      if (null != 0.0)
	{
	rgpulse(pw,zero,rof1,rof1);
	delay(tau);
	sim3pulse(2*pw,0.0,2*pwx2,zero,zero,zero,rof1,rof1);
	delay(tau);
	rgpulse(pw,two,rof1,rof1);
	delay(null);
	}
      }

      rcvroff();
      rgpulse(pw, t1, rof1, rof1);
      delay(tau - (2*pw/PI) - 2*rof1);

      dec2rgpulse(pwx2, v3, rof1, 1.0e-6);
      if (d2 > 0.0)
       delay(d2/2.0 - pw - 3.0e-6 - (2*pwx2/PI));
      else
       delay(d2/2.0);
      rgpulse(2.0*pw, t4, 2.0e-6, 2.0e-6);
      if (d2 > 0.0) 
       delay(d2/2.0 - pw - 3.0e-6 - (2*pwx2/PI)); 
      else 
       delay(d2/2.0);
      dec2rgpulse(pwx2, t5, 1.0e-6, rof2);

      rcvron();
      dec2power(dpwr2);
      delay(tau - POWER_DELAY);

   status(C);
}
void pulsesequence()
{
/* DECLARE VARIABLES */

char     
  aliph[MAXSTR],	/* aliphatic CHn groups only */
  arom[MAXSTR],		/* aromatic CHn groups only */
  N15refoc[MAXSTR],	/* flag for refocusing 15N during indirect H1 evolution */

  f1180[MAXSTR],	/* Flag to start t1 @ halfdwell */
  mag_flg[MAXSTR],	/* magic angle gradient */
  f2180[MAXSTR],	/* Flag to start t2 @ halfdwell */
  stCshape[MAXSTR],	/* C13 inversion pulse shape name */
  STUD[MAXSTR],		/* Flag to select adiabatic decoupling */
  stCdec[MAXSTR],	/* contains name of adiabatic decoupling shape */
  auto_dof[MAXSTR];	/* automatically adjust dof for aromatic, aliphatic, all carbon */

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 */ 

double    

  JCH1 = getval("JCH1"),	/* smallest coupling that you wish to purge */
  JCH2 = getval("JCH2"),	/* largest coupling that you wish to purge */
  taud,				/* 1/(2JCH1)   */
  taue,				/* 1/(2JCH2)   */

/* N15 purging */
  tauNH  = 1/(4.0*getval("JNH")),		/* HN coupling constant */

  gt4 = getval("gt4"),
  gt14 = getval("gt14"),
  gt7 = getval("gt7"),
  gt17 = getval("gt17"),
  gt8 = getval("gt8"),
  gt9 = getval("gt9"),

  gzlvl4 = getval("gzlvl4"),
  gzlvl14 = getval("gzlvl14"),
  gzlvl7 = getval("gzlvl7"),
  gzlvl17 = getval("gzlvl17"),
  gzlvl8 = getval("gzlvl8"),
  gzlvl9 = getval("gzlvl9"),

  bw, pws, ofs, ppm, nst,  /* bandwidth, pulsewidth, offset, ppm, # steps */

  ni2 = getval("ni2"),
  dofa = 0.0,			/* actual 13C offset (depends on aliph and arom)*/
  rf200 = getval("rf200"), 	/* rf in Hz for 200ppm STUD+ */
  dmf200 = getval("dmf200"),     /* dmf for 200ppm STUD+ */
  rf30 = getval("rf30"),	/* rf in Hz for 30ppm STUD+ */
  dmf30 = getval("dmf30"),	/* dmf for 30ppm STUD+ */

  stdmf = 1.0,			/* dmf for STUD decoupling initialized */ 
  studlvl = 0.0,		/* coarse power for STUD+ decoupling initialized */

  rffil = 0.0,			/* fine power level for 200ppm adiabatic pulse */

  rfst = 0.0,			/* fine power level for adiabatic pulse initialized */
  rf0,				/* full fine power */

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

  tau1,				/*  t1 delay */
  tau2,				/*  t2 delay */

  JCH = getval("JCH"),		/*  CH coupling constant */
  Cfil = getval("Cfil"),		/*  CH coupling constant */

  pwC = getval("pwC"),		/* PW90 for 13C nucleus @ pwClvl */
  pwClvl = getval("pwClvl"),	/* high power for 13C hard pulses on dec1  */
  pwC180 = getval("pwC180"),	/* PW180 for 13C nucleus in INEPT transfers */
  pwN = getval("pwN"),		/* PW90 for 15N nucleus @ pwNlvl */
  pwNlvl = getval("pwNlvl"),	/* high power for 15N hard pulses on dec2 */

  pwClw=getval("pwClw"), 
  pwNlw=getval("pwNlw"),
  pwZlw=0.0,			/* largest of pwNlw and 2*pwClw */

  mix  = getval("mix"),		/* noesy mix time */
  sw1  = getval("sw1"),		/* spectral width in t1 (H) */
  sw2  = getval("sw2"),		/* spectral width in t2 (C) */
  gstab = getval("gstab"),	/* gradient recovery delay (300 us recom.) */
  gsign = 1.0,
  gzcal = getval("gzcal"),	/* dac to G/cm conversion factor */
  gt0 = getval("gt0"),
  gt1 = getval("gt1"),
  gt2 = getval("gt2"),
  gt3 = getval("gt3"),
  gt5 = getval("gt5"),
  gt6 = getval("gt6"),
  gzlvl0 = getval("gzlvl0"),
  gzlvl1 = getval("gzlvl1"),
  gzlvl2 = getval("gzlvl2"),
  gzlvl3 = getval("gzlvl3"),
  gzlvl5 = getval("gzlvl5"),
  gzlvl6 = getval("gzlvl6");


/* LOAD VARIABLES */

  getstr("aliph",aliph);
  getstr("arom",arom);
  getstr("N15refoc",N15refoc);

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

  getstr("auto_dof",auto_dof);

/* LOAD PHASE TABLE */
  settable(t1,8,phi1);
  settable(t2,4,phi2);
  settable(t3,2,phi3);
  settable(t5,1,phi5);

  settable(t6,16,phi6);
  settable(t7,32,phi7);

  if (Cfil == 1) settable(t4,8,rec1);
    else settable(t4,32,rec2);

/* CHECK VALIDITY OF PARAMETER RANGES */

    if ( (arom[A]=='n' && aliph[A]=='n') || (arom[A]=='y' && aliph[A]=='y') )
      { 
	printf("You need to select one and only one of arom or aliph options  ");
	psg_abort(1); 
      }

    if((dm[A] == 'y' || dm[C] == 'y' ))
    {
        printf("incorrect 13C decoupler flags! dm='nnnn' or 'nnny' only  ");
        psg_abort(1);
    }

    if((dm2[A] == 'y' || dm2[C] == 'y' ))
    {
        printf("incorrect 15N decoupler flags! No decoupling in relax or mix periods  ");
        psg_abort(1);
    }

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

    if( dpwr2 > 49 )
    {
        printf("don't fry the probe, DPWR2 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);
    } 

    if( gt0 > 15e-3 || gt1 > 15e-3 || gt2 > 15e-3 || gt3 > 15e-3 || gt4 > 15e-3 || gt5 > 15e-3 || gt6 > 15e-3 ) 
    {
        printf("gti values < 15e-3\n");
        psg_abort(1);
    } 

/*   if( gzlvl3*gzlvl4 > 0.0 )*/ 

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

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

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

/*  Set up f2180  tau2 = t2               */

    tau2 = d3;
    if((f2180[A] == 'y') && (ni2 > 1.0)) tau2 += ( 1.0 / (2.0*sw2) ); 
    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(t4,2,4);}

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

/* calculate 3db lower power hard pulses for simultaneous CN decoupling during
   indirect H1 evoluion pwNlw and pwClw should be calculated by the macro that 
   calls the experiment. */

  if (N15refoc[A] == 'y')
    {
     if (pwNlw==0.0) pwNlw = compN*pwN*exp(3.0*2.303/20.0);
     if (pwClw==0.0) pwClw = compC*pwC*exp(3.0*2.303/20.0);
     if (pwNlw > 2.0*pwClw) 
	 pwZlw=pwNlw;
      else
	 pwZlw=2.0*pwClw;
/* Uncomment to check pwClw and pwNlw
     if (d2==0.0 && d3==0.0) printf(" pwClw = %.2f ; pwNlw = %.2f\n", pwClw*1e6,pwNlw*1e6);
*/
    }


/* make sure that gt3 and gt1 are of opposite sign to help dephasing H2O */
   if (gzlvl3*icosel*gzlvl1 > 0.0) gsign=-1.0;
     else gsign=1.0; 


/* if coupling constants are input by user use them to calculate delays */
   if (Cfil == 1)
     {
      taud = 1.0/(2.0*JCH1);
      taue = 1.0/(2.0*JCH2);
     }
    else
     {
       taud = 1.0/(4.0*JCH1);
       taue = 1.0/(4.0*JCH2);
     }


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

   setautocal();                        /* activate auto-calibration flags */ 
        
   if (autocal[0] == 'n') 
   {
     if (arom[A]=='y')  /* AROMATIC spectrum */
     {
       /* 30ppm sech/tanh inversion */
       rfst = (compC*4095.0*pwC*4000.0*sqrt((4.5*sfrq/600.0+3.85)/0.41));   
       rfst = (int) (rfst + 0.5);
     }
  
     if (aliph[A]=='y')  /* ALIPHATIC spectrum */
     {
       /* 200ppm sech/tanh inversion pulse */
       if (pwC180>3.0*pwC) 
	 {
	   rfst = (compC*4095.0*pwC*4000.0*sqrt((12.07*sfrq/600+3.85)/0.35));
	   rfst = (int) (rfst + 0.5);
       }
       else rfst=4095.0;

       if( pwC > (20.0e-6*600.0/sfrq) )
	 { printf("Increase pwClvl so that pwC < 20*600/sfrq");
	  psg_abort(1); 
       }
     }

     if (Cfil > 1)  /* 200ppm pulse for C13 filtering */
     {
       /* 200ppm sech/tanh inversion pulse */
       if (pwC180>3.0*pwC) 
	 {
	   rffil = (compC*4095.0*pwC*4000.0*sqrt((12.07*sfrq/600+3.85)/0.35));
	   rffil = (int) (rffil + 0.5);
       }
       else rfst=4095.0;

       if( pwC > (20.0e-6*600.0/sfrq) )
	 { printf("Increase pwClvl so that pwC < 20*600/sfrq");
	  psg_abort(1); 
       }
     }

   }
   else        /* if autocal = 'y'(yes), 'q'(quiet), r(read), or 's'(semi) */
   {
     if(FIRST_FID)                                            /* call Pbox */
     {
       ppm = getval("dfrq"); 
       bw = 118.0*ppm; ofs = 139.0*ppm;
       if (arom[A]=='y')  /* AROMATIC spectrum */
       {
         bw = 30.0*ppm; pws = 0.001; ofs = 0.0; nst = 500.0;    
         stC30 = pbox_makeA("stC30", "sech", bw, pws, ofs, compC*pwC, pwClvl, nst);
       }
       if ((aliph[A]=='y') || (Cfil > 1))
       {
         bw = 200.0*ppm; pws = 0.001; ofs = 0.0; nst = 1000.0;    
         stC200 = pbox_makeA("stC200", "sech", bw, pws, ofs, compC*pwC, pwClvl, nst);
       }
       ofs_check(H1ofs, C13ofs, N15ofs, H2ofs);
     }
     if (arom[A]=='y')  rfst = stC30.pwrf;
     if (aliph[A]=='y') 
     {
      if (pwC180>3.0*pwC) rfst = stC200.pwrf;
      else rfst = 4095.0;
     }
     if (Cfil > 1)
     {
      if (pwC180>3.0*pwC) rffil = stC200.pwrf;
      else rffil = 4095.0;
     }
   }

   if (arom[A]=='y')  
   {
     dofa=dof+(125-43)*dfrq;

     strcpy(stCshape, "stC30");
     /* 30 ppm STUD+ decoupling */
     strcpy(stCdec, "stCdec30");             
     stdmf = dmf30;
     studlvl = pwClvl + 20.0*log10(compC*pwC*4.0*rf30);
     studlvl = (int) (studlvl + 0.5);
   }

   if (aliph[A]=='y')
   {
     dofa=dof;
       
     strcpy(stCshape, "stC200");
     /* 200 ppm STUD+ decoupling */
     strcpy(stCdec, "stCdec200");
     stdmf = dmf200;
     studlvl = pwClvl + 20.0*log10(compC*pwC*4.0*rf200);
     studlvl = (int) (studlvl + 0.5);
   }

/* BEGIN ACTUAL PULSE SEQUENCE */

status(A);

   if (auto_dof[A]=='y') decoffset(dofa);

   obspower(tpwr);		/* Set transmitter power for hard 1H pulses */
   decpower(pwClvl);		/* Set Dec1 power for hard 13C pulses */
   dec2power(pwNlvl);		/* Set Dec2 power for decoupling during tau1 */
   dec2pwrf(rf0);       

   initval(135.0,v1);
   obsstepsize(1.0);


   delay(d1);

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

   decphase(zero);       
   dec2phase(zero);       
   rcvroff();
   delay(gstab);


status(B);

if (Cfil == 1) 
  {
   xmtrphase(v1);
   rgpulse(pw, t1, rof1 , 0.0);  
   txphase(zero); 
   xmtrphase(zero); 

/* CN FILTER BEGINS */
      zgradpulse(gzlvl8, gt8);
      txphase(zero); xmtrphase(zero);
      delay(taud -gt8 -2.0*GRADIENT_DELAY -2.0*SAPS_DELAY);

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

      zgradpulse(gzlvl8, gt8);
      delay(taue -gt8 -2.0*GRADIENT_DELAY);

      decrgpulse(pwC, zero, 0.0, 0.0);

      delay(taud -taue -pwC);

/* CN FILTER ENDS */

   }
else if (Cfil == 2)
   {
      txphase(t6);
      rgpulse(pw, t6, rof1, 0.0);                  /* 90 deg 1H pulse */
/* BEGIN 1st FILTER */
      txphase(zero);

      zgradpulse(gzlvl8,gt8);
      decpwrf(rffil);
      delay(taud -gt8 -2.0*GRADIENT_DELAY -WFG2_START_DELAY -0.5e-3 +70.0e-6);

      simshaped_pulse("", "stC200", 2.0*pw, pwC180, zero, zero, 0.0, 0.0);

      zgradpulse(gzlvl8,gt8);
      decpwrf(rf0);
      delay(taud -gt8 -2.0*GRADIENT_DELAY -0.5e-3 +70.0e-6);

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

      zgradpulse(gzlvl4,gt4);
      txphase(t7);
      delay(gstab);

      rgpulse(pw, t7, 0.0, 0.0);
/* BEGIN 2nd FILTER */

      zgradpulse(gzlvl9,gt9);
      decpwrf(rffil);
      delay(taue -gt9 -2.0*GRADIENT_DELAY -WFG2_START_DELAY -0.5e-3 +70.0e-6);

      simshaped_pulse("", "stC200", 2.0*pw, pwC180, zero, zero, 0.0, 0.0);

      zgradpulse(gzlvl9,gt9);
      decpwrf(rf0);
      delay(taue -gt9 -2.0*GRADIENT_DELAY -0.5e-3 +70.0e-6);

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

      zgradpulse(gzlvl7,gt7);
      txphase(t1); xmtrphase(v1);
      delay(gstab);

      rgpulse(pw, t1, 0.0, 0.0);
      txphase(zero); xmtrphase(zero);
   }
else if (Cfil == 3)
   {
      txphase(t6);
      rgpulse(pw, t6, rof1, 0.0);                  /* 90 deg 1H pulse */
/* BEGIN 1st FILTER */
      txphase(zero);

      zgradpulse(gzlvl8,gt8);
      delay(tauNH -gt8 -2.0*GRADIENT_DELAY);

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

      decpwrf(rffil);
      delay(tauNH -taud -0.5e-3 -WFG_START_DELAY -PWRF_DELAY);

      decshaped_pulse("stC200", pwC180, zero, 0.0, 0.0);

      zgradpulse(gzlvl8,gt8);
      decpwrf(rf0);
      delay(taud -gt8 -2.0*GRADIENT_DELAY -0.5e-3 -PWRF_DELAY);

      sim3pulse(pw, pwC, pwN, zero, zero, zero, 0.0, 0.0);
      zgradpulse(gzlvl14,gt14);
      txphase(t7);
      delay(gstab);

      rgpulse(pw, t7, 0.0, 0.0);
/* BEGIN 2nd FILTER */

      zgradpulse(gzlvl9,gt9);
      delay(tauNH -gt9 -2.0*GRADIENT_DELAY);

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

      decpwrf(rffil);
      delay(tauNH -taue -0.5e-3 -WFG_START_DELAY -PWRF_DELAY);

      decshaped_pulse("stC200", pwC180, zero, 0.0, 0.0);

      zgradpulse(gzlvl9,gt9);
      decpwrf(rf0);
      delay(taue -gt9 -2.0*GRADIENT_DELAY -0.5e-3 -PWRF_DELAY);

      sim3pulse(pw, pwC, pwN, zero, zero, zero, 0.0, 0.0);
      zgradpulse(gzlvl17,gt17);
      txphase(t1); xmtrphase(v1);
      delay(gstab);

      rgpulse(pw, t1, 0.0, 0.0);
      txphase(zero); xmtrphase(zero);
   }

/* H1 INDIRECT EVOLUTION BEGINS */
   if (ni > 0) 
    txphase(t3);
    {
     if ( (N15refoc[A]=='y') && ((tau1 -pwN -2.0*pw/PI -rof1 -SAPS_DELAY) > 0.0) )
      {
       delay(tau1 -pwN -2.0*pw/PI -SAPS_DELAY);
       dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
       delay(tau1 -pwN -2.0*pw/PI -rof1);
      }     
     else if (tau1 > 2.0*pw/PI +rof1 +SAPS_DELAY)
       delay(2.0*tau1 -4.0*pw/PI -2.0*rof1 -SAPS_DELAY);
    }
/* H1 INDIRECT EVOLUTION ENDS */
   rgpulse(pw, t3, rof1, rof1);             /*  2nd 1H 90 pulse   */

status(C);

   delay(mix -pwC -gt0 -PWRF_DELAY -gstab -2.0*GRADIENT_DELAY); 

   decrgpulse(pwC,zero,0.0,0.0); 
   zgradpulse(gzlvl0, gt0);
   decpwrf(rfst);                           /* fine power for inversion pulse */
   delay(gstab);

/* FIRST HSQC INEPT TRANSFER */
   rgpulse(pw,zero,0.0,0.0);
   zgradpulse(gzlvl4, gt4);
   delay(1/(4.0*JCH) -gt4 -2.0*GRADIENT_DELAY -WFG2_START_DELAY -pwC180*0.45);

   simshaped_pulse("",stCshape,2*pw,pwC180,zero,zero,0.0,0.0);

   zgradpulse(gzlvl4, gt4);
   decpwrf(rf0);
   txphase(one);
   delay(1/(4.0*JCH) -gt4 -2.0*GRADIENT_DELAY -pwC180*0.45 -PWRF_DELAY -SAPS_DELAY);

   rgpulse(pw,one,0.0,0.0);
   zgradpulse(gsign*gzlvl3, gt3);
   txphase(zero);
   delay(gstab);

/* C13 EVOLUTION */
   decrgpulse(pwC,t2,0.0,0.0);   

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

   decphase(zero);
   delay(gt1 +2.0*GRADIENT_DELAY +gstab -2.0*pw -SAPS_DELAY);
   decrgpulse(2*pwC,zero,0.0,0.0);

   if (mag_flg[A] == 'y')  magradpulse(icosel*gzcal*gzlvl1, gt1);
     else  zgradpulse(icosel*gzlvl1, gt1);
   decphase(t5);
   delay(gstab);

   decrgpulse(pwC,t5,0.0,0.0);
   delay(pw);
   rgpulse(pw,zero,0.0,0.0);

   zgradpulse(gzlvl5, gt5);
   decphase(zero);
   delay(1/(8.0*JCH) -gt5 -SAPS_DELAY -2.0*GRADIENT_DELAY);		/* d3 = 1/8*Jch */

   decrgpulse(2.0*pwC,zero,0.0,2.0e-6);
   rgpulse(2.0*pw,zero,0.0,0.0);

   zgradpulse(gzlvl5, gt5);
   decphase(one);
   txphase(one);
   delay(1/(8.0*JCH) -gt5 -2.0*SAPS_DELAY -2.0*GRADIENT_DELAY);		/* d3 = 1/8*Jch */

   delay(pwC);
   decrgpulse(pwC,one,0.0,2.0e-6);
   rgpulse(pw,one,0.0,0.0);

   zgradpulse(gzlvl6, gt6);
   decpwrf(rfst);                           /* fine power for inversion pulse */
   decphase(zero);
   txphase(zero);
   delay(1/(4.0*JCH) -gt6 -pwC180*0.45 -PWRF_DELAY 
		-WFG2_START_DELAY -2.0*SAPS_DELAY -2.0*GRADIENT_DELAY);	/* d2 = 1/4*Jch */

   simshaped_pulse("",stCshape,2*pw,pwC180,zero,zero,0.0,0.0);

   zgradpulse(gzlvl6, gt6);
   decpwrf(rf0);
   delay(1/(4.0*JCH) -gt6 -pwC180*0.45 -PWRF_DELAY -2.0*GRADIENT_DELAY);	/* d2 = 1/4*Jch */

   rgpulse(pw,zero,0.0,0.0);  

   delay(gt2 +gstab +2.0*GRADIENT_DELAY +POWER_DELAY);

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

   if (mag_flg[A] == 'y')  magradpulse(gzcal*gzlvl2, gt2);
     else  zgradpulse(gzlvl2, gt2);
   delay(gstab);

  setreceiver(t4);
   rcvron();
   if ((STUD[A]=='y') && (dm[D] == 'y'))
    {
     decpower(studlvl);
     decprgon(stCdec, 1.0/stdmf, 1.0);
     decon();
    }
   else	
    { 
     decpower(dpwr);
     status(D);
    }
}
Beispiel #15
0
pulsesequence()
{

/* DECLARE AND LOAD VARIABLES */

void        makeHHdec(), makeCdec(); 	                /* utility functions */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            mag_flg[MAXSTR],      /* magic-angle coherence transfer gradients */
	    C13refoc[MAXSTR],		/* C13 sech/tanh pulse in middle of t1*/
	    NH2only[MAXSTR],		       /* spectrum of only NH2 groups */
	    T1[MAXSTR],				/* insert T1 relaxation delay */
	    T1rho[MAXSTR],		     /* insert T1rho relaxation delay */
	    T2[MAXSTR],				/* insert T2 relaxation delay */
	    TROSY[MAXSTR],			    /* do TROSY on N15 and H1 */
	    Hdecflg[MAXSTR],                       /* HH-h**o decoupling flag */
	    Cdecflg[MAXSTR];                /* low power C-13 decoupling flag */
 
int         icosel,          			  /* used to get n and p type */
            ihh=1,       /* used in HH decouling to improve water suppression */
            t1_counter,  		        /* used for states tppi in t1 */
	    rTnum,			/* number of relaxation times, relaxT */
	    rTcounter;		    /* to obtain maximum relaxT, ie relaxTmax */

double      tau1,         				         /*  t1 delay */
	    lambda = 0.91/(4.0*getval("JNH")), 	   /* 1/4J H1 evolution delay */
	    tNH = 1.0/(4.0*getval("JNH")),	  /* 1/4J N15 evolution delay */
	    relaxT = getval("relaxT"),		     /* total relaxation time */
	    rTarray[1000], 	    /* to obtain maximum relaxT, ie relaxTmax */
            maxrelaxT = getval("maxrelaxT"),    /* maximum relaxT in all exps */
	    ncyc,			 /* number of pulsed cycles in relaxT */
            pwr_dly,                 /* power delay */
        
/* the sech/tanh pulse is automatically calculated by the macro "proteincal", */  
/* and is called directly from your shapelib.                  		      */
   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 */
   rfst,	                           /* fine power for the stCall pulse */

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

	calH = getval("calH"), /* multiplier on a pw pulse for H1 calibration */
   	tpwrsf = getval("tpwrsf"),    /* fine power adustment for soft pulse  */
   	pwHs = getval("pwHs"),	        /* H1 90 degree pulse length at tpwrs */
   	pwHH = 0.0,                     /* pwHH = pwHs for HH h**o-decoupling */
   	tpwrs,	  	              /* power for the pwHs ("H2Osinc") pulse */

	pwNlvl = getval("pwNlvl"),	              /* power for N15 pulses */
        pwN = getval("pwN"),          /* N15 90 degree pulse length at pwNlvl */
	calN = getval("calN"),   /* multiplier on a pwN pulse for calibration */
	slNlvl,					   /* power for N15 spin lock */
        slNrf = 1500.0,        /* RF field in Hz for N15 spin lock at 600 MHz */

	sw1 = getval("sw1"),

	gt1 = getval("gt1"),  		       /* coherence pathway gradients */
        gzcal = getval("gzcal"),               /* dac to G/cm conversion      */
	gzlvl1 = getval("gzlvl1"),
	gzlvl2 = getval("gzlvl2"),
        BPpwrlimits,                        /*  =0 for no limit, =1 for limit */

	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");

    P_getreal(GLOBAL,"BPpwrlimits",&BPpwrlimits,1);

    getstr("f1180",f1180);
    getstr("mag_flg",mag_flg);
    getstr("C13refoc",C13refoc);
    getstr("NH2only",NH2only);
    getstr("T1",T1);
    getstr("T1rho",T1rho);
    getstr("T2",T2);
    getstr("TROSY",TROSY);
    getstr("Hdecflg", Hdecflg);
    getstr("Cdecflg", Cdecflg);

/*   LOAD PHASE TABLE    */
	
        settable(t3,2,phi3);
	settable(t4,1,phx);
   if (TROSY[A]=='y')
       {settable(t1,1,ph_x);
	settable(t9,1,phx);
 	settable(t10,1,phy);
	settable(t11,1,phx);
	settable(t12,2,recT);}
    else
       {settable(t1,1,phx);
	settable(t9,8,phi9);
 	settable(t10,1,phx);
	settable(t11,1,phy);
	settable(t12,4,rec);}



/*   INITIALIZE VARIABLES   */

/* maximum fine power for pwC pulses (and initialize rfst) */
	rf0 = 4095.0;    rfst=0.0;

/* 180 degree adiabatic C13 pulse from 0 to 200 ppm */
     if (C13refoc[A]=='y')
       {rfst = (compC*4095.0*pwC*4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35));   
	rfst = (int) (rfst + 0.5);
	if ( 1.0/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35)) < pwC )
           { text_error( " Not enough C13 RF. pwC must be %f usec or less.\n", 
	    (1.0e6/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35))) ); psg_abort(1); }}

/* selective H20 one-lobe sinc pulse */
    if(pwHs > 1e-6)
      tpwrs = tpwr - 20.0*log10(pwHs/(compH*pw*1.69));  /* needs 1.69 times more */
    else                    	                    /* power than a square pulse */
      tpwrs = 0.0;
    tpwrs = (int) (tpwrs);    
    if (tpwrsf<4095.0) tpwrs = tpwrs + 6.0;
    if (tpwrsf < 4095.0) 
    {
      tpwrs = tpwrs + 6.0;   
      pwr_dly = POWER_DELAY + PWRF_DELAY;
    }
    else pwr_dly = POWER_DELAY;

/* power level for N15 spinlock (90 degree pulse length calculated first) */
	slNlvl = 1/(4.0*slNrf*sfrq/600.0) ;
	slNlvl = pwNlvl - 20.0*log10(slNlvl/(pwN*compN));
	slNlvl = (int) (slNlvl + 0.5);

/* use 1/8J times for relaxation measurements of NH2 groups */
  if ( (NH2only[A]=='y') && ((T1[A]=='y') || (T1rho[A]=='y') || (T2[A]=='y')) )	
     {  tNH = tNH/2.0;  }

/* reset calH and calN for 2D if inadvertently left at 2.0 */
  if (ni>1.0) {calH=1.0; calN=1.0;}

/* make shapes and set up parameters for HH h**o-decoupling */
    if(Cdecflg[0] == 'y') makeCdec();
    if(Hdecflg[0] == 'y') makeHHdec();
    if(Hdecflg[0] != 'n')
    { 
      pwHH = pwHs; 
      pwHs = 0.0; 
    }


/* CHECK VALIDITY OF PARAMETER RANGES */

  if ((TROSY[A]=='y') && (gt1 < -2.0e-4 + pwHs + 1.0e-4 + 2.0*POWER_DELAY))
  { text_error( " gt1 is too small. Make gt1 equal to %f or more.\n",    
    (-2.0e-4 + pwHs + 1.0e-4 + 2.0*POWER_DELAY) ); psg_abort(1); }

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

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

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

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



/*  RELAXATION TIMES AND FLAGS */  

/* evaluate maximum relaxT, relaxTmax chosen by the user */
  rTnum = getarray("relaxT", rTarray);
  relaxTmax = rTarray[0];
  for (rTcounter=1; rTcounter<rTnum; rTcounter++)
      if (relaxTmax < rTarray[rTcounter]) relaxTmax = rTarray[rTcounter];


/* compare relaxTmax with maxrelaxT */
  if (maxrelaxT > relaxTmax)  relaxTmax = maxrelaxT; 


if ( ((T1rho[A]=='y') || (T2[A]=='y')) && (relaxTmax > d1) )
{ text_error("Maximum relaxation time, relaxT, is greater than d1 ! "); psg_abort(1);}

if ( ((T1[A]=='y') && (T1rho[A]=='y'))   ||   ((T1[A]=='y') && (T2[A]=='y')) ||
    ((T1rho[A]=='y') && (T2[A]=='y')) )
{ text_error("Choose only one relaxation measurement ! ");          psg_abort(1); } 


if ( ((T1[A]=='y') || (T1rho[A]=='y')) && 
       ((relaxT*100.0 - (int)(relaxT*100.0+1.0e-4)) > 1.0e-6) )
 { text_error("Relaxation time, relaxT, must be zero or multiple of 10msec"); psg_abort(1);}
 

 if ( (T2[A]=='y') && 
           (((relaxT+0.01)*50.0 - (int)((relaxT+0.01)*50.0+1.0e-4)) > 1.0e-6) )
{ text_error("Relaxation time, relaxT, must be odd multiple of 10msec"); psg_abort(1);}

if ( ((T1rho[A]=='y') || (T2[A]=='y'))  &&  (relaxTmax > 0.25) && (ix==1) ) 
{ printf("WARNING, sample heating will result for relaxT>0.25sec"); }

if ( ((T1rho[A]=='y') ||  (T2[A]=='y'))  &&  (relaxTmax > 0.5) ) 
{ text_error("relaxT greater than 0.5 seconds will heat sample"); psg_abort(1);}


if ( ((NH2only[A]=='y') || (T1[A]=='y') || (T1rho[A]=='y') || (T2[A]=='y'))
   &&  (TROSY[A]=='y') ) 
{ text_error("TROSY not implemented with NH2 spectrum, or relaxation exps."); 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 (TROSY[A]=='y')
	 {  if (phase1 == 2)   				      icosel = -1;
            else 	  {  tsadd(t4,2,4);  tsadd(t10,2,4);  icosel = +1;  }
	 }
    else {  if (phase1 == 2)  {tsadd(t10,2,4); icosel = +1;}
            else 			       icosel = -1;    
	 }

    if(Hdecflg[0] != 'n') ihh = icosel;

/*  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;



/* 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); }



/*  Correct inverted signals for NH2 only spectra  */

   if ((NH2only[A]=='y') && (T1[A]=='n')  &&  (T1rho[A]=='n')  && (T2[A]=='n'))
      { tsadd(t3,2,4); }



/* BEGIN PULSE SEQUENCE */

status(A);

	obspower(tpwr);
	decpower(pwClvl);
	decpwrf(rf0);
 	dec2power(pwNlvl);
	txphase(zero);
        decphase(zero);
        dec2phase(zero);
        if(Hdecflg[0] != 'n')
        {
          delay(5.0e-5);
          rgpulse(pw,zero,rof1,0.0);                 
          rgpulse(pw,one,0.0,rof1);                 
          zgradpulse(1.5*gzlvl0, 0.5e-3);
          delay(5.0e-4);
          rgpulse(pw,zero,rof1,0.0);                 
          rgpulse(pw,one,0.0,rof1);                 
          zgradpulse(-gzlvl0, 0.5e-3);
        }
        
	delay(d1);

 
/*  xxxxxxxxxxxxxxxxx  CONSTANT SAMPLE HEATING FROM N15 RF xxxxxxxxxxxxxxxxx  */

 if  (T1rho[A]=='y')
 	{dec2power(slNlvl);
         dec2rgpulse(relaxTmax-relaxT, zero, 0.0, 0.0);
    	 dec2power(pwNlvl);}
	
 if  (T2[A]=='y')      
 	{ncyc = 8.0*100.0*(relaxTmax - relaxT);
         if (BPpwrlimits > 0.5)
          {
           dec2power(pwNlvl-3.0);    /* reduce for probe protection */
           pwN=pwN*compN*1.4;
          }
    	 if (ncyc > 0)
       	    {initval(ncyc,v1);
             loop(v1,v2);
       	     delay(0.625e-3 - pwN);
      	     dec2rgpulse(2*pwN, zero, 0.0, 0.0);
      	     delay(0.625e-3 - pwN);
            endloop(v2);}
         if (BPpwrlimits > 0.5)
          {
           dec2power(pwNlvl);         /* restore normal value */
           pwN=getval("pwN");
          }
 	}
/*  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  */
        rcvroff();
	if (TROSY[A]=='n')   
	dec2rgpulse(pwN, zero, 0.0, 0.0);   /*destroy N15 magnetization*/
	zgradpulse(gzlvl0, 0.5e-3);
	delay(1.0e-4);
	if (TROSY[A]=='n')    dec2rgpulse(pwN, one, 0.0, 0.0);
	zgradpulse(0.7*gzlvl0, 0.5e-3);
	decpwrf(rfst);
	txphase(t1);
	delay(5.0e-4);

      if ( dm3[B] == 'y' )     /* begins optional 2H decoupling */
        {
          lk_hold();
          dec3rgpulse(1/dmf3,one,10.0e-6,2.0e-6);
          dec3unblank();
          dec3phase(zero);
          delay(2.0e-6);
          setstatus(DEC3ch, TRUE, 'w', FALSE, dmf3);
        }

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

	txphase(zero);
   	dec2phase(zero);
	zgradpulse(gzlvl0, gt0);
	delay(lambda - gt0 - pwHH);
	
	if(Hdecflg[0] != 'n')
	{
	  obspower(tpwrs);
          if (tpwrsf<4095.0) obspwrf(tpwrsf); 
	  shaped_pulse("H2Osinc", pwHH, two, 5.0e-5, 0.0);
	  obspower(tpwr);
          if (tpwrsf<4095.0) obspwrf(4095.0);
   	  sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);
   	  obspower(tpwrs);
          if (tpwrsf<4095.0) obspwrf(tpwrsf);
   	  shaped_pulse("H2Osinc", pwHH, two, 5.0e-5, 0.0);
   	  obspower(tpwr);
          if (tpwrsf<4095.0) obspwrf(4095.0); 
   	}
   	else 
   	  sim3pulse(2.0*pw, 0.0, 2.0*pwN, zero, zero, zero, 0.0, 0.0);
   	
   	txphase(one);
	zgradpulse(gzlvl0, gt0);
	delay(lambda - gt0 - pwHH);        
 	rgpulse(pw, one, 0.0, 0.0);
	txphase(two);
        obspower(tpwrs);
        if (tpwrsf<4095.0) obspwrf(tpwrsf);
        shaped_pulse("H2Osinc", pwHs, two, 5.0e-5, 0.0);
	obspower(tpwr);
	if (tpwrsf<4095.0) obspwrf(4095.0);

        if (TROSY[A]=='y')
	  zgradpulse(ihh*gzlvl3, gt3);           
	else
	  zgradpulse(-ihh*gzlvl3, gt3);
	dec2phase(t3);
	delay(2.0e-4);
   	dec2rgpulse(calN*pwN, t3, 0.0, 0.0);
	txphase(zero);
	decphase(zero);

/*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 RELAXATION    xxxxxxxxxxxxxxxxxxxx  */

if ( (T1[A]=='y') || (T1rho[A]=='y') || (T2[A]=='y') )
   {
    dec2phase(one);
    zgradpulse(gzlvl4, gt4);				/* 2.0*GRADIENT_DELAY */
    delay(tNH - gt4 - 2.0*GRADIENT_DELAY);

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

    zgradpulse(gzlvl4, gt4);				/* 2.0*GRADIENT_DELAY */
    delay(tNH - gt4 - 2.0*GRADIENT_DELAY);
   }

		/*   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    */

if  (T1[A]=='y')
   {
    dec2rgpulse(pwN, one, 0.0, 0.0);
    dec2phase(three);

    zgradpulse(gzlvl0, gt0);				/* 2.0*GRADIENT_DELAY */
    delay(2.5e-3 - gt0 - 2.0*GRADIENT_DELAY - pw);
    rgpulse(2.0*pw, zero, 0.0, 0.0);
    delay(2.5e-3 - pw);

    ncyc = (100.0*relaxT);
    initval(ncyc,v4);
    if (ncyc > 0)
	{loop(v4,v5);

	 delay(2.5e-3 - pw);
    	 rgpulse(2.0*pw, two, 0.0, 0.0);
   	 delay(2.5e-3 - pw);

	 delay(2.5e-3 - pw);
    	 rgpulse(2.0*pw, zero, 0.0, 0.0);
   	 delay(2.5e-3 - pw);

	 endloop(v5);}

    dec2rgpulse(pwN, three, 0.0, 0.0);
   }

		/*   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    */

			     /* Theory suggests 8.0 is better than 2PI as RF  */
			     /* field multiplier and experiment confirms this.*/
if  (T1rho[A]=='y')          /* Shift evolution of 2.0*pwN/PI for one pulse   */
   {		             /* at end left unrefocused as for normal sequence*/
    delay(1.0/(8.0*slNrf) - pwN);
    decrgpulse(pwN, zero, 0.0, 0.0);
    dec2power(slNlvl);
           				   /* minimum 5ms spinlock to dephase */
    dec2rgpulse((2.5e-3-pw), zero, 0.0, 0.0);	         /*  spins not locked */
    sim3pulse(2.0*pw, 0.0, 2.0*pw, zero, zero, zero, 0.0, 0.0);
    dec2rgpulse((2.5e-3-pw), zero, 0.0, 0.0);

    ncyc = 100.0*relaxT;
    initval(ncyc,v4);	    if (ncyc > 0)
	  {loop(v4,v5);
           dec2rgpulse((2.5e-3-pw), zero, 0.0, 0.0);
   	   sim3pulse(2.0*pw, 0.0, 2.0*pw, two, zero, zero, 0.0, 0.0);
           dec2rgpulse((2.5e-3-pw), zero, 0.0, 0.0);
           dec2rgpulse((2.5e-3-pw), zero, 0.0, 0.0);
   	   sim3pulse(2.0*pw, 0.0, 2.0*pw, zero, zero, zero, 0.0, 0.0);
           dec2rgpulse((2.5e-3-pw), zero, 0.0, 0.0);
           endloop(v5);} 

    dec2power(pwNlvl);	
    decrgpulse(pwN, zero, 0.0, 0.0);
    delay(1.0/(8.0*slNrf) + 2.0*pwN/PI - pwN);
   }
		/*   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    */

if  (T2[A]=='y')
   {
    dec2phase(zero);
    initval(0.0,v3);   initval(180.0,v4);
    if (BPpwrlimits > 0.5)
     {
      dec2power(pwNlvl-3.0);    /* reduce for probe protection */
      pwN=pwN*compN*1.4;
     }

    ncyc = 100.0*relaxT;
    initval(ncyc,v5);

    loop(v5,v6);

      initval(3.0,v7);
      loop(v7,v8);
       	delay(0.625e-3 - pwN);
      	dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
      	delay(0.625e-3 - pwN);
      endloop(v8);

      delay(0.625e-3 - pwN - SAPS_DELAY);
      add(v4,v3,v3);  obsstepsize(1.0);  xmtrphase(v3);	   	/* SAPS_DELAY */
      dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
      delay(0.625e-3 - pwN - pw);

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

      delay(0.625e-3 - pwN - pw );
      dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
      xmtrphase(zero);						/* SAPS_DELAY */
      delay(0.625e-3 - pwN - SAPS_DELAY);
  
      initval(3.0,v9);
      loop(v9,v10);
      	delay(0.625e-3 - pwN);
      	dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
      	delay(0.625e-3 - pwN);
      endloop(v10);

    endloop(v6);
    if (BPpwrlimits > 0.5)
     {
      dec2power(pwNlvl);    /* restore normal value */
      pwN=getval("pwN");
     }
   }

/*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 EVOLUTION    xxxxxxxxxxxxxxxxxxxxx  */
	txphase(zero);
	dec2phase(t9);

if ( (NH2only[A]=='y') || (T1[A]=='y') || (T1rho[A]=='y') || (T2[A]=='y') )	
{      
    	delay(tau1);
         			  /* optional sech/tanh pulse in middle of t1 */
    	if (C13refoc[A]=='y') 				   /* WFG_START_DELAY */
           {decshaped_pulse("stC200", 1.0e-3, zero, 0.0, 0.0);
            delay(tNH - 1.0e-3 - WFG_START_DELAY - 2.0*pw);}
    	else
           {delay(tNH - 2.0*pw);}
    	rgpulse(2.0*pw, zero, 0.0, 0.0);
    	if (tNH < gt1 + 1.99e-4)  delay(gt1 + 1.99e-4 - tNH);

    	delay(tau1);

    	dec2rgpulse(2.0*pwN, t9, 0.0, 0.0);

        if (mag_flg[A] == 'y')  magradpulse(gzcal*gzlvl1, gt1);
        else  zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	txphase(t4);
    	dec2phase(t10);
   	if (tNH > gt1 + 1.99e-4)  delay(tNH - gt1 - 2.0*GRADIENT_DELAY);
   	else   delay(1.99e-4 - 2.0*GRADIENT_DELAY);
}

else if (TROSY[A]=='y')
{
  	if ( (C13refoc[A]=='y') && (tau1 > 0.5e-3 + WFG2_START_DELAY) )
           {delay(tau1 - 0.5e-3 - WFG2_START_DELAY);     /* WFG2_START_DELAY */
            decshaped_pulse("stC200", 1.0e-3, zero, 0.0, 0.0);
            delay(tau1 - 0.5e-3);}
	else    delay(2.0*tau1);

        if (mag_flg[A] == 'y')  magradpulse(gzcal*gzlvl1, gt1);
        else  zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	delay(2.0e-4 - 2.0*GRADIENT_DELAY);

	dec2rgpulse(2.0*pwN, t9, 0.0, 0.0);

	txphase(three);

        delay(gt1 + 2.0e-4 - pwHs - 1.0e-4 - 2.0*pwr_dly);
        obspower(tpwrs);
	if (tpwrsf<4095.0) obspwrf(tpwrsf);
        shaped_pulse("H2Osinc", pwHs, three, 5.0e-5, 0.0);
        obspower(tpwr);
	if (tpwrsf<4095.0) obspwrf(4095.0);

	txphase(t4);
	delay(5.0e-5);
}

else
{					  	    /* fully-coupled spectrum */
        if (dm2[C]=='n')  {rgpulse(2.0*pw, zero, 0.0, 0.0);  pw=0.0;}		

  	if ( (C13refoc[A]=='y') && (tau1 > 0.5e-3 + WFG2_START_DELAY) )
           {delay(tau1 - 0.5e-3 - WFG2_START_DELAY);     /* WFG2_START_DELAY */
            simshaped_pulse("", "stC200", 2.0*pw, 1.0e-3, zero, zero, 0.0, 0.0);
            delay(tau1 - 0.5e-3);
            delay(gt1 + 2.0e-4);}
	else
           {delay(tau1);
            rgpulse(2.0*pw, zero, 0.0, 0.0);
            delay(gt1 + 2.0e-4 - 2.0*pw);
            delay(tau1);} 
 
	pw=getval("pw");
	dec2rgpulse(2.0*pwN, t9, 0.0, 0.0);

        if (mag_flg[A] == 'y')  magradpulse(gzcal*gzlvl1, gt1);
        else  zgradpulse(gzlvl1, gt1);   	/* 2.0*GRADIENT_DELAY */
	txphase(t4);
	dec2phase(t10);
	delay(2.0e-4 - 2.0*GRADIENT_DELAY);
}

	if  (T1rho[A]=='y')   delay(POWER_DELAY); 


/*  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(1.5*gzlvl5, 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(1.5*gzlvl5, 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.65*pw + 2.0*GRADIENT_DELAY + POWER_DELAY);

        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 */
           }

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

	dec2power(dpwr2);				       /* POWER_DELAY */
        if (mag_flg[A] == 'y')	  magradpulse(icosel*gzcal*gzlvl2, 0.1*gt1);
        else   zgradpulse(icosel*gzlvl2, 0.1*gt1);		/* 2.0*GRADIENT_DELAY */
        

        if(Cdecflg[0] == 'y')
        {
          delay(gstab-2.0*POWER_DELAY-PRG_START_DELAY+rof2);
          rcvron();
                           
          statusdelay(C,1.0e-4);		

          if (dm3[B] == 'y') 
          {
            delay(1/dmf3); 
            lk_sample();
          }
	  setreceiver(t12);
          pbox_decon(&Cdseq);
          
          if(Hdecflg[0] == 'y')
            homodec(&HHdseq);  
        }
        else
        {
          delay(gstab+rof2);
          rcvron();
                             
          statusdelay(C,1.0e-4);		

          if (dm3[B] == 'y') 
          {
            delay(1/dmf3); 
            lk_sample();
          }
	  setreceiver(t12);

          if(Hdecflg[0] == 'y')
            homodec(&HHdseq);        
        }
}		 
Beispiel #16
0
pulsesequence()

{
   char         normal[MAXSTR],
                focus[MAXSTR];
   int          rxgate;
   double       pp,
		pplvl,
                j,
                mult;


   rxgate = (rof1 == 0.0);
   if (rxgate)
      rof1 = 1.0e-6;		/* phase switching time */

   j = getval("j");
   pp = getval("pp");
   mult = getval("mult");
   getstr("focus", focus);
   getstr("normal", normal);

   if (newdecamp)
   {
      if (rxgate)
         rof1 = 40.0e-6;
   }

/* if mult is zero, then do normal s2pul sequence */
   if (mult == 0.0)
   {
      status(A);
         hsdelay(d1);
         pulse(p1, zero);
      status(B);
         delay(d2);
      status(C);
      settable(t1,4,phasecycle);
      pulse(pw,t1);
      setreceiver(t1);
   }
   else
   {
      if (j != 0.0)
      {				/* calculation of delays */
	 d3 = 1.0 / (2.0 * j);
	 if (mult < 2.5)
	 {
	    d2 = 1.0 / (2.0 * j);
	 }
	 else if (mult < 3.5)
	 {
	    d2 = 3.0 / (4.0 * j);
	 }
	 else
	 {
	    d2 = 1.0 / (3.0 * j);
	 }
      }

/* setup phases */
      hlv(oph, v1);		/* 0011 */
      dbl(v1, v1);		/* 0022 */
      mod2(oph, v2);		/* 0101 */

/* do equilibration delay */
      if ((dm[A] == 'y') || (dm[B] == 'y'))
      {
	 (void) printf("Decoupler must be set as dm=nny or n\n");
	 psg_abort(1);
      }
      else
      {
         if (newdecamp)
         {
            pplvl  = getval("pplvl");
            decpower(pplvl);	/* sets DEC atten = pplvl */
         }
         else
         {
	    declvlon();		/* sets dhp = 255 level */
         }
      }

      status(A);
         if (rxgate)
	    rcvroff();
         delay(d1);

/* excitation transfer */
      status(B);
         decrgpulse(pp, v1, rof1, rof1);
         delay(d3/2 - 2*rof1 - 3*pp/2);
         simpulse(2*pw, 2*pp, zero, zero, rof1, rof1);
         delay(d3/2 - 2*rof1 - 3*pp/2);
         simpulse(pw, pp, v2, one, rof1, rof2);

/* make decision on refocussing */
         if ((focus[A] == 'y') || (dm[C] == 'y'))
         {
	    delay(d2/2 - rof1 - pp);	/* refocussing delay varied for 2d */
            simpulse(2*pw, 2*pp, v2, zero, rof1, rof2);
	    delay(d2/2 - rof2 - pp);
         }
         else if (normal[A] == 'y')
         {
	    decrgpulse(pp, v1, 1.0e-6, 0.0);
         }

         if (newdecamp)
         {
            decpower(dpwr);	/* set DEC attten = dpwr */
         }
         else
         {
	    declvloff();
         }

      status(C);
         if (rxgate)
	    rcvron();
   }
}
Beispiel #17
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);
}		 
Beispiel #18
0
void pulsesequence()
{
double  gzlvlE = getval("gzlvlE"),
        gtE = getval("gtE"),
        EDratio = getval("EDratio"),
        gstab = getval("gstab"),
        mult = getval("mult"),
	pwx180 = getval("pwx180"),
	pwxlvl180 = getval("pwxlvl180"),
	pwx180r = getval("pwx180r"),
	pwxlvl180r = getval("pwxlvl180r"),
        hsglvl = getval("hsglvl"),
        hsgt = getval("hsgt"),
        tauA=getval("tauA"),        //compensation for tauB and tauD
        tauB=getval("tauB"),        //effect of rof2
        tauD=getval("tauD"),        //effect of alfa
        tBal=getval("tBal"),        //supports inova console if ~1/(fb*1.3)
        pwr_XBIP = getval("pwr_XBIP"),
        pw_XBIP = getval("pw_XBIP"),
        pwr_HBIP = getval("pwr_HBIP"),
        pw_HBIP = getval("pw_HBIP"),
        gzlvlcr = getval("gzlvlcr"),
        gtcr = getval("gtcr"),        //crusher gradient in BIRD
        npoints = getval("npoints"),  // npoints should be an integer multiple of np
        tau, evolcorr, taug,cycles;
int     prgcycle = (int)(getval("prgcycle")+0.5),
	phase1 = (int)(getval("phase")+0.5),
	icosel, ZZgsign;
char	pwx180ad[MAXSTR], pwx180adR[MAXSTR], pwx180ref[MAXSTR],
        shp_XBIP[MAXSTR], shp_HBIP[MAXSTR], BIRD[MAXSTR], BIRDmode[MAXSTR];

//synchronize gradients to srate for probetype='nano'
//   Preserve gradient "area"
        gtE = syncGradTime("gtE","gzlvlE",0.5);
        gzlvlE = syncGradLvl("gtE","gzlvlE",0.5);

  getstr("pwx180ad", pwx180ad);
  getstr("pwx180adR", pwx180adR);
  getstr("pwx180ref", pwx180ref);
  getstr("shp_XBIP",shp_XBIP);
  getstr("shp_HBIP",shp_HBIP);
  getstr("BIRD",BIRD);
  getstr("BIRDmode",BIRDmode);

  tau = 1 / (4*(getval("j1xh")));
  evolcorr = (4*pwx/PI)+2*pw+8.0e-6;
  cycles=np/npoints;
  cycles = (double)((int)((cycles)));
  initval(cycles,v20);

  if (mult > 0.5)
    taug = 2*tau + getval("tauC");
  else
    taug = gtE + gstab + 2 * GRADIENT_DELAY;
  ZZgsign=-1; 
  if (mult == 2) ZZgsign=1;
  icosel = 1;
 
  assign(ct,v17);
  assign(zero,v18);
  assign(zero,v19);

  if (getflag("prgflg") && (satmode[0] == 'y') && (prgcycle > 1.5))
    {
        hlv(ct,v17);
        mod2(ct,v18); dbl(v18,v18);
        if (prgcycle > 2.5)
           {
                hlv(v17,v17);
                hlv(ct,v19); mod2(v19,v19); dbl(v19,v19);
           }
     }
 
     if (BIRD[0]=='n')          //gHSQC phases
        {
                settable(t1,4,ph1);
                settable(t2,2,ph2);
                settable(t3,8,ph3);
                settable(t4,16,ph4);
                settable(t5,16,ph5);
        }
     else                      //rtgHSQC-BIRD phases
        {
                settable(t1,8,ph11);
                settable(t2,2,ph12);
                settable(t3,16,ph13);
                settable(t4,32,ph14);
                settable(t5,32,ph15);
                settable(t7,4,ph17);
                settable(t8,4,ph18);
                settable(t9,4,ph19);
                getelem(t7, v17, v7);
                getelem(t8, v17, v8);
                getelem(t9, v17, v9);
        }

     getelem(t1, v17, v1);
     getelem(t3, v17, v3);
     getelem(t4, v17, v4);
     getelem(t2, v17, v2);
     getelem(t5, v17, oph);

  assign(zero,v6);
  add(oph,v18,oph);
  add(oph,v19,oph);

  if ((phase1 == 2) || (phase1 == 5))
    icosel = -1;

  initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v14);
  add(v2, v14, v2);
  add(oph, v14, oph);

status(A);
   obspower(tpwr); decpower(pwxlvl);
   delay(5.0e-5);
   if (getflag("sspul"))
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        if (getflag("slpsat"))
           {
                shaped_satpulse("relaxD",satdly,zero);
                if (getflag("prgflg"))
                   shaped_purge(v6,zero,v18,v19);
           }
        else
           {
                satpulse(satdly,zero,rof1,rof1);
                if (getflag("prgflg"))
                   purge(v6,zero,v18,v19);
           }
     }
   else
        delay(d1);

   if (getflag("wet"))
     wet4(zero,one);

  status(B);
              /****** null flag starts here *****/
    if (getflag("nullflg"))
    {
      rgpulse(0.5 * pw, zero, rof1, rof1);
      delay(2 * tau);
      decpower(pwxlvl180);
      decshaped_pulse(pwx180ad, pwx180, zero, rof1, rof1);
      rgpulse(2.0 * pw, zero, rof1, rof1);
      delay(2 * tau + 2 * POWER_DELAY);
      decshaped_pulse(pwx180adR, pwx180, zero, rof1, rof1);
      decpower(pwxlvl);
      rgpulse(1.5 * pw, two, rof1, rof1);
      zgradpulse(hsglvl, hsgt);
      delay(1e-3);
    }

/*********gHSQC or gHSQC part of pure shift starts here *****/

    if (getflag("cpmgflg"))
    {
      rgpulse(pw, v6, rof1, 0.0);
      cpmg(v6, v15);
    }
    else
      rgpulse(pw, v6, rof1, rof1);
    delay(tau);
    decpower(pwxlvl180);
    decshaped_pulse(pwx180ad, pwx180, zero, rof1, rof1);
    rgpulse(2.0 * pw, zero, rof1, rof1);
    delay(tau + 2 * POWER_DELAY);
    decshaped_pulse(pwx180adR, pwx180, zero, rof1, rof1);
    decpower(pwxlvl);
    rgpulse(pw, v1, rof1, rof1);
    zgradpulse(hsglvl, 2 * hsgt);
    delay(1e-3);
    decrgpulse(pwx, v2, rof1, 2.0e-6);

      delay(d2 / 2);
    rgpulse(2 * pw, zero, 2.0e-6, 2.0e-6);
      delay(d2 / 2);

    delay(taug - POWER_DELAY);
    if (mult > 0.5)
    {
    decpower(pwxlvl180r);
    decshaped_pulse(pwx180ref, pwx180r, zero, rof1, rof1);
    rgpulse(mult * pw, zero, rof1, rof1);
    delay(taug - mult * pw - 2 * rof1 + POWER_DELAY - gtE - gstab - 2 * GRADIENT_DELAY+evolcorr);
    zgradpulse(gzlvlE, gtE);
    delay(gstab);
    decshaped_pulse(pwx180ref, pwx180r, zero, rof1, rof1);
    }
    else
    {
    decpower(pwxlvl180);
    decshaped_pulse(pwx180ad, pwx180, zero, rof1, rof1);
    delay(taug + POWER_DELAY - gtE - gstab - 2 * GRADIENT_DELAY+evolcorr);
    zgradpulse(gzlvlE, gtE);
    delay(gstab);
    decshaped_pulse(pwx180ad, pwx180, zero, rof1, rof1);
    }

    decpower(pwxlvl);

    decrgpulse(pwx, v4, 2.0e-6, rof1);
    zgradpulse(ZZgsign*0.6 * hsglvl, 1.2 * hsgt);
    delay(1e-3);
    rgpulse(pw, v3, rof1, rof1);
    decpower(pwxlvl180);
    decshaped_pulse(pwx180adR, pwx180, zero, rof1, rof1);
    decpower(dpwr);
    delay(tau - (2 * pw / PI) - 2*rof1);
    rgpulse(2 * pw, zero, rof1, rof2);
    decpower(pwxlvl180);
    decshaped_pulse(pwx180ad, pwx180, zero, rof1, rof1);
    decpower(dpwr);
    zgradpulse(icosel * 2.0*gzlvlE/EDratio, gtE/2.0);
    delay(tau - gtE/2.0 - 2 * GRADIENT_DELAY);

/********gHSQC part stops and BIRD Acquisition starts here*************/
    // delay(tBal);
        //filter delay (Hoult) for inova; adjust tBal manually for the same effect
        //delay(1.0/(getval("fb")*1.3))

        if (BIRD[0]=='y')
        {
#ifdef NVPSG
                setacqmode(WACQ|NZ);    //use this line only for vnmrs console; comment this out in inova
#endif
                obsblank();
//                delay(rof2);
                startacq(alfa);
        }

/*----------------------------------------------------------------------------
         Observe the 1st half chunk
-----------------------------------------------------------------------------*/

        if (BIRD[0]=='y')
        {
                status(C);
                acquire(npoints/2.0,1.0/sw);
                rcvroff();                                            
                status(B);
                obspower(tpwr);

/*------------------------------------------------------------------------
         Using hard 13C inversion pulse in BIRD
--------------------------------------------------------------------------*/

                if (BIRDmode[0]== 'h')
                {
                        rgpulse(pw,v7,rof1,rof1);
                        decpower(pwxlvl);
                        delay(tau);        
                        zgradpulse(gzlvlcr,gtcr);
                        delay(tau-gtcr);
                        simpulse(2.0*pw,2.0*pwx,v8,v8,rof1,rof1);
                        decpower(dpwr);
                        delay(tau);
                        zgradpulse(gzlvlcr,gtcr);
                        delay(tau-gtcr);
                        rgpulse(pw,v9,rof1,rof1);
                }

/*---------------------------------------------------------------------------
        Using BIP 13C inversion pulse in BIRD
----------------------------------------------------------------------------*/

                if (BIRDmode[0]== 'b')
                {
                  rgpulse(pw,v7,rof1,rof1);                     
                  if (pwr_XBIP!=pwxlvl) decpower(pwr_XBIP); else decpower(pwxlvl);
                  if (pwr_HBIP!=tpwr)  obspower(pwr_HBIP);
                  delay(tau); 
                  zgradpulse(gzlvlcr,gtcr);
                  delay(tau-gtcr);                              
                  simshaped_pulse(shp_HBIP,shp_XBIP,2.0*pw,pw_XBIP,v8,v8,rof1,rof1);
                  if (pwr_HBIP!=tpwr) obspower(tpwr);
                  decpower(dpwr);
                  delay(tau);
                  zgradpulse(gzlvlcr,gtcr);
                  delay(tau-gtcr);
                  rgpulse(pw,v9,rof1,rof1);
                }
                
                delay(tauA);
                rgpulse(pw*2.0,v7,rof1,rof1);  // hard 180 degree refocusing pulse
                obsblank();
                delay(tauB);
                rcvron();       //this includes rof3
                delay(tauD);
                decr(v20);

/*------------------------------------------------------------------------------
                Loops for more chunks
------------------------------------------------------------------------------*/

                starthardloop(v20);
                status(C);
                        acquire(npoints,1.0/sw);
                        rcvroff();                                    
                status(B);
                        obspower(tpwr);                               

/*------------------------------------------------------------------------                                              
Using hard 13C inversion pulse in BIRD
--------------------------------------------------------------------------*/
                if (BIRDmode[0]== 'h')
                {
                        rgpulse(pw,v7,rof1,rof1);
                        decpower(pwxlvl);                             
                        delay(tau);         
                        zgradpulse(gzlvlcr,gtcr);
                        delay(tau-gtcr);                      
                        simpulse(2.0*pw,2.0*pwx,v8,v8,rof1,rof1);
                        decpower(dpwr);
                        delay(tau);
                        zgradpulse(gzlvlcr,gtcr);
                        delay(tau-gtcr);
                        rgpulse(pw,v9,rof1,rof1);
                }
/*---------------------------------------------------------------------------
Using BIP 13C inversion pulse in BIRD
----------------------------------------------------------------------------*/
//                if (BIRDmode[0]== 'b')
                if (BIRDmode[0]== 'b')
                {
                        rgpulse(pw,v7,rof1,rof1);                     
                        if (pwr_XBIP!=pwxlvl) decpower(pwr_XBIP); else decpower(pwxlvl);
                        delay(tau);      
                        zgradpulse(gzlvlcr,gtcr);
                        delay(tau-gtcr);                         
                        simshaped_pulse(shp_HBIP,shp_XBIP,2*pw,pw_XBIP,v8,v8,rof1,rof1);
                        decpower(dpwr);
                        delay(tau);
                        zgradpulse(gzlvlcr,gtcr);
                        delay(tau-gtcr);
                rgpulse(pw,v9,rof1,rof1);
                }

                delay(tauA);
                rgpulse(pw*2.0,v7,rof1,rof1);            // hard 180 degree refocusing pulse
                obsblank();
                delay(tauB);
                rcvron();       //this includes rof3
                delay(tauD);

                endhardloop();

/*----------------------------------------------------------------
                Acquisition of last half chunk
----------------------------------------------------------------*/
                status(C);
                        acquire(npoints/2.0,1.0/sw);
                        rcvroff();                                    
                        endacq();
                        incr(v20);
        }
                 /****** BIRD ends here for all *****/
/***************** ACQ for conventional gHSQC ******************************/
        else
        status(C);
}
Beispiel #19
0
pulsesequence()
{
   double          p1lvl = getval("p1lvl"),
                   phase = getval("phase"),
                   mix = getval("mix"),
                   cycles, d2corr,
                   gt1 = getval("gt1"),
                   gzlvl1 = getval("gzlvl1");
   int             iphase;
   char            mfsat[MAXSTR],sspul[MAXSTR],T_flg[MAXSTR];


/* LOAD AND INITIALIZE PARAMETERS */
   iphase = (int) (phase + 0.5);
   satdly = getval("satdly");
   satpwr = getval("satpwr");
   satfrq = getval("satfrq");
   getstr("sspul", sspul);
   getstr("mfsat", mfsat);
   getstr("satmode", satmode);
   getstr("T_flg", T_flg);

/* CALCULATE PHASES AND INITIALIZE LOOP COUNTER FOR MIXING TIME */
   settable(t1,8,phi1);
   settable(t2,8,phi2);
   settable(t3,8,phi3);
   settable(t4,8,phi4);
   settable(t5,8,phi5);
   getelem(t1,ct,v1);
   assign(v1,oph);	
   if (iphase == 2)
      incr(v1);			/* BC2D hypercomplex method */

/* FOR HYPERCOMPLEX, USE REDFIED TRICK TO MOVE AXIALS TO EDGE */  
   initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v9); /* moves axials */
   if ((iphase==2)||(iphase==1)) {add(v1,v9,v1); add(oph,v9,oph);}

   cycles = mix / (16.0 * (4e-6 + 2.0*pw));
   initval(cycles, v10);	/* mixing time cycles */

/* BEGIN ACTUAL PULSE SEQUENCE */
   status(C);
   obspower(p1lvl);
   if (sspul[A] == 'y')
   {
     zgradpulse(gzlvl1,gt1);
     delay(5.0e-5);
     rgpulse(p1,zero,rof1,rof1);
     zgradpulse(gzlvl1,gt1); 
     delay(5.0e-5);
   }
   status(A);
   if (satmode[A] == 'y') 
    {
    rcvroff();
    if (d1 > satdly) delay(d1-satdly);
    if (mfsat[A] == 'y')
     {obsunblank(); mfpresat_on(); delay(satdly); mfpresat_off(); obsblank();}
    else
     {
     if (tof != satfrq) obsoffset(satfrq);
     obspower(satpwr);
     rgpulse(satdly,zero,rof1,rof1);
     if (tof != satfrq) obsoffset(tof);
     }
     obspower(p1lvl);
    }
    else
     {
      delay(d1);
      rcvroff();
     }
   status(B);
   obsstepsize(45.0);
   initval(7.0,v4);  
   xmtrphase(v4);
   rgpulse(p1,v1,rof1,1.0e-6);
   xmtrphase(zero);   
   d2corr = rof1 + 1.0e-6 + (2*p1/3.1416) + SAPS_DELAY;
   if (d2 > d2corr) delay(d2 - d2corr); else delay(0.0);
   if ((T_flg[0] == 'y')&&(cycles > 1.5))
    {
      rgpulse(p1,t4,rof1,rof1);
      obspower(tpwr);
      {
         starthardloop(v10);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
            rgpulse(2.0*pw,t2,4e-6,0.0);
            rgpulse(2.0*pw,t3,4e-6,0.0);
         endhardloop();
      }
      obspower(p1lvl);
      rgpulse(p1,t5,rof1,rof2); 
    }  
/* The ROESY spin-lock unit is executed sixteen times within the
   hardware loop so that it is of sufficient duration to allow
   the acquisition hardware loop to be loaded in behind it on
   the last pass through the spin-lock loop. */

   else
    {
      obspower(tpwr);
      rgpulse(mix,t2,rof1,rof2);        /* cw spin lock  */
    }
   rcvron();
   status(C);
}
Beispiel #20
0
void pulsesequence()
{
  double j,pwxpwr,gzlvl1,gt1,gzlvl2,gt2,gzlvl3,gt3,grise,gstab,phase;
  double taumb = 0.0;
  int  icosel,t1_counter;
  char mbond[MAXSTR];

  sw1 = getval("sw1");
  j = getval("j");
  pwxpwr = getval("pwxpwr");
  pwx = getval("pwx");
  gzlvl1 = getval("gzlvl1");
  gt1 = getval("gt1");
  gzlvl2 = getval("gzlvl2");
  gt2 = getval("gt2");
  gzlvl3 = getval("gzlvl3");
  gt3 = getval("gt3");
  grise = getval("grise");
  gstab = getval("gstab");
  phase = getval("phase");
  getstr("mbond", mbond);
  if (mbond[0] == 'y')
      taumb = getval("taumb");

  tau=1/(2.0*j);

  if(tau < (gt3+grise)) 
  {
    text_error("tau must be greater than gt3+grise\n");
    psg_abort(1);
  }

  settable(t1,4,ph1);
  settable(t2,8,ph2);
  settable(t3,4,ph3);
  settable(t4,4,ph4);
  settable(t5,4,ph5);
  settable(t6,4,ph6);
  settable(t7,4,ph7);
  settable(t8,4,ph8);
  settable(t9,4,ph9);
  settable(t10,4,ph10);

/* Gradient incrementation for hypercomplex data */

   if (phase == 2)     /* Hypercomplex in t1 */
   {
      icosel = -1; /* change sign of gradient */
   }
   else icosel = 1;

/* calculate modification to phases based on current t1 values
   to achieve States-TPPI acquisition */
 
   if(ix == 1)
      d2_init = d2;
 
      t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5);
       
      if(t1_counter %2)  
      {
        tsadd(t9,2,4);
        tsadd(t10,2,4);
      }
 

  status(A);
     decpower(pwxpwr);
     delay(d1);
   if (getflag("wet")) wet4(zero,one);
     decpower(pwxpwr);
     rcvroff();

  status(B);
     rgpulse(pw,t1,rof1,rof2);
     delay(tau);
      if (mbond[0] == 'y')                      /* one-bond J(CH)-filter */
      {
         decrgpulse(pwx, t2, rof1, 0.0);
         delay(taumb - tau - rof1 - pwx);
      }

   decrgpulse(pwx,t3,rof1,rof2);
     decphase(t5);
     delay(gt1 + (grise*2.0) + (2.0*GRADIENT_DELAY));
     decrgpulse(pwx*2.0,t3,rof1,rof2);
     txphase(t6);
     rgradient('z',gzlvl1);
     delay(gt1+grise);
     rgradient('z',0.0);
     delay(grise);
   if (d2 > 0);   
     delay(d2/2 + (2.0*pwx/3.14159) - pw + D2_FUDGEFACTOR);

 rgpulse(pw*2.0,t6,rof1,rof2);

     decphase(t9);
     rgradient('z',gzlvl2);
     delay(gt2+grise);
     rgradient('z',0.0);
     delay(grise);
   if (d2 > 0);   
     delay(d2/2 + (2.0*pwx/3.14159) - pw + D2_FUDGEFACTOR);
     decrgpulse(pwx*2.0,t9,rof1,rof2);
     decphase(t9);
     delay(gt2 + (grise*2.0) + (2.0*GRADIENT_DELAY));
     decrgpulse(pwx,t9,rof1,rof2);

     rgradient('z',(double)icosel*gzlvl3);
     delay(gt3+grise);
     rgradient('z',0.0);
     decpower(dpwr);
     setreceiver(t10); 
     rcvron();
     delay(tau-(gt3+grise));
/*     delay(gstab); (Needs to be zero to phase f2 automatically) */
 
  status(C);
} 
Beispiel #21
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 */
            t1b,
            t1c,
	    tauCH = getval("tauCH"), 		         /* 1/4J delay for CH */
            timeTN = getval("timeTN"),     /* constant time for 15N evolution */
            timeAB = getval("timeAB"),	   /* set timeAB=1.9e-3 to get only Ha */
            				  /* set timeAB=3.3e-3 to maximize Hb */
            				  /* set timeAB=2.8e-3 for both Ha/Hb */
	    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 */

/* 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,	  	                            /* 7.3 kHz rf for DIPSI-2 */
   	DIPSI2time,     	        /* total length of DIPSI-2 decoupling */
        ncyc_dec,
        waltzB1=getval("waltzB1"),     /* RF strength for 1H decoupling      */

	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   */

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

    if( pwC > 24.0e-6*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.0*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.0)/(pwH*2590.0*4.0);
        ncyc_dec = (int) (ncyc_dec+0.5);
	pwH = (DIPSI2time*90.0)/(ncyc_dec*2590.0*4.0); /*fine correction of pwH */
	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);
      }


/* 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;    
	 }



/*  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 tauCH */
    tauCH = tauCH - gt0 - 2.0*GRADIENT_DELAY - 5.0e-5;

 if ((ni-1)/(2.0*sw1) > 2.0*tauCH)
    {
      if (tau1 > 2.0*tauCH) sheila = tauCH;
      else if (tau1 > 0) sheila = 1.0/(1.0/tau1+1.0/tauCH-1.0/(2.0*tauCH));
      else          sheila = 0.0;
    }
 else
    {
      if (tau1 > 0) sheila = 1.0/(1.0/tau1 + 1.0/tauCH - 2.0*sw1/((double)(ni-1)));
      else          sheila = 0.0;
    }
    t1a = tau1 + tauCH;
    t1b = tau1 - sheila;
    t1c = tauCH - 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); }


/* For ni<2 (calibration) set timeAB=1.5ms to get avoid signal cancellation between Ha and Hb */
   if (ni < 2.0) timeAB=1.5e-3;



/* BEGIN PULSE SEQUENCE */


status(A);
        delay(d1);
        if ( dm3[B] == 'y' )
           lk_sample();  /*freezes z0 correction, stops lock pulsing*/

        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(); lk_sampling_off();}  /*freezes z0 correction, stops lock pulsing*/

        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 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);

      if ( dm3[B] == 'y' )     /* begins optional 2H decoupling */
        {
          gzlvl0=0.0; gzlvl3=0.0; gzlvl4=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);
        }

        rgpulse(pw, one, 0.0, 0.0);                    /* 1H pulse excitation */
                                                                /* point a */
        txphase(zero);
        decphase(zero);
        zgradpulse(gzlvl0, gt0);                        /* 2.0*GRADIENT_DELAY */
        delay(5.0e-5);
        if((t1a -2.0*pwC) > 0.0) delay(t1a - 2.0*pwC);

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

        delay(t1b);

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

        zgradpulse(gzlvl0, gt0);                        /* 2.0*GRADIENT_DELAY */
        txphase(t3);
        delay(5.0e-5);
        delay(t1c);
                                                                /* point b */
        rgpulse(pw, t3, 0.0, 0.0);
        zgradpulse(gzlvl3, gt3);
        delay(2.0e-4);
        decrgpulse(pwC, zero, 0.0, 0.0);
                                                                /* point c */
        zgradpulse(gzlvl4, gt4);
        decpwrf(rf2);
        delay(timeAB - gt4);

        simpulse(2*pw, pwC2, zero, zero, 0.0, 0.0);

        zgradpulse(gzlvl4, gt4);
        delay(timeAB - gt4);
                                                                /* point d */

/* ghc_co_nh STOPS HERE */
/* gcbca_co_nh STARTS HERE */


	decpwrf(rf1);                                         	/* point b */
   	decrgpulse(pwC1, zero, 2.0e-6, 0.0);
	obspwrf(tpwr1); obspower(tpwr-6);				      /* POWER_DELAY */
	obsprgon("dipsi2", pwH, 5.0);		          /* PRG_START_DELAY */
	xmtron();
                    						/* point c */
	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 d */
   	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 e */
	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 f */
	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);

	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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* 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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* 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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* 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 g */
/*  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);
}		 
Beispiel #22
0
pulsesequence()
{



/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            imino[MAXSTR], amino[MAXSTR],
            mag_flg[MAXSTR],       /*magic-angle coherence transfer gradients */
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
            C13refoc[MAXSTR],		/* C13 sech/tanh pulse in middle of t1*/
	    NH2only[MAXSTR];		       /* spectrum of only NH2 groups */

 
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      tau1,         				         /*  t1 delay */
	    mix = getval("mix"),		 	    /* NOESY mix time */
            tau2,        				         /*  t2 delay */
	    lambda = 0.94/(4.0*getval("JNH")),	    /* 1/4J H1 evolution delay */
	    tNH = 1.0/(4.0*getval("JNH")),	  /* 1/4J N15 evolution delay */

        
        
/* the sech/tanh pulse is automatically calculated by the macro "proteincal", */  /* and is called directly from your shapelib.                  		      */
   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 */
   rfst,	                           /* fine power for the stCall pulse */
   compH = getval("compH"),         /* adjustment for H1 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 */

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

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

        gzcal=getval("gzcal"),
	gt1 = getval("gt1"),  		       /* coherence pathway gradients */
	gzlvl1 = getval("gzlvl1"),
	gzlvl2 = getval("gzlvl2"),

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

    getstr("f1180",f1180);
    getstr("imino",imino); getstr("amino",amino);
    getstr("mag_flg",mag_flg);
    getstr("f2180",f2180);
    getstr("C13refoc",C13refoc);
    getstr("NH2only",NH2only);



/*   LOAD PHASE TABLE    */

	settable(t1,2,phi1);
	settable(t3,4,phi3);

	settable(t9,16,phi9);
	settable(t10,1,phi10);
	settable(t11,8,rec);




/*   INITIALIZE VARIABLES   */

/* maximum fine power for pwC pulses (and initialize rfst) */
	rf0 = 4095.0;    rfst=0.0;

/* 180 degree adiabatic C13 pulse from 0 to 200 ppm */
    if (C13refoc[A]=='y')
       {rfst = (compC*4095.0*pwC*4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35));   
	rfst = (int) (rfst + 0.5);
	if ( 1.0/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35)) < pwC )
           { text_error( " Not enough C13 RF. pwC must be %f usec or less.\n", 
	    (1.0e6/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35))) ); psg_abort(1); }}

    /* 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 */




/* CHECK VALIDITY OF PARAMETER RANGES */

  if ( (mix - gt4 - gt5) < 0.0 )
  { text_error("mix is too small. Make mix equal to %f or more or reduce gt4+gt5.\n",(gt4 + gt5));
						   		    psg_abort(1); }

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

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

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

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



/* PHASES AND INCREMENTED TIMES */

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

    if (phase1 == 2) 
	 tsadd(t1,1,4);  
    if (phase2 == 1) 
	{ 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; }
    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( ix == 1) d3_init = d3;
   t2_counter = (int) ( (d3-d3_init)*sw2 + 0.5 );
   if(t2_counter % 2) 
	{ tsadd(t3,2,4); tsadd(t11,2,4); }



/*  Correct inverted signals for NH2 only spectra  */

   if (NH2only[A]=='y') 
      { tsadd(t3,2,4); }

if ( ((imino[A]=='y') && (amino[A]=='y')) )
   {
        printf(" Choose  ONE  of  imino='y'  OR  amino='y' ");
        psg_abort(1);
   }
 
  if ( ((imino[A]=='y') && (NH2only[A]=='y')) )
   {
        printf(" NH2only='y' only for amino='y'! ");
        psg_abort(1);
   }

/* BEGIN PULSE SEQUENCE */

status(A);
	obspower(tpwr);
	decpower(pwClvl);
 	dec2power(pwNlvl);
        if (imino[A] == 'y')
	  dec2offset(dof2 - 45*dfrq2);
        if (amino[A] == 'y')
	  dec2offset(dof2 - 115*dfrq2);
	decpwrf(rf0);
	txphase(zero);
        dec2phase(zero);

	delay(d1);

	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, one, 0.0, 0.0);
	zgradpulse(0.7*gzlvl0, 0.5e-3);

   	txphase(t1);
   	decphase(zero);
   	dec2phase(zero);
	initval(135.0,v1);
	obsstepsize(1.0);
	xmtrphase(v1);
	delay(5.0e-4);
	rcvroff();


   	rgpulse(pw, t1, 50.0e-6, 0.0);                     /* 1H pulse excitation */

        xmtrphase(zero);					/* SAPS_DELAY */
   	txphase(zero);
	if (C13refoc[A]=='y')
         {decpower(pwClvl-3.0); dec2power(pwNlvl-3.0);}

  if (tau1 > (2.0*GRADIENT_DELAY + pwN*1.4 + 0.64*pw + 5.0*SAPS_DELAY))  
   {
    if (C13refoc[A]=='y')
    {
     zgradpulse(gzlvl6, 0.8*(tau1 - 2.0*GRADIENT_DELAY - 1.4*pwN - 0.64*pw));
     delay(0.2*(tau1 - 2.0*GRADIENT_DELAY - 1.4*pwN - 0.64*pw) - SAPS_DELAY);
     sim3pulse(0.0, 2.0*pwC*1.4, 2.0*pwN*1.4, zero, zero, zero, 0.0, 0.0);
     zgradpulse(-1.0*gzlvl6, 0.8*(tau1 - 2.0*GRADIENT_DELAY - 1.4*pwN - 0.64*pw));
     delay(0.2*(tau1 - 2.0*GRADIENT_DELAY - 1.4*pwN - 0.64*pw));
    }
  else
    {
     zgradpulse(gzlvl6, 0.8*(tau1 - 2.0*GRADIENT_DELAY - pwN - 0.64*pw));
     delay(0.2*(tau1 - 2.0*GRADIENT_DELAY - pwN - 0.64*pw) - SAPS_DELAY);
     dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
     zgradpulse(-1.0*gzlvl6, 0.8*(tau1 - 2.0*GRADIENT_DELAY - pwN - 0.64*pw));
     delay(0.2*(tau1 - 2.0*GRADIENT_DELAY - pwN - 0.64*pw));
    } 
  }
  else if (tau1 > (0.64*pw + 0.5*SAPS_DELAY))
    delay(2.0*tau1 - 2.0*0.64*pw - SAPS_DELAY );
   	rgpulse(pw, zero, 0.0, 0.0);
	if (C13refoc[A]=='y')
         {decpower(pwClvl); dec2power(pwNlvl);}

	delay(mix - gt4 - gt5 -400.0e-6);
	zgradpulse(gzlvl4, gt4);
	dec2rgpulse(pwN, zero, 200.0e-6, 0.0);
	zgradpulse(gzlvl5, gt5);

   	rgpulse(pw, zero, 200.0e-6,0.0);			       /* HSQC begins */

   	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(two);
   	obspower(tpwrs);
   	shaped_pulse("H2Osinc", pwHs, two, 5.0e-4, 0.0);
	obspower(tpwr);
	zgradpulse(gzlvl3, gt3);
	dec2phase(t3);
	decpwrf(rfst);
	delay(2.0e-4);
   	dec2rgpulse(pwN, t3, 0.0, 0.0);
	decphase(zero);


/*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 EVOLUTION    xxxxxxxxxxxxxxxxxxxxx  */

        txphase(zero);
	dec2phase(t9);

if (NH2only[A]=='y')	
{      
    	delay(tau2);
         			  /* optional sech/tanh pulse in middle of t2 */
    	if (C13refoc[A]=='y') 				   /* WFG_START_DELAY */
           {decshaped_pulse("stC200", 1.0e-3, zero, 0.0, 0.0);
            delay(tNH - 1.0e-3 - WFG_START_DELAY - 2.0*pw);}
    	else
           {delay(tNH - 2.0*pw);}
    	rgpulse(2.0*pw, zero, 0.0, 0.0);
    	if (tNH < gt1 + 1.99e-4)  delay(gt1 + 1.99e-4 - tNH);

    	delay(tau2);

    	dec2rgpulse(2.0*pwN, t9, 0.0, 0.0);
                if (mag_flg[A] == 'y')
                {
                   magradpulse(gzcal*gzlvl1, gt1);
                }
                else
                {
                   zgradpulse(gzlvl1, gt1);
                }
    	dec2phase(t10);
   	if (tNH > gt1 + 1.99e-4)  delay(tNH - gt1 - 2.0*GRADIENT_DELAY);
   	else   delay(1.99e-4 - 2.0*GRADIENT_DELAY);
}

else
{
  	if ( (C13refoc[A]=='y') && (tau2 > 0.5e-3 + WFG2_START_DELAY) )
           {delay(tau2 - 0.5e-3 - WFG2_START_DELAY); /* WFG2_START_DELAY */
            simshaped_pulse("", "stC200", 2.0*pw, 1.0e-3, zero, zero, 0.0, 0.0);
            delay(tau2 - 0.5e-3);
            delay(gt1 + 2.0e-4);}
	else
           {delay(tau2);
            rgpulse(2.0*pw, zero, 0.0, 0.0);
            delay(gt1 + 2.0e-4 - 2.0*pw);
            delay(tau2);}

	dec2rgpulse(2.0*pwN, t9, 0.0, 0.0);

                if (mag_flg[A] == 'y')
                {
                   magradpulse(gzcal*gzlvl1, gt1);
                }
                else
                {
                   zgradpulse(gzlvl1, gt1);
                }
	dec2phase(t10);
	delay(2.0e-4 - 2.0*GRADIENT_DELAY);
}

/*  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  */

	sim3pulse(pw, 0.0, pwN, zero, zero, t10, 0.0, 0.0);

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

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

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

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

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

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

	zgradpulse(1.5*gzlvl5, gt5);
	delay(lambda - pwN - 0.5*pw - gt5);

	rgpulse(pw, zero, 0.0, 0.0);

	delay((gt1/10.0) + 1.0e-4 - 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);
                }
        rcvron();
	statusdelay(C,1.0e-4-rof1);		

	setreceiver(t11);
}		 
Beispiel #23
0
pulsesequence()
{
  void      makeHHdec(), makeCdec(); 	                  /* utility functions */
  int       ihh=1,        /* used in HH decouling to improve water suppression */
            t1_counter;
  char	    C13refoc[MAXSTR],		/* C13 sech/tanh pulse in middle of t1 */
	    Hdecflg[MAXSTR],                        /* HH-h**o decoupling flag */
	    Cdecflg[MAXSTR],                 /* low power C-13 decoupling flag */
	    IPAP[MAXSTR],		       /* Flag for anti-phase spectrum */
            wtg3919[MAXSTR];
  double    tauxh, tau1,
            pwNt = 0.0,               /* pulse only active in the TROSY option */
            gsign = 1.0,
            maxHpwr = 51.0,            /* maximum allowed H-H decoupling power */
            maxCpwr = 45.0,            /* maximum allowed C-H decoupling power */
            gzlvl0=getval("gzlvl0"),
            gzlvl1=getval("gzlvl1"),
            gzlvl2=getval("gzlvl2"),
            gzlvl3=getval("gzlvl3"),
            gt0=getval("gt0"),
            gt1=getval("gt1"),
            gt2=getval("gt2"),
            gt3=getval("gt3"),
            JNH = getval("JNH"),
            pwN = getval("pwN"),
            pwNlvl = getval("pwNlvl"),  
            pwHs, tpwrs=0.0, compH,      /* H1 90 degree pulse length at tpwrs */               
            sw1 = getval("sw1"),
            pwClvl = getval("pwClvl"), 	         /* coarse power for C13 pulse */
            pwC = getval("pwC"),       /* C13 90 degree pulse length at pwClvl */
            rfst = 4095.0,	            /* fine power for the stCall pulse */
            compC = getval("compC");   /* adjustment for C13 amplifier compr-n */


/* INITIALIZE VARIABLES */

    getstr("C13refoc",C13refoc);
    getstr("IPAP",IPAP);	       /* IPAP = 'y' for AP; IPAP = 'n' for IP */
    getstr("wtg3919",wtg3919);
    getstr("Hdecflg", Hdecflg);
    getstr("Cdecflg", Cdecflg);
    
    tauxh = ((JNH != 0.0) ? 1/(4*(JNH)) : 2.25e-3);

    if (C13refoc[A]=='y')  /* 180 degree adiabatic C13 pulse from 0 to 200 ppm */
    {
      rfst = (compC*4095.0*pwC*4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35));   
      rfst = (int) (rfst + 0.5);
      if ( 1.0/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35)) < pwC )
      { 
        text_error( " Not enough C13 RF. pwC must be %f usec or less.\n", 
	          (1.0e6/(4000.0*sqrt((30.0*sfrq/600.0+7.0)/0.35))) );    
	psg_abort(1); 
      }
    }

    if(wtg3919[0] != 'y')      /* selective H20 one-lobe sinc pulse needs 1.69  */
    { pwHs = getval("pwHs");            /* times more power than a square pulse */
      compH = getval("compH");
      if (pwHs > 1e-6) tpwrs = tpwr - 20.0*log10(pwHs/(compH*pw*1.69));  
      else tpwrs = 0.0;
      tpwrs = (int) (tpwrs); }
    else
      pwHs = pw*2.385+7.0*rof1+d3*2.5;                       	  

    if(Cdecflg[0] == 'y') makeCdec(maxCpwr);     /* make shapes for HH h**o-decoupling */
    if(Hdecflg[0] == 'y') makeHHdec(maxHpwr);
    if(Hdecflg[0] != 'n') ihh = -3;

/* check validity of parameter range */

    if((dm[A] == 'y' || dm[B] == 'y' || dm[C] == 'y' ))
    { text_error("incorrect Dec1 decoupler flags!  "); psg_abort(1); } 

    if((dm2[A] == 'y' || dm2[B] == 'y') )
    { text_error("incorrect Dec2 decoupler flags!  "); psg_abort(1); } 

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

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

/* LOAD VARIABLES */

    if(ix == 1) d2_init = d2;
    t1_counter = (int) ( (d2-d2_init)*sw1 + 0.5);
    
    tau1 = d2/2.0;
    if(tau1 < 0.0) tau1 = 0.0;

/* LOAD PHASE TABLES */

    settable(t1, 2, phi1);
    if (IPAP[A]=='y') settable(t2,4,phi2A);
    else settable(t2, 4, phi2); 
    settable(t3, 16, phi3);
    settable(t4, 16, phi4);
    if (IPAP[A]=='y') settable(t5,8,recA);
    else settable(t5, 4, rec);

    assign(one,v7); 
    assign(three,v8);     

    if ( phase1 == 2 )         /* Hypercomplex in t1 */
    {
      if (IPAP[A] == 'y') 
        tsadd(t3,1,4); 
      tsadd(t2, 1, 4); 
    } 
                                   
    if(t1_counter %2)          /* calculate modification to phases based on */
    { 			       /* current t1 values */
      tsadd(t2,2,4); 
      tsadd(t5,2,4); 
      if (IPAP[A] == 'y') 
        tsadd(t3,2,4); 
    }

    if(wtg3919[0] != 'y') 
    { add(one,v7,v7); add(one,v8,v8); }
         
                           /* sequence starts!! */
   status(A);
     
     obspower(tpwr);
     dec2power(pwNlvl);
     decpower(pwClvl);
     decpwrf(rfst);
     if(Hdecflg[0] != 'n')
     {
       delay(5.0e-5);
       rgpulse(pw,zero,rof1,0.0);                 
       rgpulse(pw,one,0.0,rof1);                 
       zgradpulse(1.5*gzlvl0, 0.5e-3);
       delay(5.0e-4);
       rgpulse(pw,zero,rof1,0.0);                 
       rgpulse(pw,one,0.0,rof1);                 
       zgradpulse(-gzlvl0, 0.5e-3);
     }
     
     delay(d1);
     rcvroff();
     
   status(B);

     dec2rgpulse(pwN,zero,rof1,rof1);
     zgradpulse(gzlvl0,gt0);
     delay(1e-3); 
     
     rgpulse(pw, zero, rof1, rof1);
     
     zgradpulse(gzlvl1,gt1);
     txphase(zero);
     dec2phase(zero);
     delay(tauxh-gt1);               /* delay=1/4J(XH)   */

     sim3pulse(2*pw,0.0,2*pwN,zero,zero,zero,rof1,rof1);

     zgradpulse(gzlvl1,gt1);
     dec2phase(t2);
     delay(tauxh-gt1 );               /* delay=1/4J(XH)   */
  
     rgpulse(pw, t1, rof1, rof1);

     zgradpulse(0.5*gsign*ihh*gzlvl2,gt2);
     delay(200.0e-6); 
     decphase(zero);
            
     txphase(t4);      
     dec2rgpulse(pwN, t2, rof1, 0.0);

     if (IPAP[A] == 'y') 
     {
      delay(tauxh-pwN); 
      sim3pulse(2*pw,0.0,2*pwN,zero,zero,t3,rof1,rof1);
      delay(tauxh-pwN);
      rgpulse(pw,t4,rof1,rof1);
     }	
        
     if ( (C13refoc[A]=='y') && (tau1 > 0.5e-3 + WFG2_START_DELAY) )
     {
       delay(tau1 - 0.5e-3 - WFG2_START_DELAY); 
       simshaped_pulse("", "stC200", 0.0, 1.0e-3, zero, zero, 0.0, 0.0);  
       dec2phase(zero);  
       delay(tau1 - 0.5e-3 - WFG2_STOP_DELAY);
     }
     else 
       delay(2.0*tau1);
       
     dec2rgpulse(pwN, zero, 0.0, 0.0);
       
     zgradpulse(0.5*gzlvl2,gt2);
     delay(200.0e-6);
     rgpulse(pw, zero, rof1, rof1); 
     
     zgradpulse(gzlvl3,gt3);
     txphase(v7); dec2phase(zero);
     delay(tauxh-gt3-pwHs-rof1+5.0e-5);
     
     if(wtg3919[0] == 'y')
     {     	
       rgpulse(pw*0.231,v7,rof1,rof1);     
       delay(d3);
       rgpulse(pw*0.692,v7,rof1,rof1);
       delay(d3);
       rgpulse(pw*1.462,v7,rof1,rof1);

       delay(d3/2-pwN);
       dec2rgpulse(2*pwN, zero, rof1, rof1);
       txphase(v8);
       delay(d3/2-pwN);

       rgpulse(pw*1.462,v8,rof1,rof1);
       delay(d3);
       rgpulse(pw*0.692,v8,rof1,rof1);
       delay(d3);
       rgpulse(pw*0.231,v8,rof1,rof1); 
     }
     else
     {
       obspower(tpwrs);  
       shaped_pulse("H2Osinc", pwHs, v7, rof1, 0.0);
       obspower(tpwr);
       sim3pulse(2.0*pw, 0.0, 2.0*pwN, v8, zero, zero, 0.0, 0.0);
       obspower(tpwrs);
       shaped_pulse("H2Osinc", pwHs, v7, rof1, 0.0);
       obspower(tpwr);
     } 
        
     zgradpulse(gzlvl3,gt3);   

     if(Cdecflg[0] == 'y')
     {
       delay(tauxh-gt3-pwHs-rof1-pwNt-3.0*POWER_DELAY-PRG_START_DELAY); 
       dec2rgpulse(pwNt, zero, rof1, rof2); 
       dec2power(dpwr2);
       rcvron();

     statusdelay(C,5.0e-5);
       setreceiver(t5);  
       pbox_decon(&Cdseq);
      
       if(Hdecflg[0] == 'y')
         homodec(&HHdseq); 
     }
     else
     {
       delay(tauxh-gt3-pwHs-rof1-pwNt-POWER_DELAY); 
       dec2rgpulse(pwNt, zero, rof1, rof2); 
       dec2power(dpwr2);
       rcvron();

     statusdelay(C,5.0e-5);
       setreceiver(t5);  
      
       if(Hdecflg[0] == 'y')
         homodec(&HHdseq); 
     }       
}
Beispiel #24
0
pulsesequence()
{
   char   
          shname1[MAXSTR],
	  f1180[MAXSTR],
	  f2180[MAXSTR],
          SE_flg[MAXSTR],
          href_flg[MAXSTR];     /*gradient flag */

   int    icosel=1,
          t1_counter,
          t2_counter,
          ni2 = getval("ni2"),
          phase;


   double d2_init=0.0,
          d3_init=0.0,
          pwS1,pwS2,pwS3,pwS4,pwS5,pwS6,
          lambda = getval("lambda"),
          gzlvl1 = getval("gzlvl1"),
          gzlvl2 = getval("gzlvl2"), 
          gzlvl3 = getval("gzlvl3"), 
          gzlvl4 = getval("gzlvl4"), 
          gzlvl5 = getval("gzlvl5"), 
          gzlvl6 = getval("gzlvl6"), 
          gt1 = getval("gt1"),
          gt3 = getval("gt3"),
          gt4 = getval("gt4"),
          gt5 = getval("gt5"),
          gt6 = getval("gt6"),
          gstab = getval("gstab"),
          tpwrsf = getval("tpwrsf"),
          shlvl1,
          shpw1,
          pwClvl = getval("pwClvl"),
          pwNlvl = getval("pwNlvl"),
          pwN = getval("pwN"),
          dpwr2 = getval("dpwr2"),
          d2 = getval("d2"),
          shbw = getval("shbw"),
          shofs = getval("shofs")-4.77,
          timeTN = getval("timeTN"),
          tau1 = getval("tau1"),
          tau2 = getval("tau2"),
          taunh = getval("taunh");

   getstr("shname1", shname1);
   getstr("SE_flg",SE_flg);
   getstr("f1180",f1180);
   getstr("f2180",f2180);
   getstr("href_flg",href_flg);



  phase = (int) (getval("phase") + 0.5);
   
   settable(t1,4,phi1);
   settable(t3,4,phi3);
   settable(t5,4,phi5);
   settable(t10,1,phi10);
   settable(t12,4,phi12);
   settable(t13,4,phi13);

/*   INITIALIZE VARIABLES   */

   shpw1 = pw*8.0;
   shlvl1 = tpwr;


   pwS1 = c13pulsepw("co", "ca", "sinc", 90.0);
   pwS2 = c13pulsepw("co", "ca", "sinc", 180.0);
   pwS3 = c13pulsepw("ca", "co", "square", 180.0);
   pwS4 = h_shapedpw("eburp2",shbw,shofs,zero, 0.0, 0.0);  
   pwS6 = h_shapedpw("reburp",shbw,shofs,zero, 0.0, 0.0);
   pwS5 = h_shapedpw("pc9f",shbw,shofs,zero, 2.0e-6, 0.0);


if (SE_flg[0] == 'y')
{
   if ( ni2*1/(sw2)/2.0 > (timeTN-pwS2*0.5-pwS4))
       { printf(" ni2 is too big. Make ni2 equal to %d or less.\n",
         ((int)((timeTN-pwS2*0.5-pwS4)*2.0*sw2)));    psg_abort(1);}
}
else
{
   if ( ni2*1/(sw2)/2.0 > (timeTN-pwS2*0.5))
       { printf(" ni2 is too big. Make ni2 equal to %d or less.\n",
         ((int)((timeTN-pwS2*0.5)*2.0*sw2)));    psg_abort(1);}
}



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

if (SE_flg[0] =='y')
{
  if (phase2 == 2)  {tsadd(t10,2,4); icosel = +1;}
            else                               icosel = -1;
}
else
{
  if (phase2 == 2) {tsadd(t3,1,4);tsadd(t5,1,4);}
}
 

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

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

  
    


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

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



   status(A);
      rcvroff();  

   decpower(pwClvl);
   decoffset(dof);
   dec2power(pwNlvl);
   dec2offset(dof2);
   obspwrf(tpwrsf);
   decpwrf(4095.0);
   obsoffset(tof);
   set_c13offset("co");


     zgradpulse(gzlvl6, gt6);
       delay(1.0e-4);

       delay(d1-g6);
lk_hold();

        h_shapedpulse("pc9f",shbw,shofs,zero, 2.0e-6, 0.0);  

	delay(lambda-pwS5*0.5-pwS6*0.4); 

   	h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, one, zero, zero, 0.0, 0.0);

	delay(lambda-pwS5*0.5-pwS6*0.4);

        h_shapedpulse("pc9f_",shbw,shofs,one, 0.0, 0.0);  


   obspower(shlvl1);
/**************************************************************************/
      dec2rgpulse(pwN,zero,0.0,0.0);

           zgradpulse(gzlvl4, gt3);
           delay(timeTN-pwS2*0.5-gt3);

      sim3_c13pulse("", "co", "ca", "sinc", "", 0.0, 180.0, 2.0*pwN,
                                             zero, zero, zero, 2.0e-6, 2.0e-6);

        if (href_flg[0] == 'y') 
        {
           delay(timeTN-pwS2*0.5-taunh*0.5-shpw1);
           shaped_pulse(shname1,shpw1,two,0.0,0.0);
           zgradpulse(gzlvl4, gt3);
           delay(taunh*0.5-gt3);
     dec2rgpulse(pwN,zero,0.0,0.0);				     
        }
        else
        {
           delay(timeTN-pwS2*0.5-taunh*0.5);
           zgradpulse(gzlvl4, gt3);
           delay(taunh*0.5-gt3);
     dec2rgpulse(pwN,one,0.0,0.0);				     
        }
/**************************************************************************/
/*   xxxxxxxxxxxxxxxxxxxxxx       13CO EVOLUTION        xxxxxxxxxxxxxxxxxx    */
/**************************************************************************/
   
	c13pulse("co", "ca", "sinc", 90.0, t1, 2.0e-6, 0.0);       
        delay(tau1*0.5);
        sim3shaped_pulse(shname1,"","",shpw1,0.0,pwN*2.0,zero,zero,zero,2.0e-6,0.0);
        delay(tau1*0.5);
	c13pulse("co", "ca", "sinc", 180.0, zero, 0.0, 0.0);      
        dec2rgpulse(pwN*2.0,zero,0.0,0.0);				     
        if (pwN*2.0 <shpw1) delay(shpw1-pwN*2.0);
	c13pulse("co", "ca", "sinc", 90.0, zero, 0.0, 0.0);       

/**************************************************************************/

   obspower(shlvl1);
        if (href_flg[0] == 'y') 
         {
          shaped_pulse(shname1,shpw1,two,0.0,0.0);
     dec2rgpulse(pwN,t3,0.0,0.0);
         }
        else 
     dec2rgpulse(pwN,t5,0.0,0.0);

      if (SE_flg[0] == 'y')
      {
        if (href_flg[0] == 'y')
        {
           delay(tau2*0.5);
	c13pulse("ca", "co", "square", 180.0, zero, 0.0, 0.0);       
          delay(taunh*0.5-pwS3);
        shaped_pulse(shname1,shpw1,two,0.0,0.0);
        delay(timeTN-pwS2*0.5-shpw1-taunh*0.5-gt1-1.0e-4);
        }
        else
        {
           delay(tau2*0.5);
        sim_c13pulse(shname1,"ca", "co", "square",shpw1, 180.0, two,zero, 0.0, 0.0);
          if (shpw1 >= pwS3) delay(taunh*0.5-shpw1);
          else  delay(taunh*0.5-pwS3);
        delay(timeTN-pwS2*0.5-taunh*0.5-gt1-1.0e-4);
        }
 
        zgradpulse(-gzlvl1, gt1);
        delay(1.0e-4);

      sim3_c13pulse("", "co", "ca", "sinc", "", 0.0, 180.0, 2.0*pwN,
                                             zero, zero, zero, 2.0e-6, 2.0e-6);
           delay(timeTN-pwS2*0.5-tau2*0.5-pwS4);
        h_shapedpulse("eburp2",shbw,shofs,zero, 2.0e-6, 0.0); 
	dec2rgpulse(pwN, t10, 0.0, 0.0);
      }
      else
      {
        if (href_flg[0] == 'y')
        {
           delay(tau2*0.5);
	c13pulse("ca", "co", "square", 180.0, zero, 0.0, 0.0);       
          delay(taunh*0.5-pwS3);
        shaped_pulse(shname1,shpw1,two,0.0,0.0);
        delay(timeTN-pwS2*0.5-shpw1-taunh*0.5);
        }
        else
        {
           delay(tau2*0.5);
        sim_c13pulse(shname1,"ca", "co", "square",shpw1, 180.0, two,zero, 0.0, 0.0);
         if (shpw1 >= pwS3)   delay(taunh*0.5-shpw1);
         else  delay(taunh*0.5-pwS3);
        delay(timeTN-pwS2*0.5-taunh*0.5);
        }

      sim3_c13pulse("", "co", "ca", "sinc", "", 0.0, 180.0, 2.0*pwN,
                                             zero, zero, zero, 2.0e-6, 2.0e-6);
       delay(timeTN-pwS2*0.5-tau2*0.5);
       dec2rgpulse(pwN, zero, 0.0, 0.0);
      }

/**************************************************************************/
if (SE_flg[0] == 'y')
{
	zgradpulse(gzlvl5, gt5);
	delay(lambda-pwS6*0.4  - gt5);

   	h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

	zgradpulse(gzlvl5, gt5);
	delay(lambda-pwS6*0.4  - gt5);

	dec2rgpulse(pwN, one, 0.0, 0.0);
  
        h_shapedpulse("eburp2_",shbw,shofs,one, 0.0, 0.0); 
 

	txphase(zero);
	dec2phase(zero);
	delay(lambda-pwS4*0.5-pwS6*0.4);

   	h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

	dec2phase(t10);
	delay(lambda-pwS4*0.5-pwS6*0.4);

 
        h_shapedpulse("eburp2",shbw,shofs,zero, 0.0, 0.0); 


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

        h_shapedpulse("reburp",shbw,shofs,zero, 0.0, rof2); 
        zgradpulse(icosel*gzlvl2, gt1/10.0);            /* 2.0*GRADIENT_DELAY */
        delay(gstab);
}
else
{
        h_shapedpulse("eburp2",shbw,shofs,zero, 2.0e-6, 0.0);
        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.4  - gt5);

        h_sim3shapedpulse("reburp",shbw,shofs,0.0,2.0*pwN, zero, zero, zero, 0.0, 0.0);

        zgradpulse(gzlvl5, gt5);
        delay(lambda-pwS6*0.4  - gt5-POWER_DELAY-1.0e-4);
}

	dec2power(dpwr2);				       /* POWER_DELAY */
lk_sample();
if (SE_flg[0] == 'y')
	setreceiver(t13);
else
	setreceiver(t12);
      rcvron();  
statusdelay(C,1.0e-4 );

}		 
Beispiel #25
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,  		        /* used for states tppi in t1 */
            t2_counter,  	 	        /* used for states tppi in t2 */
            PRexp,                          /* projection-reconstruction flag */
	    ni = getval("ni"),
	    ni2 = getval("ni2");

double      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
	    tauCH = getval("tauCH"), 		         /* 1/4J delay for CH */
	    zeta = getval("zeta"),   /* zeta delay, 0.006 for 1D, 0.011 for 2D*/
            timeTN = getval("timeTN"),     /* constant time for 15N evolution */
	    timeCH = 1.1e-3,				      /* other delays */
	    timeAB = 3.3e-3,
	    kappa = 5.4e-3,
	    lambda = 2.4e-3,
            csa, sna,
            pra = M_PI*getval("pra")/180.0,
        bw, ofs, ppm,                            /* temporary Pbox parameters */            
	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 */

/* the following pulse lengths for SLP pulses are automatically calculated    */
/* by the macro "biocal".  SLP pulse shapes, "offC7" etc are called       */
/* directly from your shapelib.                    			      */
   pwC7,                     /* 180 degree selective sinc pulse on CO(174ppm) */
   rf7,	                           /* fine power for the pwC7 ("offC7") pulse */

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

   	pwH,	    		        /* H1 90 degree pulse length at tpwr1 */
   	tpwr1,	  	                     /* 9.2 kHz rf magnet for DIPSI-2 */
   	DIPSI2time,     	        /* total length of DIPSI-2 decoupling */
        ncyc_dec,
        waltzB1=getval("waltzB1"),

	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);
 
    csa = cos(pra);
    sna = sin(pra);


/*   LOAD PHASE TABLE    */

	settable(t3,1,phx);
	settable(t4,1,phx);
   if (TROSY[A]=='y')
       {settable(t8,2,phi8T);
	settable(t9,1,phx);
 	settable(t10,1,phy);
	settable(t11,1,phx);
	settable(t12,2,recT);}
    else
       {settable(t8,2,phi8);
	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); }
 
    /* set zeta to 6ms for 1D spectral check, otherwise it will be the    */
    /* value in the dg2 parameter set (about 11ms) for 2D/13C and 3D work */
        if (ni>1)  zeta = zeta;
	else  zeta = 0.006;
	
    /* maximum fine power for pwC pulses */
	rf0 = 4095.0;

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

      if (autocal[0] == 'n') 
      {
    /* 90 degree pulse on Cab, null at CO 128ppm away */
	pwC1 = sqrt(15.0)/(4.0*128.0*dfrq);
        rf1 = 4095.0*(compC*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 > 4295 )
       { printf("increase pwClvl"); psg_abort(1);}
	if(( rf2 < 4296 ) && (rf2>4095)) rf2=4095;
	
    /* 180 degree one-lobe sinc pulse on CO, null at Ca 118m away */
        pwC7 = getval("pwC7");
	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 */
	}
      else        /* if autocal = 'y'(yes), 'q'(quiet), r(read), or 's'(semi) */
      {  
        if(FIRST_FID)                                            /* call Pbox */
        {          
          ppm = getval("dfrq"); 
          bw = 128.0*ppm; ofs = bw;           
          offC1 = pbox_Rcal("square90n", bw, compC*pwC, pwClvl);
          offC2 = pbox_Rcal("square180n", bw, compC*pwC, pwClvl); 
          bw = 118.0*ppm; 
          offC7 = pbox_make("offC7", "sinc180n", bw, ofs, compC*pwC, pwClvl);
          if (dm3[B] == 'y') H2ofs = 3.2;     
          ofs_check(H1ofs, C13ofs, N15ofs, H2ofs); 
        }
        pwC1 = offC1.pw; rf1 = offC1.pwrf;
        pwC2 = offC2.pw; rf2 = offC2.pwrf;
        pwC7 = offC7.pw; rf7 = offC7.pwrf;  

   /* Example of semi-automatic calibration - use parameters, if they exist : 

        if ((autocal[0] == 's') || (autocal[1] == 's'))       
        { 
          if (find("pwC1") > 0) pwC1 = getval("pwC1");
          if (find("rf1") > 0) rf1 = getval("rf1");
        }
   */
      }	
	
    /* power level and pulse times for DIPSI 1H decoupling */
	DIPSI2time = 2.0*zeta + 2.0*timeTN - 5.4e-3 + pwC1 + 5.0*pwN + gt3 + 5.0e-5 + 2.0*GRADIENT_DELAY + 3.0*POWER_DELAY;
        pwH=1.0/(4.0*waltzB1);

	ncyc_dec = (DIPSI2time*90.0)/(pwH*2590.0*4.0);
        ncyc_dec = (int) (ncyc_dec +0.5);

	pwH = (DIPSI2time*90.0)/(ncyc_dec*2590.0*4.0);   /* adjust pwH  */
	tpwr1 = 4095.0*(compH*pw/pwH);
	tpwr1 = (int) (2.0*tpwr1 + 0.5);  /* x2 because obs atten will be reduced by 6dB  */
 
/* CHECK VALIDITY OF PARAMETER RANGES */

    if ( 0.5*ni*1/(sw1) > timeAB - gt4 - WFG_START_DELAY - pwC7 )
       { printf(" ni is too big. Make ni equal to %d or less.\n",
         ((int)((timeAB - gt4 - WFG_START_DELAY - pwC7)*2.0*sw1))); psg_abort(1);}
    PRexp = 0;
    if((pra > 0.0) && (pra < 90.0)) PRexp = 1;

    if (PRexp) 
    {
      if( 0.5*ni*sna/sw1 > timeTN - WFG3_START_DELAY)
        { printf(" ni is too big. Make ni equal to %d or less.\n",
        ((int)((timeTN - WFG3_START_DELAY)*2.0*sw1/sna))); psg_abort(1);}
    }
    else 
    {
      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;    
	 }


/*  Set up f1180  */
   
    
    if(PRexp)                /* set up Projection-Reconstruction experiment */
      tau1 = d2*csa;
    else
      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  */

    if(PRexp)
      tau2 = d2*sna;
    else
    {
      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 ACTUAL PULSE SEQUENCE */

status(A);
   	delay(d1);
        if ( dm3[B] == 'y' )
          { lk_hold(); lk_sampling_off();}  /*freezes z0 correction, stops lock pulsing*/

	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 */

   	decphase(zero);
	zgradpulse(gzlvl0, gt0);
	delay(tauCH - gt0);

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

   	txphase(one);
	decphase(t3);
	zgradpulse(gzlvl0, gt0);
	delay(tauCH - gt0);

   	rgpulse(pw, one, 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 a */	
	txphase(zero);
	decphase(zero);
        decpwrf(rf7);
     	delay(tau1);

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

	zgradpulse(gzlvl4, gt4);
        decpwrf(rf2);	
        if ( pwC7 > 2.0*pwN)
     	   {delay(timeCH - pwC7 - gt4 - WFG3_START_DELAY - 2.0*pw);}
        else
     	   {delay(timeCH - 2.0*pwN - gt4 - WFG3_START_DELAY - 2.0*pw);}

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

     	delay(timeAB - timeCH);

     	decrgpulse(pwC2, zero, 0.0, 0.0);

	zgradpulse(gzlvl4, gt4);
        decpwrf(rf7);
     	delay(timeAB - tau1 - gt4 - WFG_START_DELAY - pwC7 - 2.0e-6);

 							/*  WFG_START_DELAY   */
     	decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0);
                                                              
	decpwrf(rf1);					       	/* point b */
   	decrgpulse(pwC1, zero, 2.0e-6, 0.0);                   		
	obspwrf(tpwr1); obspower(tpwr-6);				       /* POWER_DELAY */
	obsprgon("dipsi2", pwH, 5.0);		           /* PRG_START_DELAY */
	xmtron();
								/* point c */
	dec2phase(zero);
	decpwrf(rf2);
	delay(zeta - POWER_DELAY - PRG_START_DELAY);

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

	decpwrf(rf1);
	dec2phase(t8);
	delay(zeta);
								/* point d */
	decrgpulse(pwC1, zero, 0.0, 0.0);                        
        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 */
           }

/*  xxxxxxxxxxxxxxxxxx    OPTIONS FOR N15 EVOLUTION    xxxxxxxxxxxxxxxxxxxxx  */

	zgradpulse(gzlvl3, gt3);
        if (TROSY[A]=='y') { xmtroff(); obsprgoff(); }
 	delay(2.0e-4);
	dec2rgpulse(pwN, t8, 0.0, 0.0);
								/* point e */

	decpwrf(rf2);
	decphase(zero);
	dec2phase(t9);
	delay(timeTN - WFG3_START_DELAY - tau2);
							 /* WFG3_START_DELAY  */
	sim3pulse(0.0, pwC2, 2.0*pwN, zero, zero, t9, 0.0, 0.0);

	dec2phase(t10);
        decpwrf(rf7);

if (TROSY[A]=='y')
{
    if (tau2 > gt1 + 2.0*GRADIENT_DELAY + 1.0e-4)
	{
	  txphase(t4);
          delay(timeTN - pwC7 - WFG_START_DELAY);          /* WFG_START_DELAY */
          decshaped_pulse("offC7", pwC7, 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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_DELAY);
	}
    else
	{
	  txphase(t4);
          delay(timeTN -pwC7 -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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_DELAY);                    /* WFG_START_DELAY */
          decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0);
          delay(tau2);
	}
}
else
{
    if (tau2 > kappa)
	{
          delay(timeTN - pwC7 - WFG_START_DELAY);     	   /* WFG_START_DELAY */
          decshaped_pulse("offC7", pwC7, 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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_DELAY);
	}
    else if (tau2 > (kappa - pwC7 - WFG_START_DELAY))
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY);
          xmtroff();
          obsprgoff();					    /* PRG_STOP_DELAY */
	  txphase(t4);                                     /* WFG_START_DELAY */
          decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0);
          delay(kappa -pwC7 -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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_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 - pwC7 - WFG_START_DELAY);    /* WFG_START_DELAY */
          decshaped_pulse("offC7", pwC7, 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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_DELAY);
	}
    else
	{
          delay(timeTN + tau2 - kappa - PRG_STOP_DELAY);
          xmtroff();
	  obsprgoff();					    /* PRG_STOP_DELAY */
	  txphase(t4);
    	  delay(kappa-tau2-pwC7-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 */
	  obspwrf(4095.0); obspower(tpwr);				       /* POWER_DELAY */
	  delay(1.0e-4 - 2.0*POWER_DELAY);                    /* WFG_START_DELAY */
          decshaped_pulse("offC7", pwC7, zero, 0.0, 0.0);
          delay(tau2);
	}
}                                                            	/* point f */
/*  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);
}		 
Beispiel #26
0
static void WET(codeint phaseA, codeint phaseB)
{
  double finepwr,gzlvlw,gtw,gswet,dmfwet,dpwrwet,dofwet,wetpwr,pwwet,dz,
  ref_pw90 = getval("ref_pw90"),
         ref_pwr = getval("ref_pwr"),
        slp0bw = getval("slp0bw"),
        slpbw = getval("slpbw"),
        slp2bw = getval("slp2bw"),
        slp3bw = getval("slp3bw"),
        slp4bw = getval("slp4bw"),
        slp5bw = getval("slp5bw"),
        slp6bw = getval("slp6bw"),
        slp0,slp,slp2,
        slp3,slp4,slp5,slp6;
  int   slp0w,slpw,slp2w,slp3w,slp4w,slp5w,slp6w,c13wet;
  char  wetshape[MAXSTR];

  c13wet=getflag("c13wet");        /* C13 satellite suppression flag    */
  getstr("wetshape",wetshape);     /* Selective pulse shape (basename)  */
  wetpwr=getval("wetpwr");         /* User enters power for 90 deg.     */
  pwwet=getval("pwwet");           /* User enters power for 90 deg.     */
  dmfwet=getval("dmfwet");         /* dmf for the C13 decoupling        */
  dpwrwet=getval("dpwrwet");       /* Power fot the C13 decoupling      */
  dofwet=getval("dofwet");         /* Offset for the C13 decoupling     */
  dz=getval("dz");                 /* Post WET delay                    */
  slp0w=getflag("slp0w");          /* Flags whether user is requesting  */
  slpw=getflag("slpw");            /* WET suppression on each solvent   */
  slp2w=getflag("slp2w");          /* signal                            */
  slp3w=getflag("slp3w");
  slp4w=getflag("slp4w");
  slp5w=getflag("slp5w");
  slp6w=getflag("slp6w");

/*      On-the fly calculation of the WET shapes.
        d.a. March 2001
        First check if any of the WET related parameters are arrayed,
        in order to avoid extra pulse shaping  */

   if ((getval("arraydim") < 1.5) || (ix==1) || (isarry("ref_pwr")) || (isarry("ref_pw90")) || (isarry("tof")) || (isarry("slp0bw")) || (isarry("slp")) || (isarry("slpbw")) || (isarry("slp2bw")) || (isarry("slp3bw")) || (isarry("slp4bw")) || (isarry("slp5bw")) || (isarry("slp6bw")) || (isarry("slp0")) || (isarry("slp2")) || (isarry("slp3")) || (isarry("slp4")) || (isarry("slp5")) || (isarry("slp6")) || (isarry("slp0w")) || (isarry("slpw")) || (isarry("slp2w")) || (isarry("slp3w")) || (isarry("slp4w")) || (isarry("slp5w")) || (isarry("slp6w")))
{

/*      Set the name of the shape file to wetshape if not arrayed,
        for compatibility reasons with the other sequences of the LC
        and VAST package.
        If something is arrayed then the first elements named with
        wetshape and all subsequent with wetshape_n, where n is
        the array index    */

  if (ix==1)
  sprintf(wetarr, "%s", wetshape);
  else
  sprintf(wetarr, "%s_%d", wetshape, ix);

/* Open Pbox and start pulse shape calculation   */

  opx(wetarr);

/*      Explicitly check whether each one of the seven solvent lines
        is chosen to be suppressed. If the slpN parameter is set to
        'n' or the slpNw flag is set to 'n' then no wave is put into Pbox. 
        Otherwise the proper line with the SEDUCE shape is addded.
        var_active information can be found in /vnmr/psg/active.c    */

  if ((var_active("slp0",1)) && (slp0w))
        { slp0 = getval("slp0");
          putwave("seduce",slp0bw/2,slp0,0.0,0.0,90.0); }
  if ((var_active("slp",1)) && (slpw))
        { slp = getval("slp");
          putwave("seduce",slpbw/2,slp,0.0,0.0,90.0); }
  if ((var_active("slp2",1)) && (slp2w))
        { slp2 = getval("slp2");
          putwave("seduce",slp2bw/2,slp2,0.0,0.0,90.0); }
  if ((var_active("slp3",1)) && (slp3w))
        { slp3 = getval("slp3");
          putwave("seduce",slp3bw/2,slp3,0.0,0.0,90.0); }
  if ((var_active("slp4",1)) && (slp4w))
        { slp4 = getval("slp4");
          putwave("seduce",slp4bw/2,slp4,0.0,0.0,90.0); }
  if ((var_active("slp5",1)) && (slp5w))
        { slp5 = getval("slp5");
          putwave("seduce",slp5bw/2,slp5,0.0,0.0,90.0); }
  if ((var_active("slp6",1)) && (slp6w))
        { slp6 = getval("slp6");
          putwave("seduce",slp6bw/2,slp6,0.0,0.0,90.0); }

/*      Add additional control parameters, close Pbox and retrieve
        the shape parameters into the proper variables   */

  pbox_par("attn","i");
  pbox_par("reps","2");
  cpx(ref_pw90,ref_pwr);
  pbox_get();
  wetpwr = pbox_pwr;
  pwwet = pbox_pw;
}
else
{   /* Read the pbx.RF shape file and retrieve the wetpwr and pwwet values */
    dumshape=getRsh(wetshape);
    wetpwr = dumshape.pwr;
    pwwet = dumshape.pw;
}


finepwr=wetpwr-(int)wetpwr;  /* Adjust power to 152 deg. pulse */
  wetpwr=(double)((int)wetpwr);
  if (finepwr==0.0) {wetpwr=wetpwr+5; finepwr=4095.0; }
  else {wetpwr=wetpwr+6; finepwr=4095.0*(1-((1.0-finepwr)*0.12)); }
  rcvroff();
  if (c13wet)
    {
    decunblank(); decon();
    decoffset(dofwet);
    decpower(dpwrwet);
    if (rfwg[DECch-1]=='y')
         decprgon("garp1",1/dmfwet,1.0);
      else
         setstatus(DECch,FALSE,'g',FALSE,dmfwet);
    }
  obspower(wetpwr);         /* Set to low power level        */
  gzlvlw=getval("gzlvlw");      /* Z-Gradient level              */
  gtw=getval("gtw");            /* Z-Gradient duration           */
  gswet=getval("gswet");        /* Post-gradient stability delay */
  CHESS(finepwr*0.5056,wetarr,pwwet,phaseA,20.0e-6,rof2,gzlvlw,gtw,gswet,c13wet);
  CHESS(finepwr*0.6298,wetarr,pwwet,phaseB,20.0e-6,rof2,gzlvlw/2.0,gtw,gswet,c13wet);
  CHESS(finepwr*0.4304,wetarr,pwwet,phaseB,20.0e-6,rof2,gzlvlw/4.0,gtw,gswet,c13wet);
  CHESS(finepwr*1.00,wetarr,pwwet,phaseB,20.0e-6,rof2,gzlvlw/8.0,gtw,gswet,c13wet);
  if (c13wet)
    {
    if (rfwg[DECch-1]=='y')
         decprgoff();
      else
         setstatus(DECch,FALSE,'c',FALSE,dmf);
    decoffset(dof);
    decpower(dpwr);
    decoff(); decblank();
    }
  obspower(tpwr); obspwrf(tpwrf);    /* Reset to normal power level   */
  rcvron();
  delay(dz);
}
Beispiel #27
0
pulsesequence()
{

/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
            RELAY[MAXSTR],                         /* Insert HCCH-relay delay */
            ribose[MAXSTR],                         /* ribose CHn groups only */
            aromatic[MAXSTR],                     /* aromatic CHn groups only */
            rna_stCshape[MAXSTR],     /* calls sech/tanh pulses from shapelib */
            rna_stCdec[MAXSTR],        /* calls STUD+ waveforms from shapelib */
	    mag_flg[MAXSTR],             /* Flag to use magic-angle gradients */
	    H2O_flg[MAXSTR],
	    sspul[MAXSTR],
            SHAPE[MAXSTR],
	    STUD[MAXSTR];   /* apply automatically calculated STUD decoupling */
 
int         t1_counter,  		        /* used for states tppi in t1 */
            t2_counter,  	 	        /* used for states tppi in t2 */
            ni2 = getval("ni2");

double      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
            delta1,delta2,
               ni = getval("ni"),
            lambda = 0.94/(4*getval("JCH")),       /* 1/4J H1 evolution delay */
            tCH = 1/(6.0*getval("JCH")),          /* 1/4J C13 evolution delay */
            tCC = 1/(8*getval("JCC")),

        pwClvl = getval("pwClvl"),              /* coarse power for C13 pulse */
        pwC = getval("pwC"),          /* C13 90 degree pulse length at pwClvl */
   rfC,                           /* maximum fine power when using pwC pulses */
   compC = getval("compC"),       /* adjustment for C13 amplifier compression */
                               /* temporary Pbox parameters */
   bw, pws, ofs, ppm, nst,     /* bandwidth, pulsewidth, offset, ppm, # steps */

/* Sech/tanh inversion pulses automatically calculated by macro "rna_cal"     */
/* and string parameter rna_stCshape calls them from your shapelib.           */
   rfst = 0.0,          /* fine power for the rna_stCshape pulse, initialised */
   dofa,        /* dof shifted to 80 or 120ppm for ribose or aromatic spectra */

/* string parameter stCdec calls stud decoupling waveform from your shapelib.*/
   studlvl,	                         /* coarse power for STUD+ decoupling */
            stdmf = getval("dmf80"),     /* dmf for 80 ppm of STUD decoupling */
            rf80 = getval("rf80"),                /* rf in Hz for 80ppm STUD+ */

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

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

	gt3 = getval("gt3"),
	gt4 = getval("gt4"),
	gt5 = getval("gt5"),
	gt7 = getval("gt7"),
	gt8 = getval("gt8"),
	gt9 = getval("gt9"),
        gzcal = getval("gzcal"),
	grecov = getval("grecov"),
	gzlvl0 = getval("gzlvl0"),
	gzlvl3 = getval("gzlvl3"),
	gzlvl4 = getval("gzlvl4"),
	gzlvl5 = getval("gzlvl5"),

	gzlvl7 = getval("gzlvl7"),		/* triax option */
	gzlvl8 = getval("gzlvl8"),
	gzlvl9 = getval("gzlvl9");

    getstr("f1180",f1180);
    getstr("mag_flg",mag_flg);
    getstr("f2180",f2180);
    getstr("RELAY",RELAY);
    getstr("ribose",ribose);
    getstr("aromatic",aromatic);
    getstr("H2O_flg",H2O_flg);
    getstr("sspul",sspul);
    getstr("SHAPE",SHAPE);
    getstr("STUD",STUD);


/*   INITIALIZE VARIABLES   */

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

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

  if (autocal[0] == 'n') 
  {
      /* 50ppm sech/tanh inversion */
      rfst = (compC*4095.0*pwC*4000.0*sqrt((7.5*sfrq/600+3.85)/0.41));
      rfst = (int) (rfst + 0.5);
  }
  else        /* if autocal = 'y'(yes), 'q'(quiet), r(read), or 's'(semi) */
  {
    if(FIRST_FID)                                            /* call Pbox */
    {
      ppm = getval("dfrq"); 
      bw = 50.0*ppm; pws = 0.001; ofs = 0.0; nst = 500.0; 
      stC50 = pbox_makeA("rna_stC50", "sech", bw, pws, ofs, compC*pwC, pwClvl, nst);
      if (dm3[B] == 'y') H2ofs = 3.2;
      ofs_check(H1ofs, C13ofs, N15ofs, H2ofs);
    }
    rfst = stC50.pwrf; 
  }
        strcpy(rna_stCshape, "rna_stC50");
        strcpy(rna_stCdec, "wurst80");
        studlvl = pwClvl + 20.0*log10(compC*pwC*4.0*rf80);
        studlvl = (int) (studlvl + 0.5);

/*  RIBOSE spectrum only, centered on 80ppm. */
  if (ribose[A]=='y')
        dofa = dof - 30.0*dfrq;

/*  AROMATIC spectrum only, centered on 120ppm */
  else
        dofa = dof + 10*dfrq;


/* CHECK VALIDITY OF PARAMETER RANGES */

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

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

  if((dm[A] == 'y' || dm[B] == 'y' ))
	{ printf("incorrect Dec1 decoupler flags!  "); psg_abort(1);}

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

  if((dm3[A] == 'y' || dm3[C] == 'y' ))
	{printf("incorrect dec1 decoupler flags! Should be 'nyn' or 'nnn' ");
								psg_abort(1); }
  if ((dm3[B] == 'y'  &&   dpwr3 > 44 ))
	{ printf("Deuterium decoupling power too high ! "); psg_abort(1);}

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

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


/*  CHOICE OF PULSE SEQUENCE */

  if ( ((ribose[A]=='y') && (aromatic[A]=='y')) )
   { text_error("Choose  ONE  of  ribose='y'  OR  aromatic='y' ! ");
        psg_abort(1); }

  if ( ((aromatic[A]=='y') && (RELAY[A]=='y')) )
   { text_error("No RELAY with aromatic='y' ! ");
        psg_abort(1); }


/* LOAD VARIABLES */

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


/* INITIALIZE VARIABLES */

/* Phase incrementation for hypercomplex data */

   if ( phase1 == 2 )     /* Hypercomplex in t1 */
     tsadd(t1,1,4);

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

/* calculate modification to phases based on current t1 values
   to achieve 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);
   }

/* calculate modification to phases based on current t2 values
   to achieve States-TPPI acquisition */

   if(ix == 1) d3_init = d3;
   t2_counter = (int)((d3-d3_init)*sw2 + 0.5);
   if(t2_counter % 2)     
   {
       tsadd(t2,2,4);
       tsadd(t11,2,4);
   }
 
/* set up so that get (90, -180) phase corrects in F1 if f1180 flag is y */

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

/* set up so that get (90, -180) phase corrects in F2 if f2180 flag is y */

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

   if (ni > 1)
      delta1 = (double)(t1_counter*(lambda - gt5 - 0.2e-3))/((double)(ni-1));
   else delta1 = 0.0;
   if (ni2 > 1)
      delta2 = (double)(t2_counter*(tCC - 0.6e-3))/((double)(ni2-1));
   else delta2 = 0.0;

   initval(7.0, v1);
   obsstepsize (45.0);

/* BEGIN ACTUAL PULSE SEQUENCE */

status(A);
   obsoffset(tof);
   decoffset(dofa);
   dec2offset(dof2);
   obspower(tpwr-12);                   
   decpower(pwClvl);
   decpwrf(rfC);
   dec2power(pwNlvl);                  
   decphase(zero);
   dec2phase(zero);
   if (sspul[0] == 'y')
   {
      rgpulse(200*pw, one, 10.0e-6, 0.0e-6);
      rgpulse(200*pw, zero, 0.0e-6, 1.0e-6);
   }
   obspower(tpwr);                   
   xmtrphase(v1);
   txphase(t1);
   if (dm3[B] == 'y') lk_sample();
   delay(d1);
   if (dm3[B] == 'y') lk_hold();
   rcvroff();

       decrgpulse(pwC, zero, rof1, rof1);
       delay(rof1);
       zgradpulse(gzlvl0,0.5e-3); 
       delay(grecov);

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

status(B);
	rgpulse(pw, t1, 1.0e-4, rof1);
	xmtrphase(zero);
	txphase(zero);

	zgradpulse(gzlvl5,gt5); 

/*
        decpwrf(rfst);
        delay(lambda - gt5 - rof1 - SAPS_DELAY - GRADIENT_DELAY - POWER_DELAY -
                        WFG2_START_DELAY - 0.5e-3 + 70.0e-6 + tau1);

        decshaped_pulse(rna_stCshape, 1.0e-3, zero, 0.0, 0.0);

        delay(tau1 - delta1);

        rgpulse(2.0*pw, zero, 0.0, rof1);
        txphase(one);
        decpwrf(rfC);

        zgradpulse(gzlvl5,gt5);
        delay(lambda - delta1 - gt5 - rof1 - GRADIENT_DELAY - POWER_DELAY - 0.5e-3 + 70.0e-6);
*/


        delay(lambda - gt5 - rof1 - SAPS_DELAY - GRADIENT_DELAY + tau1);

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

        delay(tau1 - delta1);

        rgpulse(2.0*pw, zero, 0.0, rof1);
        txphase(one);

        zgradpulse(gzlvl5,gt5);
        delay(lambda - delta1 - gt5 - rof1 - GRADIENT_DELAY);

	rgpulse(pw, one, 0.0, rof1);
	decphase(t2);
	txphase(zero);

   if(mag_flg[A] == 'y')
      magradpulse(gzcal*gzlvl3,gt3); 
   else
      zgradpulse(gzlvl3,gt3); 

	delay(grecov);

	decrgpulse(pwC, t2, rof1, 0.0);
	decphase(zero);

	delay(tau2);
	
	dec2rgpulse(2.0*pwN,zero,0.0,0.0);

	delay(tCH - 2*pwN);

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

	delay(tCC - tCH + tau2 - delta2 - 2.0*pw);
	
	decrgpulse(2.0*pwC, t3, 0.0, 0.0);
	decphase(t4);

	delay(tCC - delta2);

	decrgpulse(pwC, t4, 0.0, rof1);
	txphase(zero);
	decphase(zero);

  if(RELAY[A] == 'y')
   {
        zgradpulse(gzlvl4, gt4);
        delay(tCC - gt4 - GRADIENT_DELAY - pwC);

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

        zgradpulse(gzlvl4, gt4);
        delay(tCC - gt4 - GRADIENT_DELAY - pwC);

        decrgpulse(pwC, zero, 0.0, 0.0);
   }

	zgradpulse(gzlvl4,gt4); 
   	delay(tCC - gt4);

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

   if (H2O_flg[A] == 'y')
   {
      delay(tCC - gt4 - grecov - POWER_DELAY);

      zgradpulse(gzlvl4,gt4); 

      txphase(one);
      decphase(one);
      delay(grecov);

      decrgpulse(pwC, one, 0.0, rof1);
      rgpulse(900*pw, one, 0.0, rof1);
      txphase(zero);

      rgpulse(500*pw, zero, rof1, rof1);
      decphase(one);

      if(mag_flg[A] == 'y')
         magradpulse(gzcal*gzlvl7,gt7);
      else
         zgradpulse(gzlvl7,gt7);
      delay(200.0e-6);

      simpulse(pw, pwC, zero, one, 0.0, rof1);
      decphase(zero);

      zgradpulse(gzlvl4,gt4); 
      delay(tCH - gt4);

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

      zgradpulse(gzlvl4,gt4); 
      delay(tCH - gt4);
   }
   else
   {
      delay(tCC - tCH - 2.0*pw - POWER_DELAY);
      rgpulse(2.0*pw, zero, 0.0, rof1);

      zgradpulse(gzlvl4,gt4); 
      delay(tCH - gt4 - rof1);
   }
   
	decrgpulse(pwC, zero, 0.0, rof1);
	txphase(zero);

   if(mag_flg[A] == 'y')
      magradpulse(gzcal*gzlvl8,gt8); 
   else
      zgradpulse(gzlvl8,gt8); 

	delay(grecov);

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

	rgpulse(pw, zero, 0.0, rof1);

  if (SHAPE[A] =='y')
   {
	decpwrf(rfst);

   if(mag_flg[A] == 'y')
      magradpulse(gzcal*gzlvl9,gt9);
   else
      zgradpulse(gzlvl9,gt9);

	delay(lambda - gt9 - GRADIENT_DELAY - POWER_DELAY - WFG2_START_DELAY - 0.5e-3 + 70.0e-6);

        simshaped_pulse("",rna_stCshape,2*pw, 1.0e-3, zero, zero, 0.0, rof1);
        decphase(zero);

   if(mag_flg[A] == 'y')
      magradpulse(gzcal*gzlvl9,gt9);
   else
      zgradpulse(gzlvl9,gt9);

	decpwrf(rfC);

if (STUD[A]=='y') decpower(studlvl); else decpower(dpwr);

	delay(lambda - gt9 -rof1 -0.5*pw - 2*POWER_DELAY - GRADIENT_DELAY - 0.5e-3 + 70.0e-6);
   }
  else
   {
   if(mag_flg[A] == 'y')
      magradpulse(gzcal*gzlvl9,gt9);
   else
      zgradpulse(gzlvl9,gt9);

        delay(lambda - gt9 - GRADIENT_DELAY);

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

   if(mag_flg[A] == 'y')
      magradpulse(gzcal*gzlvl9,gt9);
   else
      zgradpulse(gzlvl9,gt9);

if (STUD[A]=='y') decpower(studlvl); else decpower(dpwr);

        delay(lambda - gt9 -rof1 -0.5*pw - POWER_DELAY - GRADIENT_DELAY);
     } 

	rgpulse(pw, zero, rof1, rof2);
	rcvron();
if (dm3[B] == 'y') lk_sample();
	setreceiver(t11);

if ((STUD[A]=='y') && (dm[C] == 'y'))
	{
        decunblank();
        decon();
        decprgon(rna_stCdec,1/stdmf, 1.0);
        startacq(alfa);
        acquire(np, 1.0/sw);
        decprgoff();
        decoff();
        decblank();
        }
   else	
	 status(C);
setreceiver(t11);
}
Beispiel #28
0
pulsesequence()
{



/* DECLARE AND LOAD VARIABLES */

char        f1180[MAXSTR],   		      /* Flag to start t1 @ halfdwell */
            f2180[MAXSTR],    		      /* Flag to start t2 @ halfdwell */
	    ribose[MAXSTR],	 		    /* ribose CHn groups only */
	    AH2H8[MAXSTR],		         /* Adenine H2-H8 correlation */
	    H2Opurge[MAXSTR],
	    rna_stCdec[MAXSTR],	       /* calls STUD+ waveforms from shapelib */
	    STUD[MAXSTR];   /* apply automatically calculated STUD decoupling */
 
int         t1_counter,  		        /* used for states tppi in t1 */
            t2_counter;  	 	        /* used for states tppi in t2 */

double      tau1,         				         /*  t1 delay */
            tau2,        				         /*  t2 delay */
            stdmf = getval("dmf80"),     /* dmf for 80 ppm of STUD decoupling */
            rf80 = getval("rf80"),       	  /* rf in Hz for 80ppm STUD+ */
	    taua = getval("taua"),   /* time delays for CH coupling evolution */
	    taub = getval("taub"),
	    tauc = getval("tauc"),

/* string parameter rna_stCdec calls stud decoupling waveform from your shapelib.*/
   studlvl,	                         /* coarse power for STUD+ decoupling */

	pwClvl = getval("pwClvl"), 	        /* coarse power for C13 pulse */
        pwC = getval("pwC"),          /* C13 90 degree pulse length at pwClvl */
	rfC,            	  /* maximum fine power when using pwC pulses */
	dofa,	    /* dof shifted to 80 ppm for ribose and 145 ppm for AH2H8 */
	tofa,	    		    /* tof shifted to 7.5 ppm in t1 for AH2H8 */

/* p_d is used to calculate the isotropic mixing on the C-ribose region */
        p_d,                 	       /* 50 degree pulse for DIPSI-3 at rfdC */
        rfdC,               /* fine power for 7.5 kHz or 4.0 kHz rf at 500MHz */
	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 */

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

 grecov = getval("grecov"),   /* Gradient recovery delay, typically 150-200us */

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

    getstr("f1180",f1180);
    getstr("f2180",f2180);
    getstr("ribose",ribose);
    getstr("AH2H8",AH2H8);
    getstr("H2Opurge",H2Opurge);
    getstr("STUD",STUD);

/*   LOAD PHASE TABLE    */

	settable(t3,2,phi3);
	settable(t5,4,phi5);
	settable(t9,8,phi9);
	settable(t11,8,rec);


/*   INITIALIZE VARIABLES   */

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

  if (ribose[A] == 'y')
   {
/*  Center dof in RIBOSE region on 80ppm. */
	tofa = tof;
        dofa = dof - 30.0*dfrq;
		
/* dipsi-3 decoupling on C-ribose */	
 	p_d = (5.0)/(9.0*4.0*7000.0*(sfrq/800));  /* 35ppm DIPSI-3 */
     	rfdC = (compC*4095.0*pwC*5.0)/(p_d*9.0); 
	rfdC = (int) (rfdC + 0.5);
  	ncyc = (int) (ncyc + 0.5);
   }
  else
   {
/*  Center dof in adenine C2-C4-C6-C8-C5 region on 145 ppm. */
	tofa = tof + 2.5*sfrq;
        dofa = dof + 35.0*dfrq;

/* dipsi-3 decoupling on C-aromatic */
        p_d = (5.0)/(9.0*4.0*8000.0*(sfrq/800));  /* 40ppm DIPSI-3 */
        rfdC = (compC*4095.0*pwC*5.0)/(p_d*9.0);
        rfdC = (int) (rfdC + 0.5);
        ncyc = (int) (ncyc + 0.5);
   }

/* 80 ppm STUD+ decoupling */
        strcpy(rna_stCdec, "wurst80");
        studlvl = pwClvl + 20.0*log10(compC*pwC*4.0*rf80);
        studlvl = (int) (studlvl + 0.5);


/* CHECK VALIDITY OF PARAMETER RANGES */


    if((ribose[A] == 'y' && AH2H8[A] == 'y' ))
    { text_error("Choose either ribose='y' or AH2H8='y' !! ");
        psg_abort(1); }

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

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

    if( (((dm[C] == 'y') && (dm2[C] == 'y')) && (STUD[A] == 'y')) )
    { text_error("incorrect dec2 decoupler flags! Should be 'nnn' if STUD='y'"); psg_abort(1); }

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

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

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

    if( (pw > 20.0e-6) && (tpwr > 56) )
    { text_error("don't fry the probe, pw too high ! "); psg_abort(1); }

    if( (pwC > 40.0e-6) && (pwClvl > 56) )
    { text_error("don't fry the probe, pwN too high ! "); psg_abort(1); }

    if( (pwN > 100.0e-6) && (pwNlvl > 56) )
    { text_error("don't fry the probe, pwN too high ! "); psg_abort(1); }
 
    if ((dm3[B] == 'y'  &&   dpwr3 > 44 ))
    { text_error ("Deuterium decoupling power too high ! "); psg_abort(1); }

    if ((ncyc > 1 ) && (ix == 1))
    { text_error("mixing time is %f ms.\n",(ncyc*97.8*4*p_d)); }


/* PHASES AND INCREMENTED TIMES */

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

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

/*  C13 TIME INCREMENTATION and set up f1180  */

/*  Set up f1180  */
   
    tau1 = d2;

    if(f1180[A] == 'y') 
	{ 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') 
	{ 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(t11,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(t11,2,4); }



/*   BEGIN PULSE SEQUENCE   */

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

	obspower(tpwr);
	decpower(pwClvl);
 	dec2power(pwNlvl);
	decpwrf(rfC);
	obsoffset(tofa);
	decoffset(dofa);
	dec2offset(dof2);
	txphase(t3);
	delay(1.0e-5);

	decrgpulse(pwC, zero, 0.0, 0.0);	   /*destroy C13 magnetization*/
	zgradpulse(gzlvl0, 0.5e-3);
	delay(grecov/2);
	decrgpulse(pwC, one, 0.0, 0.0);
	zgradpulse(0.7*gzlvl0, 0.5e-3);
	delay(5.0e-4);

        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, t3, 0.0, 0.0);                    /* 1H pulse excitation */
	zgradpulse(gzlvl0, gt0);		/* 2.0*GRADIENT_DELAY */	
        decphase(zero);
	delay(taua + tau1 - gt0 - 2.0*GRADIENT_DELAY - 2.0*pwC);
        decrgpulse(2.0*pwC, zero, 0.0, 0.0);
        txphase(zero);
	delay(tau1);
	rgpulse(2.0*pw, zero, 0.0, 0.0);
	zgradpulse(gzlvl0, gt0);
        txphase(one);
	decphase(t5);
	obsoffset(tof);
	delay(taua - gt0);
	rgpulse(pw, one, 0.0, 0.0);
	zgradpulse(gzlvl3, gt3);
	delay(grecov);
        decrgpulse(pwC, t5, 0.0, 0.0);
	delay(tau2);
	dec2rgpulse(2.0*pwN, zero, 0.0, 0.0);
	zgradpulse(gzlvl4, gt4);		        /* 2.0*GRADIENT_DELAY */
        decphase(zero);
	delay(taub - 2.0*pwN - gt4 - 2.0*GRADIENT_DELAY);
        txphase(zero);
	decpwrf(rfC);
	delay(taub - 2.0*pw);
	rgpulse(2.0*pw, zero, 0.0, 0.0);
	delay(tau2);
	decrgpulse(2.0*pwC, zero, 0.0, 0.0);
	delay(taub);
	zgradpulse(gzlvl4, gt4);	        /* 2.0*GRADIENT_DELAY */	
	decpwrf(rfdC);
	delay(taub - gt4 - 2.0*GRADIENT_DELAY);
	decrgpulse(1.0e-3, zero, 0.0, 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();
        decrgpulse(9.0*p_d/5.0, t9, 2.0e-6, 0.0);
     if( H2Opurge[A] == 'y' )
         {obspwrf(1000.0); rgpulse(900*pw, zero, 0.0, 0.0);
	   rgpulse(500*pw, one, 0.0, 0.0); obspwrf(4095.0); }
	zgradpulse(gzlvl7, gt7);
	decpwrf(rfC);
	delay(50.0e-6);
        rgpulse(pw,zero,0.0,0.0);
	zgradpulse(gzlvl7, gt7/1.6);
        decrgpulse(pwC, three, 100.0e-6, 0.0); 
	zgradpulse(gzlvl5, gt5);
	decphase(zero);
	delay(tauc - gt5);
	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);
	zgradpulse(gzlvl5, gt5);
	delay(tauc - gt5);
	decrgpulse(pwC, zero, 0.0, 0.0);
	zgradpulse(gzlvl3, gt3);
        if(dm3[B] == 'y')	         /*optional 2H decoupling off */
        {
         dec3rgpulse(1/dmf3, three, 0.0, 0.0);
         dec3blank();
         setstatus(DEC3ch, FALSE, 'w', FALSE, dmf3);
         dec3blank();
        }
	delay(grecov);
	rgpulse(pw, zero, 0.0, 0.0);
	zgradpulse(gzlvl6, gt5);
	delay(taua - gt5);
	simpulse(2.0*pw, 2.0*pwC, zero, zero, 0.0, 0.0);
	zgradpulse(gzlvl6, gt5);
  if (STUD[A]=='y') decpower(studlvl);

  else
   {
	decpower(dpwr);
	dec2power(dpwr2);
   }
	delay(taua - gt5);
	rgpulse(pw, zero, 0.0, rof2);
        rcvron();
        if (dm3[B] == 'y') lk_sample();
	setreceiver(t11);
  if ((STUD[A]=='y') && (dm[C] == 'y'))
       {
        decpower(studlvl);
        decunblank();
        decon();
        decprgon(rna_stCdec,1/stdmf, 1.0);
        startacq(alfa);
        acquire(np, 1.0/sw);
        decprgoff();
        decoff();
        decblank();
       }
   else	
	 status(C);
}		 
Beispiel #29
0
pulsesequence()
{
        double gzlvl1,qlvl,grise,gstab,gt1,ss,phase;
	int icosel,iphase;
  	ss = getval("ss");
        grise=getval("grise");
        gstab=getval("gstab"); 
        gt1=getval("gt1");
        gzlvl1=getval("gzlvl1");
        qlvl=getval("qlvl");
        phase=getval("phase");
        iphase = (int) (phase + 0.5);



/* DETERMINE STEADY-STATE MODE */
   if (ss < 0) ss = (-1) * ss;
   else
      if ((ss > 0) && (ix == 1)) ss = ss;
      else
         ss = 0;
   initval(ss, ssctr);
   initval(ss, ssval);

   assign(oph,v2);
   assign(oph,v1);
   if (iphase == 2)
      incr(v1);

/* HYPERCOMPLEX MODE */
   initval(2.0*(double)(((int)(d2*getval("sw1")+0.5)%2)),v6);
   if ((iphase==1) || (iphase==2))
      {add(v1,v6,v1); add(oph,v6,oph);} 
	

     status(A);
        rcvroff();
	delay(d1);
     if (getflag("wet")) wet4(zero,one);
	rlpower(tpwr,TODEV);

	rgpulse(pw,v1,rof1,rof2);
     status(B);
        if (d2 > rof1 + 4.0*pw/3.1416)
           delay(d2 - rof1 - 4.0*pw/3.1416);
     status(C);
        rgpulse(pw,v2,rof1,rof2);
      
        delay(gt1+2.0*grise+24.4e-6);
        rgpulse(2.0*pw,v2,rof1,rof2);
        icosel=-1;
        rgradient('z',gzlvl1*(double)icosel);
	delay(gt1+grise);
	rgradient('z',0.0);
        txphase(oph);
	delay(grise);

	rgpulse(pw,v2,rof1,rof2);

        rgradient('z',gzlvl1*qlvl);

	delay(gt1+grise);
	rgradient('z',0.0);
	delay(grise);
       rcvron();
	delay(gstab);  
     status(D);
}
Beispiel #30
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);
}