Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

F-GEN Bug

F-GEN 2.4.0 does not output frequency list when changing output mode from Frequency List to Arb then back to Frequency List again.  The following code (modified version of SweepGenerator example... Amplitude value was als reduced in project UIR and unchanged functions not included because of 10000 character limit) does not work (w/ NI PXI-5441) unless the output mode is switched to Standard Function before selecting Frequency List the second time...
 
========================================================================
 
#include <utility.h>
#include <ansi_c.h>
#include <cvirte.h>     /* Needed if linking in external compiler; harmless otherwise */
#include <userint.h>
#include <stdio.h>
#include <nifgen.h>
#include "SweepGenerator.h"
static int gui;
ViSession vi = VI_NULL;
ViStatus error = VI_SUCCESS;
void generate(void);
void ErrorBox(void);
 
static ViStatus ConfigureOSP (ViSession vi)
{
    ViStatus    error = VI_SUCCESS;
    ViInt32     i, waveformSize, wfmHandle;
    niFgen_ComplexF64   *complex = NULL;
    waveformSize = 1000;
   
    complex = malloc (waveformSize * sizeof (niFgen_ComplexF64));
    for (i=0; i<waveformSize; i++)
    {
        complex[i].real = 1.0;
        complex[i].imaginary = 0.0;
    }
    checkErr( niFgen_ConfigureOutputMode (vi, NIFGEN_VAL_OUTPUT_ARB));
   
    checkErr( niFgen_SetAttributeViBoolean (vi, "", NIFGEN_ATTR_OSP_ENABLED, VI_TRUE));
    checkErr( niFgen_SetAttributeViBoolean (vi, "", NIFGEN_ATTR_OSP_CARRIER_ENABLED, VI_TRUE));
    checkErr( niFgen_SetAttributeViInt32 (vi, "", NIFGEN_ATTR_OSP_DATA_PROCESSING_MODE, NIFGEN_VAL_OSP_COMPLEX));
    checkErr( niFgen_SetAttributeViReal64 (vi, "", NIFGEN_ATTR_OSP_IQ_RATE, 1.0e+6));
    checkErr( niFgen_CreateWaveformComplexF64 (vi, "", waveformSize, complex, &wfmHandle));
Error:
    if (complex != NULL)
        free (complex);
    return error;
}
 
/****************************************************************************\
  This reads all control values and starts waveform generation
\****************************************************************************/
void generate(void) {
    ViChar Resource[256], Channel[256];
    ViReal64 StartFreq, EndFreq, Duration, Amplitude, DCOffset, *frequencies = NULL, *durations = NULL;
    ViReal64 stepsize, dur;
    ViInt32  wfmType, Steps, i, fListHandle;
    /*- Read all clontrol values -------------------------------------------*/
    GetCtrlVal(gui, GUI_RESOURCE, Resource);
    GetCtrlVal(gui, GUI_CHANNEL, Channel);
    GetCtrlVal(gui, GUI_WAVEFORM, &wfmType);
    GetCtrlVal(gui, GUI_START_FREQ, &StartFreq);
    GetCtrlVal(gui, GUI_END_FREQ, &EndFreq);
    GetCtrlVal(gui, GUI_NUM_STEPS, &Steps);
    GetCtrlVal(gui, GUI_DURATION, &Duration);
    GetCtrlVal(gui, GUI_AMPLITUDE, &Amplitude);
    GetCtrlVal(gui, GUI_DC_OFFSET, &DCOffset);
   
    /*- Generate a frequency list to sweep the given frequencies ------------*/
    frequencies = malloc (Steps * sizeof(ViReal64));
    durations = malloc (Steps * sizeof(ViReal64));
    stepsize = (EndFreq - StartFreq) / Steps;
    dur = Duration;
    for(i=0; i<Steps; i++) {
        frequencies[i] = StartFreq + i*stepsize;
        durations[i] = dur;
    }
    if(vi != VI_NULL) niFgen_close(vi);
   
    /*- Initialize the session ---------------------------------------------*/
    checkErr(niFgen_init(Resource, VI_TRUE, VI_TRUE, &vi));
    /*- Configure output mode for frequency list ---------------------------*/
    checkErr(niFgen_ConfigureOutputMode(vi, NIFGEN_VAL_OUTPUT_FREQ_LIST));
    /*- Create the frequency list ------------------------------------------*/
    checkErr(niFgen_CreateFreqList(vi, wfmType, Steps, frequencies,
                                   durations, &fListHandle));
    /*- Select the frequency list to generate ------------------------------*/
    checkErr(niFgen_ConfigureFreqList(vi, Channel, fListHandle, Amplitude,
                                      DCOffset, 0));
    /*- Enable output ------------------------------------------------------*/
    checkErr(niFgen_ConfigureOutputEnabled(vi, Channel, VI_TRUE));
    /*- Generate the frequency list ----------------------------------------*/
    checkErr(niFgen_InitiateGeneration(vi));
    Delay (2.0);
   
    checkErr(niFgen_AbortGeneration(vi));
    checkErr(ConfigureOSP (vi));
    checkErr(niFgen_SetAttributeViReal64 (vi, "0", NIFGEN_ATTR_OSP_CARRIER_FREQUENCY, 100e+3));
    checkErr(niFgen_SetAttributeViReal64 (vi, "0", NIFGEN_ATTR_ARB_GAIN, Amplitude / 2.0));
    checkErr(niFgen_InitiateGeneration(vi));
    Delay (2.0);
    checkErr(niFgen_AbortGeneration(vi));
    //checkErr(niFgen_ConfigureOutputMode(vi, NIFGEN_VAL_OUTPUT_FUNC));
    checkErr(niFgen_ConfigureOutputMode(vi, NIFGEN_VAL_OUTPUT_FREQ_LIST));
    checkErr(niFgen_ConfigureFreqList(vi, Channel, fListHandle, Amplitude, DCOffset, 0));
    checkErr(niFgen_InitiateGeneration(vi));
Error:
    /*- Display any errors -------------------------------------------------*/
    ErrorBox();
    if ((error < 0) && (vi != VI_NULL))
    {
        niFgen_close(vi);
        vi = VI_NULL;
    }
    if (frequencies != NULL)
        free (frequencies);
    if (durations != NULL)
        free (durations);
}
0 Kudos
Message 1 of 6
(7,492 Views)
jtporter,

Thanks for contacting National Instruments.  You mention this is an issue with the 5441.  Does it work with other boards?

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 2 of 6
(7,457 Views)
I only have the PXI-5441... I do not know how this works with other boards.
0 Kudos
Message 3 of 6
(7,448 Views)
jtporter,

We were able to reproduce this issue here and have come up with a workaround.  You should be able to close the session and open a new one instead of reconfiguring output modes.  R&D has been informed of this issue and will determine the best way to handle it for a future release.  Hope this helps, let us know if we can be of anymore help.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 4 of 6
(7,436 Views)
Ok.  I knew about that workaround; reset also works.  But, these options are not acceptable.  I will continue to switch output modes in my application, as this seems to be the least destructive workaround and I will look forward to the next release.
0 Kudos
Message 5 of 6
(7,428 Views)
Hi,
Looks like you were satisfied but I'm curious... why are the new session/reset workarounds unacceptable? I'd like to understand your issues better.

Thanks
Marcos Kirsch


Marcos Kirsch
Chief Software Engineer
NI Driver Software
0 Kudos
Message 6 of 6
(7,362 Views)