100ns Pulse generation With Matlab
-
- Posts: 5
- Joined: Mon Jul 18, 2016 6:08 am
100ns Pulse generation With Matlab
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.
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: 100ns Pulse generation With Matlab
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.
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.
-
- Posts: 5
- Joined: Mon Jul 18, 2016 6:08 am
Re: 100ns Pulse generation With Matlab
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.
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: 100ns Pulse generation With Matlab
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
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.
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,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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
SOUR1:FREQ:FIX 7629.39453125
OUTPUT1:STATE ON
-
- Posts: 5
- Joined: Mon Jul 18, 2016 6:08 am
Re: 100ns Pulse generation With Matlab
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.
This works. I can maybe go on from here. Thank you again.
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: 100ns Pulse generation With Matlab
This information came from analyzing the AWG module and the code that handles it.how does one know what is the exact frequency required for one sample?
- 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
-
- Posts: 5
- Joined: Mon Jul 18, 2016 6:08 am
Re: 100ns Pulse generation With Matlab
Thank you so much. I think I get it now. 

-
- Posts: 5
- Joined: Mon Jul 18, 2016 6:08 am
Re: 100ns Pulse generation With Matlab
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?
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?
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: 100ns Pulse generation With Matlab
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.
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.
-
- Posts: 3
- Joined: Tue Jan 18, 2022 1:50 pm
Re: 100ns Pulse generation With Matlab
Is it possible to let this run through a DIO pin as output ?
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 1 guest