%For download to atmel/DAC waveform generator %MODIFIED to make printing CHARS ONLY format compact clear all startflag =0 %required for read synch samplerate = 40 %in 0.25 microsec ticks numwaves = 250 %number of repeats wavespace = 20 %in 5 mSec ticks %convert to ascii printable chars for transmission sthi = fix(samplerate/16)+32 stlo = samplerate-fix(samplerate/16)*16+32 nuhi = fix(numwaves/16)+32 nulo = numwaves-fix(numwaves/16)*16+32 wvhi = fix(wavespace/16)+32 wvlo = wavespace-fix(wavespace/16)*16+32 x = 0:1:255 ; a = fix(128 + 60*sin(2*pi*x/128) .* (1-cos(2*pi*x/256))) ; %test waveform nibble = 1:1:512; j=1; %convert the 8-bit to 2 four-bit nibbles and add 32 to make printable chars for i=1:2:511 ; nibble(i) = fix(a(j)/16) + 32; nibble(i+1) = a(j) - fix(a(j)/16)*16 + 32; j=j+1; end param = [startflag, sthi, stlo, nuhi, nulo, wvhi, wvlo ] output = [ param, nibble]; fileid = fopen ('f:\232eod7.txt', 'w') count = fwrite (fileid, output, 'uint8') status = fclose (fileid)