alj alj / Mbed 2 deprecated PGSE_diffusion

Dependencies:   mbed

Revision:
0:8fc9e66cbabb
Child:
1:9c47e011f1bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 26 13:38:44 2012 +0000
@@ -0,0 +1,174 @@
+/*            *************************************************************************************
+              PGSE_diffusion Basic standard sequence, VERSION 1, October 24th 2012
+              PULSE GRADIENT SPIN ECHO diffusion sequence(or diff_se) to measure diffusion coefficient value.
+              ref : E.O. Stejskal and J.E. tanner, J. Chem. Phys. 42, 288 (1965)
+              THE PGSE SEQUENCE IS
+              1H ---> 90° -   DELTA/2 - 180   - DELTA/2  - FID
+              Gz ---> --  - Gz(sdelta)- DELTA - Gz(sdelta)   
+              *************************************************************************************
+              Gradient strength (or duration) must be increase to measure the diffusion coefficient (2D DOSY spectroscopy)
+              The maximum diffusion time (DELAT) is limited by T2 in PGSE.
+              For T1 = T2 the PGSE sequence is usualy the easiest et preferred sequence.
+              For T1 >> Té the PGSTE (PULSE GRADIENT with STIMULATED ECHO) is better, as during most of the diffusion
+              time the magetization evolve prinipaly under T1 relaxtion (magnetization is like stored on Z axis in conventionnal NMR). With PGSTE the maximum
+              diffusion time (DELTA) is limited by T1.
+              IN THIS VERSION THE GRADIENT PULSE DURATION IS USED
+              *************************************************************************************
+                
+                DESIGN FOR NXPLPC1768 ARM CORTEX M3 MCU BOARD:
+                INPUT : NONE (reset on board)
+                OUTPUT :  ACQU                  ---> P26 AND LED1
+                       :  PULSES P1 & P2        ---> P25
+                       :  Emmitter              ---> P24, P23
+                       :  Transmitter           ---> P22, P21
+              ***** IN THIS VERSION RECEIVER AND TRANSMITTER HAVE THE SAME PHASE CYCLE *****
+              *************************************************************************************
+              Alain LOUIS-JOSEPH
+              CNRS
+              Laboratoire de Physique de la Matière Condensée PMC
+              Ecole Polytechnique
+              91128 Palaiseau CEDEX France
+              *************************************************************************************
+                UNLESS OTHERWISE SPECIFIED THE PARAMETERS OF THE PULSE SEQUENCE ARE SET :
+ D1           : relaxation delay ( ms to s)
+ DELTA        : Diffusion time (ms to s)
+ sdelta       :  Gradient duration
+ D21          : delay of recovery
+ DE           : fixed delay before acqusisition (not use)
+ DW           : Dwell time period for sampled t2 acquisition time domain
+ D0           : incremenatble delay ( from 1us to s)(t1 time domain dimension for 2D experiment)
+ NS           : Number of scan
+ NE           : Number of experiment
+ VD           : Variable delay using a file list
+ PW           : Pulse length (us)
+ P90          : 90° transmitter or decoupler pulse length
+ P180         : 180° transmitter or decoupler pulse length
+ P3 P4        : 90°, 180°, X-nucleus pulses length
+ DO           : Decoupler gated off or on
+ HD           : HomoDecoupling in time sharing during acqusition
+ HG           : HomoGating decoupling with receiver gated OFF
+ BB           : Broadband modulation gate
+ CW           : Continuous wave
+ FID          : Free Induction Decay acquisition (data acquisition for time AQ
+ AQ           : Acquisition time (physical t2  acquisition time domain dimension)
+ PHn          : Phase for pulse number n (ie : PH1 for pulse P1)
+ PH0          : Receiver phase
+              *************************************************************************************
+              
+*/
+
+#include "mbed.h"
+
+#define D1  0.1               /*  Relaxation delay in second              */
+#define Fs  48000                 /* Sample frequency in Hz                   */
+#define DW  1                     /* DW time period in us    NOT USE              */
+#define NS  1.0                   /* 8 accumulations                              */
+#define DELTA  0.006              /*  diffusion dealy in s                         */
+#define NE  1.0                   /* 8 accumulations  */
+#define sdelta  0.003            /* gradient duration */
+#define D21  0.001              /* recovery time */
+#define AQ  0.04                  /* acquisition time in seconde     */
+#define P90 0.00005             /* hard 90° 1H  */
+#define IncGsdelta 0.0           /* gradient increment */
+#define stepG  0.0
+
+
+DigitalOut Relaxation(LED1);    /* Delay on pin 26 ??? and flash LED1 during relaxation delay */
+BusOut Acqu(p26, LED2)  ;       /*  Start acquisition */
+DigitalOut  p1(p25);            // HARD PULSE
+DigitalOut  p2(p25);            /* Only for reason of clarity P2 =2*P1 */
+BusOut  PH1PH2(p24, p23) ;      // transmitter and receiver phases are the same
+DigitalOut  Gsdelta(p22) ;           // Gradient Z
+
+int main()
+{
+
+    // while (1) {
+    p1 =0 ;
+    Relaxation = 0 ;
+    Acqu=0x00;
+    PH1PH2=0x00;  //0 init
+
+    for (float i = 0.0f ; i < NS ; i += 1.0f) {
+        
+        Relaxation = 1;         /* LED1 light*/
+        wait(D1);               // relaxation
+        Relaxation = 0;         // turn off the led
+
+        p1=1;
+        wait(P90);              // 90°
+        p1=0;
+        
+        Gsdelta = 1;
+        wait(sdelta); //gradient Z;
+        Gsdelta = 0;
+        
+        wait(DELTA - sdelta);               // diffusion time 
+
+        p2=1;
+        wait(2*P90);            //180°
+        p2=0;
+        
+        Gsdelta = 1;
+        wait(sdelta); //gradient Z;
+        Gsdelta = 0;
+        
+        
+        wait(D21) ;             //recovery time
+
+        Acqu=0x11;              // Acquire FID (we can write 3 in decimal)
+        wait(AQ);
+        Acqu=0x00;
+
+        PH1PH2=PH1PH2+1;        //Phase cycling
+        
+        //IncGsdelta += stepG ;
+
+        }
+   
+    }
+//}
+
+/* INCREMENTATION DE LA DUREE D'ECLAIREMENT DE LED1 AVEC PwmOut
+PwmOut led(LED1);
+
+int main() {
+    while(1) {
+        for(float p = 0.0f; p < 1.0f; p += 0.1f) {
+            led = p;
+            wait(0.1);
+        }
+    }
+} */
+
+/* Digital I/O
+
+    DigitalOut - Configure and control a digital output pin.
+    DigitalIn - Configure and control a digital input pin.
+    DigitalInOut - Bi-directional digital pins
+
+    BusIn - Flexible way to read multiple DigitalIn pins as one value
+    BusOut - Flexible way to write multiple DigitalIn pins as one value
+    BusInOut - Flexible way to read/write multiple DigitalIn pins as one value
+
+    PortIn - Fast way to read multiple DigitalIn pins as one value
+    PortOut - Fast way to write multiple DigitalIn pins as one value
+    PortInOut - Fast way to read/write multiple DigitalIn pins as one value
+
+    PwmOut - Pulse-width modulated output  */
+
+/* Features
+
+  NXP LPC1768 MCU
+      High performance ARM® Cortex™-M3 Core
+      96MHz, 32KB RAM, 512KB FLASH
+      Ethernet, USB Host/Device, 2xSPI, 2xI2C, 3xUART, CAN, 6xPWM, 6xADC, GPIO
+  Prototyping form-factor
+      40-pin 0.1" pitch DIP package, 54x26mm
+      5V USB or 4.5-9V supply
+      Built-in USB drag 'n' drop FLASH programmer
+  mbed.org Developer Website
+      Lightweight Online Compiler
+      High level C/C++ SDK
+      Cookbook of published libraries and projects
+      */