tknopp / RedPitayaDAQServer

Advanced DAQ Tools for the RedPitaya (STEMlab 125-14)
https://tknopp.github.io/RedPitayaDAQServer/dev/
Other
37 stars 10 forks source link

modulus < > sample rate????? #87

Closed karu2003 closed 1 month ago

karu2003 commented 1 month ago

Where do you get it from modulus. I need to generate a chirp signal, I don't really understand what kind of sample rate you have. :(

tknopp commented 1 month ago

125000000 / modulus is the sampling rate. 125Mhz is fixed in the RP.

karu2003 commented 1 month ago

it's not quite clear. how is this related to DEC? You change both values ​​in the examples. I have another question. I'm looking for an alternative to the official firmware. I need to get a signal of 0.3 seconds duration with a sampling frequency of at least 96000....1M at the generator output.

tknopp commented 1 month ago

which example are you referring to? That would help. The second question, I don't understand.

karu2003 commented 1 month ago

In all examples you don't have sampling rate. You have DEC and modulus.

Regarding the second question. Can your system reproduce a long signal. more than 16K points? For example, I have a signal of 300K points and 1M sampling rate.

nHackel commented 1 month ago

The decimation determines the sampling rate, it is based on the clock of 125 MHz. The highest sampling rate we have is achieved with a decimation of 8. That gives you 1.25e8/8 = 1.5625e7 Hz. This is essentially just for receiving the data.

The examples then use the modulus to define the frequency of the signals we are sending. They use a modulus of 12480 for example. 1.25e8/12480 is around 10 Hz. So that would be a 10 Hz sine wave. When you define your signal frequency you have to take care that you sampling rate or rather how you group your samples, fits to your signal. Otherwise you get a drift in your reception.

For example, when we use a frequency of 1.25e8/12480 and a decimation of 8 we have 1560 samples per period. With a decimation of 32 we would have 390 per period. If we would have a decimation of 128, we would have 97.5 samples per period and in the reception our signal would "drift" over time.

The data acquisition section of the documentation details for different sampling rates how long data exists before it is being overwritten. Generally, our system can record data continuously at the highest supported sampling rate. It is more a question of how efficient you are receiving the data. At that data rate a single RedPitaya produces 500 Mbit/s

nHackel commented 1 month ago

I'm not exactly sure what you mean with reproduce a signal of more than 16k points. Do you mean an arbitrary waveform?

jonschumacher commented 1 month ago

According to this thread, the question is about the send side and not receiving. So actually the question about the modulus is probably just a misunderstanding. Sending is always done with 125 MHz sample rate. There is some documentation on arbitrary waveforms with LUTs in https://tknopp.github.io/RedPitayaDAQServer/dev/examples/sequence.html. The sequencing is not fully covered in the documentation but it is used extensively https://github.com/MagneticParticleImaging/MPIMeasurements.jl. I am not sure how many samples can be stored in the LUT though. The RAM on the RP is quite limited and the BRAM even more. You might have to push multiple blocks of LUTs during your sequence.

karu2003 commented 1 month ago

I'm not exactly sure what you mean with reproduce a signal of more than 16k points. Do you mean an arbitrary waveform?

Yes. arbitrary?

jonschumacher commented 1 month ago

https://en.wikipedia.org/wiki/Arbitrary_waveform_generator ;) I guess that is essentially what you want. Create a waveform that is not one of the standard waveforms like sine, sqquare wave or triangle.

nHackel commented 1 month ago

You can set arbitrary waveforms for the rf-outputs with 2^14 values. This is then repeated as long as the trigger is active/the waveform is set. You can change the frequency of that waveform.

For both the rf-outputs and the four analog pins you can set an arbitrary waveform, but those are farily slow in their update rate and can fall behind/output the wrong signal if new values need to be output with more than 10 kHz

karu2003 commented 1 month ago

jonschumacher I have some of these. I need to replace it with something. :)

Thank you. Your firmware is no different from the original. :( There is also a limit of 16K points. And DAC streaming only works at 125M. I will look for some USB avg generator. Thanks for introducing me to Julia.

jonschumacher commented 1 month ago

It really depends on what you want to achieve. Could you specify the signal you want to produce?

Depending on your budget, https://spectrum-instrumentation.com/ could be a nice option. They offer an AWG where you can split the memory into multiple sections that can be looped and transitioned between freely. The PicoScopes also work quite nicely: https://www.picotech.com/oscilloscope/2000/picoscope-2000-overview.

karu2003 commented 1 month ago

simple example. sometimes i need to give an ECG signal. A picoscope is the worst choice. :(

fs = 1e6  # Sampling frequency
t1 = 0.004  # Chirp duration 4 ms
t2 = 0.002  # Chirp duration 2 ms
pause = 0.008  # Pause 8 ms

function generate_chirp(f0, f1, t, fs)
    t = range(0, stop=t, length=Int(fs * t))
    return sin.(2 * π * (f0 .+ (f1 - f0) .* (t ./ t[end])) .* t)
end
function generate_signal(fs, t1, t2, pause)
    signal = Float64[]
    append!(signal, generate_chirp(18000, 34000, t1, fs))
    append!(signal, zeros(Int(fs * pause)))
    for _ in 1:2
        append!(signal, generate_chirp(34000, 18000, t1, fs))
        append!(signal, zeros(Int(fs * pause)))
    end

    for _ in 1:129
        append!(signal, generate_chirp(34000, 18000, t2, fs))
    end

    return signal
end
signal = generate_signal(fs, t1, t2, pause)
jonschumacher commented 1 month ago

Hm, easy to implement on the FPGA but not so easy in our current firmware. In the end it is just a counter in front of the frequency input of a DDS combined with another counter for the pause sequencing. If the fixed sequence is sufficient, this can be done easily. Just grab the FPGA image and strip most parts. Just hardcode the values and you are good to go. But making it configurable requires implementing it in the FPGA, then the server and also the client. This is not done quickly. If you want to have a go on it, we can probably assist you but currently this is nothing we plan to implement on our own.

karu2003 commented 1 month ago

jonschumacher It's good that there are alternatives in the rack. I took ADALM2000 - 64K buffer, adjustable sample rate. The disadvantage is that it works in conjunction with a raspberry or PC. No ethernet.

jonschumacher commented 1 month ago

Alright, seems like you found a solution. I will close here. If you need assistance in implementing a chirp within the firmware, feel free to open a new issue.