alj alj / Mbed 2 deprecated CPMG_T2

Dependencies:   mbed

Committer:
alj
Date:
Mon Jan 27 14:55:01 2014 +0000
Revision:
1:b6541b5d9934
Parent:
0:6ed68c99564e
Pulse programmer CPMG_T2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alj 0:6ed68c99564e 1 /* *************************************************************************************
alj 0:6ed68c99564e 2 CPMG_T2 Basic standard sequence, VERSION 1, October 22th 2012
alj 0:6ed68c99564e 3 CPMG SPIN ECHO PULSE SEQUENCE FOR T2 MEASURMENT IN NMR SPECTROMETRIE.
alj 0:6ed68c99564e 4 {D1 - P1 - [D2 - P2 - D2]n - FID }NS
alj 0:6ed68c99564e 5 Homonuclear sequence : (p1, P2 --> same channel)
alj 0:6ed68c99564e 6 DESIGN FOR NXPLPC1768 ARM CORTEX M3 MCU BOARD:
alj 0:6ed68c99564e 7 INPUT : NONE (reset on board)
alj 0:6ed68c99564e 8 OUTPUT : ACQU ---> P26 AND LED1
alj 0:6ed68c99564e 9 : PULSES P1 & P2 ---> P25
alj 0:6ed68c99564e 10 : Emmitter ---> P24, P23
alj 0:6ed68c99564e 11 : Transmitter ---> P24, P23
alj 0:6ed68c99564e 12 ***** IN THIS VERSION RECEIVER AND TRANSMITTER HAVE THE SAME PHASE CYCLE *****
alj 0:6ed68c99564e 13 *************************************************************************************
alj 1:b6541b5d9934 14 Alain L-J
alj 1:b6541b5d9934 15 France
alj 0:6ed68c99564e 16 91128 Palaiseau CEDEX France
alj 0:6ed68c99564e 17 *************************************************************************************
alj 1:b6541b5d9934 18 This program comes as is with its flaws and bugs.
alj 1:b6541b5d9934 19 NO WARRANTY IS PROVIDED.
alj 1:b6541b5d9934 20 This program is distributed in the hope that it will be useful,
alj 1:b6541b5d9934 21 but WITHOUT ANY WARRANTY; without even the implied warranty of
alj 1:b6541b5d9934 22 FITNESS FOR A PARTICULAR PURPOSE
alj 1:b6541b5d9934 23 This software is distributed on an "AS IS" BASIS,
alj 1:b6541b5d9934 24 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
alj 1:b6541b5d9934 25 *************************************************************************************
alj 0:6ed68c99564e 26 UNLESS OTHERWISE SPECIFIED THE PARAMETERS OF THE PULSE SEQUENCE ARE SET :
alj 0:6ed68c99564e 27 D1 : relaxation delay ( ms to s)
alj 0:6ed68c99564e 28 D2, D3,etc, : fixed delay (ms to s)
alj 0:6ed68c99564e 29 DE : fixed delay before acqusisition
alj 0:6ed68c99564e 30 DW : Dwell time period for sampled t2 acquisition time domain
alj 0:6ed68c99564e 31 D0 : incremenatble delay ( from 1us to s)(t1 time domain dimension for 2D experiment)
alj 0:6ed68c99564e 32 NS : Number of scan
alj 0:6ed68c99564e 33 VD : Variable delay using a file list
alj 0:6ed68c99564e 34 PW : Pulse length (us)
alj 0:6ed68c99564e 35 P90 : 90° transmitter or decoupler pulse length
alj 0:6ed68c99564e 36 P180 : 180° transmitter or decoupler pulse length
alj 0:6ed68c99564e 37 P3 P4 : 90°, 180°, X-nucleus pulses length
alj 0:6ed68c99564e 38 DO : Decoupler gated off or on
alj 0:6ed68c99564e 39 HD : HomoDecoupling in time sharing during acqusition
alj 0:6ed68c99564e 40 HG : HomoGating decoupling with receiver gated OFF
alj 0:6ed68c99564e 41 BB : Broadband modulation gate
alj 0:6ed68c99564e 42 CW : Continuous wave
alj 0:6ed68c99564e 43 FID : Free Induction Decay acquisition (data acquisition for time AQ
alj 0:6ed68c99564e 44 AQ : Acquisition time (physical t2 acquisition time domain dimension)
alj 0:6ed68c99564e 45 PHn : Phase for pulse number n (ie : PH1 for pulse P1)
alj 0:6ed68c99564e 46 PH0 : Receiver phase
alj 0:6ed68c99564e 47 *************************************************************************************
alj 0:6ed68c99564e 48 For CPMG sequence :
alj 0:6ed68c99564e 49 For best SNR, Transmitter Pulse phase PH1 and Acquisition receiver phase (PH0) should follow the standard quadrature phase cycle,
alj 0:6ed68c99564e 50 QP : 0, 0, 180°, 180°, 90°, 90°, 270°,270°
alj 0:6ed68c99564e 51 PH2 phase should be : 90°, 90°, 90°, 90°, 180°, 180°, 180°, 180°
alj 0:6ed68c99564e 52 n must be even
alj 0:6ed68c99564e 53 optimise D2 to eliminate J modulation and/or diffusion effect
alj 0:6ed68c99564e 54 ***** IN THIS VERSION RECEIVER AND TRANSMITTER HAVE THE SAME PHASE CYCLE and are cycled 0°, 90°, 180°, 270°*****
alj 0:6ed68c99564e 55 *************************************************************************************
alj 0:6ed68c99564e 56 */
alj 0:6ed68c99564e 57
alj 0:6ed68c99564e 58
alj 0:6ed68c99564e 59 #include "mbed.h"
alj 0:6ed68c99564e 60
alj 0:6ed68c99564e 61 #define D1 0.0005 /* Relaxation delay in second */
alj 0:6ed68c99564e 62 #define Fs 48000 /* Sample frequency in Hz NOT USE */
alj 0:6ed68c99564e 63 #define DW 1 /* DW time period in us */
alj 0:6ed68c99564e 64 #define NS 8.0 /* 8 accumulations */
alj 0:6ed68c99564e 65 #define D2 0.000010 /* echo delay in ms */
alj 0:6ed68c99564e 66 #define n 1
alj 0:6ed68c99564e 67 #define AQ 0.0005
alj 0:6ed68c99564e 68 #define P90 0.000005
alj 0:6ed68c99564e 69
alj 0:6ed68c99564e 70
alj 0:6ed68c99564e 71
alj 0:6ed68c99564e 72 DigitalOut Relaxation(LED1); /* Delay on pin 26 ??? and flash LED1 during relaxation delay */
alj 0:6ed68c99564e 73 BusOut Acqu(p26, LED2) ; /* */
alj 0:6ed68c99564e 74 DigitalOut p1(p25);
alj 0:6ed68c99564e 75 DigitalOut p2(p25); /* Only for reason of clarity P2 =2*P1 */
alj 0:6ed68c99564e 76 BusOut PH1PH2(p24, p23) ; // transmitter and receiver phases are the same
alj 0:6ed68c99564e 77
alj 0:6ed68c99564e 78 int main()
alj 0:6ed68c99564e 79 {
alj 0:6ed68c99564e 80
alj 0:6ed68c99564e 81 // while (1) {
alj 0:6ed68c99564e 82 p1 =0 ;
alj 0:6ed68c99564e 83 Relaxation = 0 ;
alj 0:6ed68c99564e 84 Acqu=0x00;
alj 0:6ed68c99564e 85 PH1PH2=0x00; //0 init
alj 0:6ed68c99564e 86
alj 0:6ed68c99564e 87 for (float i = 0.0f ; i < NS ; i += 1.0f) {
alj 0:6ed68c99564e 88
alj 0:6ed68c99564e 89 Relaxation = 1; /* LED1 light*/
alj 0:6ed68c99564e 90 wait(D1); // relaxation
alj 0:6ed68c99564e 91 Relaxation = 0; // turn off the led
alj 0:6ed68c99564e 92
alj 0:6ed68c99564e 93
alj 0:6ed68c99564e 94 p1=1;
alj 0:6ed68c99564e 95 wait(P90); // 90°
alj 0:6ed68c99564e 96 p1=0;
alj 0:6ed68c99564e 97
alj 0:6ed68c99564e 98 wait(D2); // delay D2
alj 0:6ed68c99564e 99
alj 0:6ed68c99564e 100 p2=1;
alj 0:6ed68c99564e 101 wait(2*P90); //180°
alj 0:6ed68c99564e 102 p2=0;
alj 0:6ed68c99564e 103
alj 0:6ed68c99564e 104 wait(D2); // delay
alj 0:6ed68c99564e 105
alj 0:6ed68c99564e 106 Acqu=0x11; // Acquire FID (we can write 3 in decimal)
alj 0:6ed68c99564e 107 wait(AQ);
alj 0:6ed68c99564e 108 Acqu=0x00;
alj 0:6ed68c99564e 109
alj 0:6ed68c99564e 110 PH1PH2=PH1PH2+1; //Phase cycling
alj 0:6ed68c99564e 111
alj 0:6ed68c99564e 112 }
alj 0:6ed68c99564e 113 //wait(1); //for slow test
alj 0:6ed68c99564e 114 }
alj 0:6ed68c99564e 115 //}
alj 0:6ed68c99564e 116
alj 0:6ed68c99564e 117 /* INCREMENTATION DE LA DUREE D'ECLAIREMENT DE LED1 AVEC PwmOut
alj 0:6ed68c99564e 118 PwmOut led(LED1);
alj 0:6ed68c99564e 119
alj 0:6ed68c99564e 120 int main() {
alj 0:6ed68c99564e 121 while(1) {
alj 0:6ed68c99564e 122 for(float p = 0.0f; p < 1.0f; p += 0.1f) {
alj 0:6ed68c99564e 123 led = p;
alj 0:6ed68c99564e 124 wait(0.1);
alj 0:6ed68c99564e 125 }
alj 0:6ed68c99564e 126 }
alj 0:6ed68c99564e 127 } */
alj 0:6ed68c99564e 128
alj 0:6ed68c99564e 129 /* Digital I/O
alj 0:6ed68c99564e 130
alj 0:6ed68c99564e 131 DigitalOut - Configure and control a digital output pin.
alj 0:6ed68c99564e 132 DigitalIn - Configure and control a digital input pin.
alj 0:6ed68c99564e 133 DigitalInOut - Bi-directional digital pins
alj 0:6ed68c99564e 134
alj 0:6ed68c99564e 135 BusIn - Flexible way to read multiple DigitalIn pins as one value
alj 0:6ed68c99564e 136 BusOut - Flexible way to write multiple DigitalIn pins as one value
alj 0:6ed68c99564e 137 BusInOut - Flexible way to read/write multiple DigitalIn pins as one value
alj 0:6ed68c99564e 138
alj 0:6ed68c99564e 139 PortIn - Fast way to read multiple DigitalIn pins as one value
alj 0:6ed68c99564e 140 PortOut - Fast way to write multiple DigitalIn pins as one value
alj 0:6ed68c99564e 141 PortInOut - Fast way to read/write multiple DigitalIn pins as one value
alj 0:6ed68c99564e 142
alj 0:6ed68c99564e 143 PwmOut - Pulse-width modulated output */
alj 0:6ed68c99564e 144
alj 0:6ed68c99564e 145 /* Features
alj 0:6ed68c99564e 146
alj 0:6ed68c99564e 147 NXP LPC1768 MCU
alj 0:6ed68c99564e 148 High performance ARM® Cortex™-M3 Core
alj 0:6ed68c99564e 149 96MHz, 32KB RAM, 512KB FLASH
alj 0:6ed68c99564e 150 Ethernet, USB Host/Device, 2xSPI, 2xI2C, 3xUART, CAN, 6xPWM, 6xADC, GPIO
alj 0:6ed68c99564e 151 Prototyping form-factor
alj 0:6ed68c99564e 152 40-pin 0.1" pitch DIP package, 54x26mm
alj 0:6ed68c99564e 153 5V USB or 4.5-9V supply
alj 0:6ed68c99564e 154 Built-in USB drag 'n' drop FLASH programmer
alj 0:6ed68c99564e 155 mbed.org Developer Website
alj 0:6ed68c99564e 156 Lightweight Online Compiler
alj 0:6ed68c99564e 157 High level C/C++ SDK
alj 0:6ed68c99564e 158 Cookbook of published libraries and projects
alj 0:6ed68c99564e 159 */