problem writing data to a function generator using GUI.
古いコメントを表示
Hi everyone,
I wrote a GUI code that transfers an arbitrary waveform to a function generator. I use a slider button to change\select the amplitude of the waveform in real time. My problem is, that each time I touch the slider button, the (waveform) signal "jumps" for a short moment (I think to zero - it happens very fast) and only then changes to the selected value(confirmed it by conneting the function generator to a scope). It drives my laser crazy. How can I solve this problem? I think it may be related to the period of time in which the function generator reads the waveform data.
function CONST_Amp_Callback(hObject, eventdata, handles) %Set pulse amplitude
AM_Vpp= [-2.5 0]; %low and high voltages
n=16348; %temporal resolution (dont change)
ignition_pulse_amplitude = 1; % fraction of full power
DAC_max=16383;
waveform=zeros(1,n);
waveform(1:ignition_pulse_end_ind)=DAC_max.*ignition_pulse_amplitude;
waveform(ignition_pulse_end_ind+1:full_pulse_end_ind)=DAC_max.*lasing_pulse_amplitude;
handles.time = time;
handles.waveform = waveform;
if handles.DG1000Z.Value == 1
DG1000Z_device = instrfind('Type', 'visa-usb', 'RsrcName', 'USB0::0x1AB1::0x0642::DG1ZA171301033::0::INSTR', 'Tag', '');
% Create the VISA-USB object if it does not exist
% otherwise use the object that was found.
if isempty(DG1000Z_device)
DG1000Z_device = visa('NI', 'USB0::0x1AB1::0x0642::DG1ZA171301033::0::INSTR'); %Create VISA object
%% USB VISA descriptor can be checked using ULTRA software
else
fclose(DG1000Z_device);
DG1000Z_device = DG1000Z_device(1);
end
WF_STR='DATA:DAC VOLATILE,'; %Digital to analog convertor
for i=1:length(waveform)-1
WF_STR=[WF_STR num2str(waveform(i)) ','];
end
WF_STR=[WF_STR num2str(waveform(end))];
set(DG1000Z_device,'OutputBufferSize',length(WF_STR) + 40);
fopen(DG1000Z_device);
fprintf(DG1000Z_device,[':SOUR1:APPL:ARB ' num2str(n.*pulse_rep_rate) ] ); %Set the waveform of CH1 to ARB (arbitrary waveform)...
fprintf(DG1000Z_device,'VOLT:UNIT VPP');
fprintf(DG1000Z_device,['VOLT:HIGH ' num2str(AM_Vpp(2))]);
fprintf(DG1000Z_device,['VOLT:LOW ' num2str(AM_Vpp(1))]);
fprintf(DG1000Z_device,WF_STR);
fprintf(DG1000Z_device,':OUTP1 ON'); %Turn on the output of CH1 of the function generator
fclose(DG1000Z_device);
end
Thanks for helping!!
2 件のコメント
Jan
2019 年 1 月 29 日
Without seeing any details of your implementation, how could we suggest a modification? There is no magic "do not cause jumps" switch in Matlab.
Katherine Akulov
2019 年 1 月 30 日
編集済み: Jan
2019 年 1 月 30 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Waveform Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!