function [] = TDS2KWaveotoRef( wave ) %2KWaveotoRef Sends a 2.5K lenght array to the TDS2K reference waveform if length(wave) ~= 2500 display(['Wrong lenght of array, cannot send to scope. Must be 2.5K points']) return end % Connect to instrument and print its ID delete (instrfindall); vinfo = instrhwinfo('visa', 'NI', 'USB'); scope = str2num(char(vinfo.ObjectConstructorName)); set(scope, 'InputBufferSize', 5000) set(scope, 'OutputBufferSize', 5000) fopen( scope ); query(scope, '*IDN?') %get info for vertical scaling values on scope % max of range is *2 since it goes +/- from center of graticule fwrite(scope, 'DATA:SOU REFA'); low = min(wave); high = max(wave); vrange = abs((low - high)); if vrange < abs(low) maxvalue = abs(low*2); elseif vrange < abs(high) maxvalue = abs(high*2); else maxvalue = abs(vrange*2); end %Set the verticale scale appropriately for the reference waveform %Ymult value = volt/div * 10.25 / 256 if maxvalue >= 20 % 5v/div Ymult = 0.2; elseif maxvalue >= 10 %2V/div Ymult = .08; elseif maxvalue >= 5 %1V/div Ymult = .04; elseif maxvalue >= 2 %.5V/div Ymult = .02; elseif maxvalue >= 1 %.2V/div Ymult = .008; elseif maxvalue >= .5 %.1V/div Ymult = .004; elseif maxvalue >= .2 %.05V/div Ymult = .002; elseif maxvalue >= .1 %.02V/div Ymult = .0008; elseif maxvalue >= .05 %.01V/div Ymult = .0004; elseif maxvalue >= .02 %.005V/div Ymult = .0002; else Ymult = .00008; %.002V/div end fwrite(scope, ['WFMPRE:YMULT ', num2str(Ymult)]); % get waveform scaling values to convert wave to curvedata Yoff = str2num(query(scope, 'WFMPRE:YOFF?')); Yzero = str2num(query(scope, 'WFMPRE:YZERO?')); Ymult = str2num(query(scope, 'WFMPRE:YMULT?')); %scale the array curvedata = (wave - Yzero)./ Ymult + Yoff; fwrite(scope, 'WFMPRE:BN_F RP'); fwrite(scope, 'WFMPRE:BYT_N 1'); fwrite(scope, 'WFMPRE:BYT_O LSB'); binblockwrite(scope, curvedata, 'curve '); fwrite(scope, 'SEL:REF1 ON'); fclose(scope); display(['Done']); end