Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about PulsedNMR #503

Open
johncprice opened this issue Jul 30, 2017 · 34 comments
Open

Question about PulsedNMR #503

johncprice opened this issue Jul 30, 2017 · 34 comments

Comments

@johncprice
Copy link

Pavel, thank you very much for all of this helpful information. I am thinking about a project similar to your PulsedNMR, but I am not sure if the Red-Pitaya hardware is suitable or not. All of my previous experience is with Altera boards. It might save me a lot of time if you could answer two questions:

  1. My project requires a very stable external clock. I see that the Red-Pitaya board has a jumper for an external clock that goes directly to the ADC. If I supply this external clock can the same clock be used for the FPGA logic and for the DAC? I need to have the ADC, the FPGA logic, and the DAC all synchronous.

  2. In your PulsedNMR project it looks like the Tx signal is written out by the CPU. Is the Tx signal phase coherent with the Rx local oscillator? If not, won't the NMR data be at a different phase for every pulse?

Thanks very much for any help you are able to give.

John

@pavel-demin
Copy link
Owner

Thank you for your interest in my NMR application for Red Pitaya. I started this project to help a group from an university with their pulsed NMR setup. My version of this code is still in a state of a basic prototype that lacks some important features (for example, generation of the B pulses). The missing features can be added relatively easily and I know that someone has successfully built a pulsed NMR system for student use based on my prototype.

If I supply this external clock can the same clock be used for the FPGA logic and for the DAC?

Yes, the external ADC clock can be used for the FPGA logic and for the DAC.

Is the Tx signal phase coherent with the Rx local oscillator?

I didn't know that the phase coherence was a requirement. In the current version of my code the phases of the TX and RX signals aren't synchronized.

@johncprice
Copy link
Author

Thanks very much for answering these questions. This is for a student project at the Univ. of Colorado where I teach. Red-Pitaya is the only board I have found that is inexpensive enough for such a project, so it is good news what you say about the clocks. In simple NMR transceivers like the one we are considering the Tx oscillator is usually the same as the Rx local oscillator except maybe at a different phase. The CPU might just gate the waveform from the DDS to create the Tx pulse, rather than providing the complete RF waveform. In more sophisticated high-field NMR systems there is usually an arbitrary waveform generator to create "shaped pulses", which is more similar to what you have done. But in those systems there is also a programmable sequencer that can trigger the RF pulses at definite times and at definite phase relative to the Rx local oscillator. I will definitely get one of these boards and try to get more familiar with the tools. Thanks again for your help!

@pavel-demin
Copy link
Owner

I now have a version of the FPGA configuration with a simple pulse sequence generator. The arbitrary waveform memory is replaced with a DDS and a sequencer. Each pulse has four parameters: delay before, pulse duration, delay after, phase offset. Here is a sequence of three pulses with different phase offsets (0, pi/2, pi):
test_pulses

@johncprice
Copy link
Author

That looks really neat! Are you going to post the updated code? We have not made any progress on our project but I started playing with the RP board.

@PaulMGlover
Copy link

Hi Pavel (and sorry to John for adding to a thread rather than starting my own)

