I am working on a project where I need to do a frequency sweep with the RP board in combination with an amplifier. The problem is, that the frequencies are switched independently of the actual phase of the signal, so spikes will appear at the switching points which harm the amplifier.
As far as I know the Direct Digital Synthesis (DDS) is state of the art in function generator to avoid this problem. Is there any solution for this already used on the RP that I can just insert in my code? I think this should be a common problem but I could not find the solution in the example files (function generator, impedance analyzer, ...).
Can anyone tell me if and where I can find the required piece of code or are there other options to solve this problem (e.g. look up table for the sine wave)? I do my programming in C.
Thanks
Peter
Frequency Sweep DDS
-
- Posts: 799
- Joined: Sat May 23, 2015 5:22 pm
Re: Frequency Sweep DDS
Hello Peter,
I'm sweeping frequencies using a DDS in my VNA project:
http://pavel-demin.github.io/red-pitaya-notes/vna/
Since the frequencies are changed by changing the phase increment, the signal should be smooth.
The C code running on Red Pitaya can be found at the following location:
https://github.com/pavel-demin/red-pita ... vna/server
The VNA application is available from the Red Pitaya application marketplace. So, you can easily check the signal smoothness.
Best regards,
Pavel
I'm sweeping frequencies using a DDS in my VNA project:
http://pavel-demin.github.io/red-pitaya-notes/vna/
Since the frequencies are changed by changing the phase increment, the signal should be smooth.
The C code running on Red Pitaya can be found at the following location:
https://github.com/pavel-demin/red-pita ... vna/server
The VNA application is available from the Red Pitaya application marketplace. So, you can easily check the signal smoothness.
Best regards,
Pavel
-
- Posts: 6
- Joined: Tue Mar 01, 2016 4:34 pm
Re: Frequency Sweep DDS
Hello
I am still struggling with the DDS Problem. Pavel, thank you for your response!
The aim is to make a frequency sweep or to alter the frequency of a continuous sine wave during operation with smooth transitions between the frequencies. At present I face the problem that the sine wave starts from 0 when I change the frequency and that leads to unwanted steps in the signal that might harm the peripherals.
I tried to realize the sweep with the RP API (please see code below). It is a very simple loop that alters just the frequencies. When I check the signal on the oscilloscope I see the unwanted steps. I checked the source code of the involved functions and I think that basically everything needed for DDS ist there. The sine wave is stored in a look up table and the step size is altered to change the frequency. What is missing is that the code recognizes the actual point in the look up table when the frequency is altered.
I also checked the source code of the example 'generate.c' an the sweep in there. Here the sweep is realized by altering the frequency while running through the look up table. But when a new sweep period starts after one passage I see the same problem of having hard steps as the new sweep starts at 0.
My questions therefor are:
- can I realize the smooth transitions using the API as it is (maybe I overlooked any option or useful command)? As mentioned for me it looks like everything needed is there.
- if not, are there any recommendations or maybe extensions for the API to manage this problem?
Attached are two images that illustrate the 'problem'.
Thanks
Peter
I am still struggling with the DDS Problem. Pavel, thank you for your response!
The aim is to make a frequency sweep or to alter the frequency of a continuous sine wave during operation with smooth transitions between the frequencies. At present I face the problem that the sine wave starts from 0 when I change the frequency and that leads to unwanted steps in the signal that might harm the peripherals.
I tried to realize the sweep with the RP API (please see code below). It is a very simple loop that alters just the frequencies. When I check the signal on the oscilloscope I see the unwanted steps. I checked the source code of the involved functions and I think that basically everything needed for DDS ist there. The sine wave is stored in a look up table and the step size is altered to change the frequency. What is missing is that the code recognizes the actual point in the look up table when the frequency is altered.
I also checked the source code of the example 'generate.c' an the sweep in there. Here the sweep is realized by altering the frequency while running through the look up table. But when a new sweep period starts after one passage I see the same problem of having hard steps as the new sweep starts at 0.
My questions therefor are:
- can I realize the smooth transitions using the API as it is (maybe I overlooked any option or useful command)? As mentioned for me it looks like everything needed is there.
- if not, are there any recommendations or maybe extensions for the API to manage this problem?
Attached are two images that illustrate the 'problem'.
Thanks
Peter
Code: Select all
int main(int argc, char **argv){
/* Print error, if rp_Init() function failed */
if(rp_Init() != RP_OK){
fprintf(stderr, "Rp api init failed!\n");
}
float frequency = 10000.0;
float increment = 5000.0;
/* Generating frequency */
rp_GenFreq(RP_CH_1, frequency);
/* Generating amplitude */
rp_GenAmp(RP_CH_1, 1.0);
/* Generating wave form */
rp_GenWaveform(RP_CH_1, RP_WAVEFORM_SINE);
/* Enable channel */
rp_GenOutEnable(RP_CH_1);
for (; frequency < 40000.0; frequency += increment) {
sleep(1.0/5000.0);
rp_GenFreq(RP_CH_1, frequency);
}
rp_GenOutDisable (RP_CH_1);
You do not have the required permissions to view the files attached to this post.
-
- Posts: 1441
- Joined: Sat Jun 07, 2014 12:49 pm
- Location: Königswinter
Re: Frequency Sweep DDS
Hi,
the problem is that the rp_GenFreq() function of the RP api does much more than just set the frequency. Among other things it resets the generator state machine which is what causes the discontinuities.
You could put something like
into gen_handler.c / gen_handler.h and add an appropriate wrapper to rp.c / rp.h . This would allow you to control the frequency of the generator directly, without any (noticeable) side effects.
the problem is that the rp_GenFreq() function of the RP api does much more than just set the frequency. Among other things it resets the generator state machine which is what causes the discontinuities.
You could put something like
Code: Select all
int gen_onlySetFrequency(rp_channel_t channel, float frequency) {
if (frequency < FREQUENCY_MIN || frequency > FREQUENCY_MAX) {
return RP_EOOR;
}
return generate_setFrequency(channel, frequency);
}
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 61 guests