Load an arb waveform in agilent 33220a generator in MATLAB-visa with low sampling rate
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have been trying to load an arbitrary waveform in function generator using MATLAB (visa). However, I dont obtain the waveform that I have designed. The code used is given below. I initially tested the code with a simple sine wave of 1Hz. However, the wave generated is of very much higher frequency (of the order of kHz). I suspect it is due to much lower sampling frequency. The 50Mbps sampling rate of the function generator creates a huge amount of data, that cannot be handled by MAtlab. Also, I ultimately want to create a chirp with 1000 sec sweep time. For that, I need to reduce the sampling rate of the generator .Please provide me the commands for the same. The codes I used is given below-
fgen = visa('AGILENT','USB0::0x0957::0x0407::MY44048510::0::INSTR'); set (fgen,'OutputBufferSize',100000); fopen(fgen);
%Query Idendity string and report fprintf (fgen, '*IDN?'); idn = fscanf (fgen); fprintf (idn) fprintf ('\n\n')
%Clear and reset instrument fprintf (fgen, '*RST'); fprintf (fgen, '*CLS');
% Create arb waveform fprintf('Generating Waveform...\n\n')
sRate = 100;
ch = []; for t = 0:1/sRate:10 c = sin(t); y = num2str(c); s5 = sprintf(', %s',y); ch = ch s5; end
%combine all of the strings % s = rise width fall low; s = ch;
% combine string of data with scpi command arbstring =sprintf('DATA VOLATILE %s', s);
%Send Command to set the desired configuration fprintf('Downloading Waveform...\n\n') fprintf(fgen, arbstring); %make instrument wait for data to download before moving on to next %command set fprintf(fgen, '*WAI'); fprintf('Download Complete\n\n')
%Set desired configuration. fprintf(fgen,'VOLT 2'); % set max waveform amplitude to 2 Vpp fprintf(fgen,'VOLT:OFFSET 0'); % set offset to 0 V fprintf(fgen,'OUTPUT:LOAD 50'); % set output load to 50 ohms fprintf(fgen,'FREQ 1'); %set frequency to 1KHz fprintf(fgen,'DATA:COPY TEST16385, VOLATILE'); fprintf(fgen,'FUNC:USER VOLATILE'); fprintf(fgen,'FUNC:SHAP USER');
%Enable Output fprintf(fgen,'OUTPUT ON'); % turn on channel 1 output
% Read Error fprintf(fgen, 'SYST:ERR?'); errorstr = fscanf (fgen);
% error checking if strncmp (errorstr, '+0,"No error"',13) errorcheck = 'Arbitrary waveform generated without any error \n'; fprintf (errorcheck) else errorcheck = ; fprintf (errorcheck) end
%closes the visa session with the function generator fclose(fgen);
I used the following command to reduce the sampling rate- sRate = 100; fprintf(fgen,'SOURCE1:FUNCtion:ARB:SRATe ' num2str(sRate)) The program shows an error at this line
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Waveform Generation 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!