I am new to RedPitaya and FPGA synthesis methods. However, I have designed NMR spectrometers over the years. The RedPitaya and your fantastic software and instructional resource is wonderful and I am learning a lot. I have got as far as working out how the blocks are wired together. I can see how you have changed to a pulse generator and DDS on the tx side (John's suggestion above). I can determine how this works and what instructions I need to feed to it to make the pulses you show above. What I can't work out yet and can't see from your 'server' code is how the tx side FIFO works? It appears that you have done-away with the tx-data-counter so how does the pulse generator 'know' how many words are in the FIFO (or does it matter). Clearly the 'pulse-nmr.c' code is for the original method of arbitrary generation. I can see how to change it but I don't know if the FIFO works in the same way as the rx side or if it is different?

As far as I can see the FPGA is very nearly exactly what I need. There are only one or two things I would like to implement to 'ice the cake' as it were. One thing would be to remove the sync from every tx pulse so that the pulses are coherent thoughout the sequence (if required). I was going to use an unused upper bit from pinc to gate it perhaps. However, I am getting well ahead of where I am now.

If you are interested I will send you a photograph of two large circuit boards of discrete logic chips which are 30 years old and were used to implement a pulse sequence controller for an NMR imaging system!

Thank you again.

Paul

@pavel-demin
Copy link
Owner

Hi Paul,

Thank you for checking the new pulse generator.

You're right. The server code isn't in sync with the FPGA configuration. I've just committed to the devel branch the code that I used to generate the three pulses shown in my previous comment. The values written to the TX FIFO buffer are on the lines 129-142:
https://github.com/pavel-demin/red-pitaya-notes/blob/develop/projects/pulsed_nmr/server/pulsed-nmr.c#L129-L142

The server code is unfinished because I don't have any idea of how to implement a user interface for the new pulse generator. Your ideas are very welcome.

The pulse generator knows the state of the TX FIFO buffer via the s_axis_tvalid wire. This wire is connected to the non-empty signal of the TX FIFO buffer. Here is a link to the code reading the data from the TX FIFO buffer:
https://github.com/pavel-demin/red-pitaya-notes/blob/develop/cores/axis_pulse_generator_v1_0/axis_pulse_generator.v#L57-L63

The sync signal can be controlled by the last unused bit from the phase offset register. This way it can be configured independently for each pulse. Actually, I don't know if the sync signal is required at all.

Best regards,

Pavel

@PaulMGlover
Copy link

PaulMGlover commented Mar 12, 2018

Dear Pavel

Thank you for the very speedy response. I can now see exactly how the tx FIFO server side works so that is very helpful. I was going to try and guess at something along those lines - but I have to admit that I would have got the write word order wrong (at least to start with).

The sync facility isn't really needed during a sequence of pulses, but only for the very first pulse if at all. It might be desirable in some circumstances to be able to synchronise the tx and rx DDS devices if the frequencies were exactly the same.

Another point I was going to make was that the Rx acquisition block should be timed from the tx pulse generator as well - almost as if it were a pulse in itself. This is vital for coherence of the signal so that data averaging can take place (always happens in NMR!). I was wondering how this might be done but now I see that there is an 'enable' line originating in the server code and going to the rx fifo. I was going to investigate the possibility of driving this from the pulse generator in the tx chain.

However, I need to get on with the day job and will have to pursue this later. I just wanted to say thank you for responding to my question. I certainly have some ideas about how one might create a flexible and usable interface once I understand how the FPGA code and server works.

Paul

@PaulMGlover
Copy link

Pavel

Some success! I thought you would like to see some output from the pulsed-NMR project. The graphic shows an FID obtained after a 10 microsecond pulse at 18.45 MHz on a bench-top magnet
fid. The pulse tip-angle is undefined for the moment. The FID is typical of the unfiltered signal seen on the 'scope before further base-band filtering.

I have made some modifications to the gating. I have used two bits from the phase offset register to gate the RF pulse, and also gate the receive channel. I have done the latter (for simplicity to start with) by putting the Rx-gate into the t-data-valid on the CICs (which is usually set to true permanently). This works but it would be better to gate the flow of data into the FIFO so that the FIR filter can operate all the time. Otherwise the first points of the acquisition get mixed up with the end of the previous acquisition. It isn't very obvious on this graphic because it is mixed up with the ring-down of the pulse etc. The only other very minor change (just to see if I could edit and compile the FPGA) was to output the gates to LEDs. For the moment the 'server' code just runs and dumps data to a file which I read into matlab - laborious but it made things slightly simpler for understanding what is happening.

I feel that I could now pass this on to some students as a project now I know that it does the business - thanks to your design skills.

Paul

@PaulMGlover
Copy link

Sorry, forgot to say that the x-axis on the graph is milliseconds.

@pavel-demin
Copy link
Owner

Thanks for sharing these results! I'm glad that the new pulser starts to be usable.

I agree that gating the RX path isn't trivial. That's why I prefer to keep it running continuously. The only application where I restart the RX modules is VNA. It's required for the phase measurements. To avoid the effects of the restarting, I just skip the first 200 microseconds. Maybe something similar could be done in the pulsed NMR application.

BTW. I didn't know that the NMR applications require the phase measurement. I thought that only the amplitude is measured.

@twitzelbos
Copy link

twitzelbos commented Apr 18, 2018

Hello Pavel,

I also felt your example was very useful and I have been trying to reach you last November. Paul, awesome result, once you start you cannot stop :-)

