필터 지우기
필터 지우기

Generating two different frequencies with NI-DAQ 6251 Analog output

조회 수: 2 (최근 30일)
Hi,
I want to use my DAQ as a function generator to generate two different frequencies continuously. A simple code like
ao= analogoutput(adaptor, deviceId);
addchannel(ao, 0:1);
nsample1 = freq1/sampling_rate
nsample2 = freq2/sampling_rate
wave1 = sin(linspace(0,2*pi,nsample1));
wave2 = sin(linspace(0,2*pi,nsample2));
set(ao,'RepeatOutput',inf);
putdata(ao,[wave1' wave2']);
won't work because [wave1' wave2'] are of different lengths. I can't pad any data to the end of the shorter wave because if the two frequencies are relatively prime, one of the would not be periodic.
Is there anyway around this?
Thanks!

채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 9일
You are not required to output to both channels simultaneously. If the job works better by separating the channels, do so. This might cause a lag between the two. If the lag gets to be too much, then adopt another method.
You can use lcm (Lowest Common Multiple) to determine how many of each side you need you would need to queue so that the queue would have full cycles for both waves.
  댓글 수: 2
signal
signal 2011년 11월 9일
Walter, thanks for your response!
The lcm method should work very well as long as the number of samples required is not larger than the onboard memory on the DAQ, I should test this.
Regarding your first suggestion, can you elaborate more? are you suggesting that I should define two separate analog outputs like
ao1 = analogoutput(adaptor, deviceId); addchannel(ao1, 0);
ao2 = analogoutput(adaptor, deviceId); addchannel(ao2, 1);
and queue them independently?
Walter Roberson
Walter Roberson 2011년 11월 9일
I think the latter should be possible, but I do not know for sure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by