//Set the fpRFDR pulses from the Spin Rate

if (srate>500) then
   $pwXfprfdr = 1.0e6/(3.0*srate)              // pwXfprfdr is 180 pulse equal to TauR/3.0.
   pwXfprfdr = 0.1*trunc($pwXfprfdr/0.1 + 0.5) // round the pulse width to 100 ns resolution.
   srate = 1.0e6/(3.0*pwXfprfdr)               // recalculate the exact spin rate.
   aXfprfdr = aX90*(2.0*pwX90)/pwXfprfdr       // recalculate the exact amplitude.
   if (aXfprfdr >= 4095) then
      write('error','reset_fprfdr Error: aXfprfdr is >= to 4095')
   endif
endif

if (qXfprfdr < 1) then qXfprfdr = 1.0 endif    // minimum of 1 element

//Set the ptRFDR pulses from the Spin Rate

if (srate>500) then
   $pwXptrfdr = 1.0e6/(3.0*srate)              // pwXptrfdr is 180 pulse equal to TauR/3.0.
   pwXptrfdr = 0.1*trunc($pwXptrfdr/0.1 + 0.5) // round the pulse width to 100 ns resolution.
   srate = 1.0e6/(3.0*pwXptrfdr)               // recalculate the exact spin rate.
   aXptrfdr = aX90*(2.0*pwX90)/pwXptrfdr       // recalculate the exact amplitude.
   if (aXptrfdr >= 4095) then
      write('error','reset_ptrfdr Error: aXptrfdr is >= to 4095')
   endif
endif

if (qXptrfdr < 1) then qXptrfdr = 1.0 endif    // minimum of 1 element

// Syncrhonize tXmix and tXtotal with 12 rotor cycles. 

if (srate>500) then
   tXmix = 36.0*pwXfprfdr*trunc(tXmix/(36.0*pwXfprfdr)+ 0.5)
endif

if (srate>500) then
   tXtotal = 36.0*pwXfprfdr*trunc(tXtotal/(36.0*pwXfprfdr)+ 0.5)
endif