I have students actively taking MRI images using the red pitaya, and we'll have an oral presentation on low-cost open source MRI at ISMRM in Paris this year.

20180411_212252
These are three Analog devices 16-bit DAC evaluation boards used to generate the gradient waveforms and linear shim offsets. Below the "DAC rig" is our open-source 3x10A gradient amplifier.

20180418_163416
Our 0.3T benchtop magnet with sample holder and TR-switch/preamp board.

20180415_175558
Image of a small star phantom (non-selective excitation, 50 us hard pulse due to only 0.7W transmit power).

20180411_212221
Example spin-echo on 1cm NMR tube filled with water, non-selective 50 us hard pulse.

This data is from a 15.7MHz benchtop magnet, with a 1 cm FOV, and 3-axis gradients (open source hardware), so very close to Pauls. Note, that we needed a lot of gain from the coil to the red pitaya input to get good SNR (~ 60 dB).

We will be making all the source available at ISMRM and since it contains your cores and still has parts of your pulsed-nmr example, I wanted to know what license you prefer and how you would like to be credited in the project.

Thomas Witzel

@pavel-demin
Copy link
Owner

Hello Thomas,

Thanks for the pictures. It's great that your project is progressing well.

The license for the code running on the Red Pitaya board is MIT license:
https://github.com/pavel-demin/red-pitaya-notes/blob/master/LICENSE

Since the GUI client code is based on the Qt library it has to be under the GPLv3 license:
https://github.com/pavel-demin/red-pitaya-notes/blob/master/projects/pulsed_nmr/client/COPYING

