100ns Pulse generation With Matlab

Tell us how your experiment is running with Red Pitaya
DivyaG
Posts: 5
Joined: Mon Jul 18, 2016 6:08 am

100ns Pulse generation With Matlab

Post by DivyaG » Thu Jul 21, 2016 1:10 pm

Hello I am new to programming in general and I am unable to figure out how I can generate a pulse train of 100ns with a frequency of 200kHz using SSH over Matlab. Please help.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: 100ns Pulse generation With Matlab

Post by Nils Roos » Fri Jul 22, 2016 1:31 pm

Hi,

one option would be to generate a PWM signal of 200kHz with a duty cycle of 2%. Look at the example of continuous waveform generation and take the list of scpi commands to help you. Be aware that some of the command descriptions are incorrect, for example the duty cycle command "SOUR#:DCYC" takes a fractional argument instead of percentage points - so for 2% you would use 0.02 .

To run the example, you must first start the scpi-server on the Red Pitaya (button in the RP main page), then insert the address of your RP into the example code.

DivyaG
Posts: 5
Joined: Mon Jul 18, 2016 6:08 am

Re: 100ns Pulse generation With Matlab

Post by DivyaG » Mon Jul 25, 2016 12:12 pm

I used the same code as given for a continuous signal and used pwm as the type of waveform and duty cycle as 0.02 and no output was observed. For the same code, sine and square works fine.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: 100ns Pulse generation With Matlab

Post by Nils Roos » Mon Jul 25, 2016 10:27 pm

Yeah, I noticed that something is not working with PWM as it should. There's a simple workaround: generate your own PWM and play it as an arbitrary waveform like this

Code: Select all

GEN:RST
SOUR1:VOLT 1.0
SOUR1:FUNC ARBITRARY
SOUR1:TRAC:DATA:DATA 0,0.8,0.95,1,1,1,1,1,1,1,1,1,1,0.2,0.05,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0
SOUR1:FREQ:FIX 7629.39453125
OUTPUT1:STATE ON
The frequency of 7629.39453125 is the exact frequency neccessary to output one sample of the arbitrary waveform every DAC-clocktick (125MHz). You can tune the base frequency by changing the number of samples, and the pulse width by changing the number of 1s at the start.

DivyaG
Posts: 5
Joined: Mon Jul 18, 2016 6:08 am

Re: 100ns Pulse generation With Matlab

Post by DivyaG » Tue Jul 26, 2016 9:33 am

Thank you so much. Just out of curiosity, how does one know what is the exact frequency required for one sample?
This works. I can maybe go on from here. Thank you again.

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: 100ns Pulse generation With Matlab

Post by Nils Roos » Tue Jul 26, 2016 8:55 pm

how does one know what is the exact frequency required for one sample?
This information came from analyzing the AWG module and the code that handles it.
  • the waveform buffer has a size of 16384 samples
  • to generate the output signal, a read pointer traverses the buffer at 125MHz with a constant increment, which is chosen to yield the requested frequency with the assumption that the buffer contains one whole period of the waveform
  • frequency f and increment (step size) d are related according to f = d * 125000000Hz / 16384
From there it follows that a frequency of 7629... leads to an increment of 1, which means each DAC cycle the next sample from the buffer will appear at the output. If you were to half the frequency, each sample would appear at the output for 2 consecutive cycles, and so on.

DivyaG
Posts: 5
Joined: Mon Jul 18, 2016 6:08 am

Re: 100ns Pulse generation With Matlab

Post by DivyaG » Wed Jul 27, 2016 7:23 am

Thank you so much. I think I get it now. :)

DivyaG
Posts: 5
Joined: Mon Jul 18, 2016 6:08 am

Re: 100ns Pulse generation With Matlab

Post by DivyaG » Wed Jul 27, 2016 8:59 am

Hello I'm back. I got the board running and got my signal but there are a couple of problems.
1. I need a 4V amplitude signal pulse (100ns, 200kHz). Is this possible with the pitaya?
2. When I set the voltage to 1V I don't seem to be getting a 1V output it's much higher. (I'm checking on an Oscilloscope)
3. I have set the oscilloscope for DC Coupling. What can I do to reduce the ringing? Can I add an amplifier circuit if required?

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: 100ns Pulse generation With Matlab

Post by Nils Roos » Wed Jul 27, 2016 3:16 pm

Hi again,

The fast analog outputs have a range of +- 1V . No output on the Red Pitaya can go over 3.3V, so external amplification is your only option.

The fast analog outputs are specified for 50ohm termination. If you don't use suitable termination at the point where you measure, that would explain your 2nd and 3rd point. I am not sure if you can get completely rid of the ringing with proper impedance matching, part of it may be caused by bandwidth limitations.

Kaltobi44
Posts: 3
Joined: Tue Jan 18, 2022 1:50 pm

Re: 100ns Pulse generation With Matlab

Post by Kaltobi44 » Tue Jan 18, 2022 6:38 pm

Is it possible to let this run through a DIO pin as output ?

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 11 guests