From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Arbitrary Waveform Generation using NI-FGEN 5422 in MATLAB

I'm using the functions 

[WaveformHandle]=invoke(FgenObj.Configurationfunctionsarbitrarywaveformoutput,'createwaveformf64',ChannelName,WaveformSize,WaveformData);
invoke(FgenObj.Configurationfunctionsarbitrarywaveformoutput,'configurearbwaveform',ChannelName,WaveformHandle,Gain,Offset);

 

to create a waveform with the NI-Fgen. My Waveform is just a sine wave of a certain number of samples. I'm confused about what exactly the WaveformSize is supposed to represent. When I make the WaveformSize 10000 samples and the WaveformData a sine wave array with 10000 samples and I view the signal on the scope with 50000 samples the waveform spans all 50000 samples. When I decrease the WaveformSize to 1000 samples and likewise with the WaveformData array I suddenly don't get a clean sine wave, but the signal still spans all 50000 samples. How can I make a sine wave that spans 10000 samples? Should I be using a user defined standard waveform as opposed to an arbitrary waveform? Also here is what I'm using to configure the scope.

 

SampleRate=2E+6;

NumSamples=50000;

TimeOut = NumSamples/SampleRate;
RefPosition=0;
NumRecords=1;
EnforceRealTime=1;

Range = 60;
Offset = 0;
Coupling = 1;
ProbeAttenuation = 10;

channelList = '1';

 

invoke(ScopeObj.Configurationfunctionsvertical, 'configurevertical', '1', Range, Offset, Coupling, ProbeAttenuation, true);
invoke(ScopeObj.Configurationfunctionshorizontal,'configurehorizontaltiming',SampleRate,NumSamples,RefPosition,NumRecords,EnforceRealTime);

invoke(ScopeObj.Acquisition, 'initiateacquisition');
[waveformArray, waveformInfo] = invoke(ScopeObj.Acquisition, 'fetch', channelList,TimeOut, NumSamples, waveformArray, waveformInfo);

 

I'm new to using MATLAB for this purpose to there may be some simple mistake I'm unaware of

0 Kudos
Message 1 of 1
(881 Views)