It would be great if you could link my Red Pitaya notes (http://pavel-demin.github.io/red-pitaya-notes) from your project.

Best regards,

Pavel

@twitzelbos
Copy link

Hello Pavel,

thank you for the very fast response. We will likely go with the MIT license as well for the HDL side of things. We can either fork your project, or contribute to your github. Either is fine with me in principle.

We will link to your red-pitaya-notes in all published works and websites.

Thomas

@BeauWebber
Copy link

BeauWebber commented Jun 18, 2018

Hi Guys,
Yes what Pavel has done is great. It is really extremely useful and effective.
I have been conversing with him off-line, while I have been building up some NMR kits around the Red Pitaya. I now have a receiver that I am very happy with - it has replaced my previous receivers in my lab, and is now in day-to-day use.
The transmitters are still work in progress, but I have had NMR signals from both a linear transmitter module, taking RF signals from Pavel's latest DDS transmitter, and also a digital transmitter that currently is driven by a different FPGA.
Perhaps some background would be useful - I have been building NMR spectrometers since 1972 - the first one had a 2 valve transmitter and solid-state receiver with a super-linear diode detector.
Pretty soon I had developed an all digital CMOS logic plus bipolar transistor power stage NMR transmitter (the bigger box in this picture) plus a NMR receiver with hard-ware phase-locked loop detector.

Here is one of the last being commissioned in 1992 (about 24 were made) and I have used it for decades for my published research. Pi/2 into a 5mm water sample is less than 3 us. I am just retiring it now with the advent of these Red Petaya based spectrometers.
image

I have worked with Altera FPGAs for many years, and I am afraid getting to grips with the Xilinx firmware in the Red Pitaya is taking longer than I would like.
I use the array processing language AplX to process the data, and it is also very good at creating and interacting with the GUI frontpanels. I now use it in Server-Client mode, where the Server runs in Linux in the ARM CPU, and talks via c programs with Pavel's firmware, and the Client runs on the desktop, handles the GUI and file I/O.

Here is the new low-noise receiver, about 60 dB gain (variable), mounted on the Red Pitaya.

image

And here are the Receiver, Transmitter and Pulse Programmer GUI frontpanels (with fairly arbitrary settings), followed by a single-shot CP/MG echo train, using my prototype linear transmitter board. But I am very limited in how much power I can apply, the transmitter module needs a proper box to work well. Pi/2 into a 5mm water sample is currently 15 us , Pi is 30 us .

image

image

I am just starting to update my company instrumentation web page, but feel free to have a browse, there is quite a bit of older stuff on it too : http://www.lab-tools.com/instrumentation/

I am busy documenting things at the moment, so I hope to have more here and on the above web-site soon.
cheers,
Dr. Beau Webber

@dnhkng
Copy link

dnhkng commented Aug 22, 2018

Hi NMR Experts,

I want to build a permanent magnet NMR. Yes, its a weird hobby project, but I'm an organic chemist by training, and I now have some FPGA experience. My goal is about a 0.5 tesla device.

Working from Pavel's base, I would like to extend extend the project, and use the pynq framework to interface the PL. Basically VHDL for the fast stuff, and Python for the rest.

Can I get some input on what features to add? My current list includes:

  • slow DACs for gradient field control. (Maybe I try and build a MRI device later).
  • lock-in amplifier in the RX, like in this paper: "Simple and low-cost tabletop NMR system for chemical-shift-resolution spectra measurements", (https://doi.org/10.1016/j.jmr.2018.07.003)
  • 16 GPIOs. Because more is better.
  • LED control to monitor status.

Any suggestions would be great.
-David

@BeauWebber
Copy link

BeauWebber commented Aug 22, 2018 via email

@BeauWebber
Copy link

A pre-Christmas update on the NMR system :
Lots of progress since I last wrote.

A Red Pitaya with a ~60 dB gain pre-amp I have designed, plus Pavel Demin’s firmware, is working well,
and is now my main receiver for my NMR system in my research laboratory.

I am using the Apl language I talked about previously, but now working with Micro-Apl’s AplX :
running the Apl server in the ARM cores in the Red Pitaya, talking to C which talks to Pavel Demin’s firmware; and the Apl client on the desktop handles the GUI and the control and data handling.

I also have two NMR transmitter modules – for the high-power NMR digital transmitter, the prototype worked well, and the V4 boards are back from etching and assembly, but the machine shops are taking forever with the finishing stages of the 3D printed boxes.

I also have a lower-power NMR linear amplifier, that amplifies Ch1 output from the Red Pitaya, as generated by Pavel's code. Final boards away for etching and assembly, as are the 3D printed boxes.

I talked about these at an NMR conference in Florida, last February, and have now published a paper :

  1. Credit-card sized Field and Benchtop NMR Relaxometers using Field Programmable Gate Arrays. J. Beau W. Webber, Pavel Demin, Magnetic Resonance Imaging, 2018, DOI: 10.1016/j.mri.2018.09.018

I still have to have the EU certification done, but hope to be selling Version 1 NMR Spectrometers within about 6 months.

Cheers,
Beau

@twitzelbos
Copy link

Hi Beau and Pavel,

happy new year!! This is extremely exciting news. Congratulations on the publication! It's exciting to see progress. We are proceeding slowly as this a small side project for me... I'll start blogging soon on my github page, so people will see progress....Pavel, you got the new SDR redpitaya? I tried contacting redpitaya about it, but I'm not getting much information at this point...

@pavel-demin
Copy link
Owner

Pavel, you got the new SDR redpitaya?

I have a prototype of the new board. It looks exactly like the board shown on the Red Pitaya web site (https://www.redpitaya.com/n86/new-stemlab-sdr). Unfortunately, this prototype has a problem in the TX part. So, I can't test the TX functionality at the moment.

@twitzelbos
Copy link

Okay, sorry to hear about that. Since I'm not doing SDR, I'm not too excited about the 122.88 MHz clock. Of course, I can make the NMR/MRI stuff work with that as well, but a 125 MHz clock would be way more convenient...

@BeauWebber
Copy link

BeauWebber commented Jan 4, 2019 via email

@twitzelbos
Copy link

Hi Beau,
I would be interested in trying your hardware. As you know, I'm making all my work openly available (hardware and software), which may not entirely be aligned with your project, but I wouldn't mind having your setup in my lab. I have not had a chance to work on the amplifier yet for example. I'm using an open source 800 mW transmitter we developed based on an obsolete Motorola hybrid amp, and I'm also using a vintage ENI linear amp with a bit more oomph...

@BeauWebber
Copy link

BeauWebber commented Jan 4, 2019 via email

@BeauWebber
Copy link

BeauWebber commented Feb 4, 2019 via email

@BeauWebber
Copy link

Hi guys,
Now have the NMR receiver in a box (will soon be smaller), so this is the latest version of my NMR Spectrometer, based on Pavel's firmware, and with the NMR linear transmitter. Soon hopefully going for certification.
2019-03-12 - P1060875_Lab-Tools NMR Spectrometer_v3#001_cr+Text

@twitzelbos
Copy link

Hello guys,

Is there any news about the 16bit redpitaya? I have been trying to get info by emailing them, but can never get the real story. Do they ship? Do they work?

@BeauWebber
Copy link

BeauWebber commented May 27, 2019 via email

@BeauWebber
Copy link

Yes my 16 bit Red Pitaya came today.
One possible worry is not a problem - the physical lay-out of the E1 & E2 connectors is the same, and will fit the PCBs that I have had made to plug in.
I regret if will be a few days before I can fire it up and do some testing.

@BeauWebber
Copy link

I am pleased to say my NMR Spectrometer has passed its Accreditation and EU testing with flying colours.
For minimum radiated noise it is necessary to replace the standard Red Pitaya +5V switch-mode power supply with a linear power supply. The other power supplies are already linear supplies.

@pavel-demin
Copy link
Owner

For information. I've created a new GitHub repository and a new set of notes on the new STEMlab 122.88-16 SDR board. Here are the links:

https://github.com/pavel-demin/stemlab-sdr-notes
https://pavel-demin.github.io/stemlab-sdr-notes

@twitzelbos
Copy link

Thanks, Pavel, much appreciated. Hopefully, I get my boards soon as well.

@BeauWebber
Copy link

BeauWebber commented Jun 15, 2019

Hmm, no joy firing up the 16 bit Red Pitaya - using the supplied SD card.
Green LED OK, No Heartbeat LED.
BT Hub does not see it.
SD card version.txt and file dates identical to an SD card from a recent 14 bit Red Pitaya.

But it works fine with Pavel's Alpine distribution :
Starts with yellow LED pulsing,
Get list of applications - I just started VNA, then back to LED.

@BeauWebber
Copy link

BeauWebber commented Jun 15, 2019

The Lab-Tools NMR Relaxation Spectrometer is now ready.
On the left is the Red Pitaya : the Array processing AplX server runs in the Linux Arm processor; this talks to C routines, which in turn talk to Pavel's firmware. The surface mount low noise receiver, linear transmitter, and probe tuning are in the 3D printed gold flashed box.
The connector pins will be covered with a 3D printed cover, when not connected to additional instrumentation.

P1070068 - Assembled_br_cr_med

RedPitaya_ARM-to-AplX-to-C-to-Firmware_bg

RP Receiver block diagram_fixedFIR_bg

RP Transmitter block diagram_pipeline_v2_bg

Here is the Free Induction Decay of Fluorine in PTFE; This is part of an experiment to determine the crystalline / amorphous polymer ratio :

F - PTFE - Sealex Foam -4 - fit

And here is a measurement of the Gaussian T2 of solid brittle ice, as a function of temperature; This gives information on the dynamics / mobility of the ice molecules :

Solid Brittle Ice - T2 vs Temperature

@twitzelbos
Copy link

twitzelbos commented Jun 16, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants