Generating two different frequencies with NI-DAQ 6251 Analog output
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponse acceptée
Walter Roberson
le 9 Nov 2011
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Call Web Services from MATLAB Using HTTP dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!