Posted By

panopticon on 07/13/10


Tagged

dump binary systems research Stanford SRS SR 620 SR620


Versions (?)

SR620 Code


 / Published in: MatLab
 

These are two functions I wrote in MATLAB to perform the binary dump readout. There is little documentation on this outside of the manual, but I finally got it to work today. There are some superfluous bits to this code, but the essentials are there.

  1. -----------sr620_avar.m
  2.  
  3. function sr620_avar(samples, minTau)
  4.  
  5. sr620obj = gpib('agilent',7,14);
  6. fclose(sr620obj);
  7. sr620obj.InputBufferSize = 8*samples+1;
  8. fopen(sr620obj);
  9.  
  10. fprintf(sr620obj, '*IDN?');
  11.  
  12. out = fscanf(sr620obj);
  13.  
  14. out
  15.  
  16. fprintf(sr620obj, 'MODE 3');
  17.  
  18. fprintf(sr620obj, 'SRCE 2');
  19.  
  20. fprintf(sr620obj, 'SIZE?');
  21.  
  22. size = fscanf(sr620obj)
  23.  
  24. fprintf(sr620obj, 'GATE 1E-3');
  25.  
  26. sr620obj.Timeout = 20;
  27. get(sr620obj,{'EOSMode','EOIMode'})
  28. %fprintf(sr620obj, 'SIZE 65000');
  29.  
  30. fprintf(sr620obj, 'BDMP%d', samples);
  31. %fprintf(sr620obj, 'UNT UNL MLA TALK 14');
  32. %fprintf(sr620obj, 'MEAS? 0');
  33.  
  34. binData = fread(sr620obj, 4*samples, 'short');
  35.  
  36. %binData = fscanf(sr620obj);
  37. sr620convert(1,1,binData,samples)
  38.  
  39.  
  40.  
  41. fclose(sr620obj);
  42. end
  43.  
  44.  
  45. ---------- sr620convert.m
  46.  
  47. function out = sr620convert(mode, expd, data, samples)
  48.  
  49. for i=1:1:samples
  50. sign = 0;
  51. fdata(i) = 0;
  52. for j=1:1:4
  53. words(j) = data(4*(i-1)+j);
  54. end
  55. if words(4) < 0
  56. sign = 1;
  57. for j=1:4
  58. words(j) = bitcmp(words(j));
  59. end
  60. end
  61. for j = 1:4
  62. fdata(i) = fdata(i)*65536.0 + words(5-j);
  63. end
  64.  
  65.  
  66. if fdata(i) == -1*abs(fdata(i))
  67. fdata(i) = fdata(i) + 1;
  68. fdata(i) = fdata(i)*-1;
  69. end
  70. fdata(i) = fdata(i)*1.24900090270331e-9;
  71. end
  72. out = fdata;
  73. end

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: panopticon on July 13, 2010

The convert file converts the binary words into proper frequency values. The instrument is capable of other modes, so the conversion factor would change, but right now the factor of 1.249e-9 is for the frequency conversion. The conversion code I tried to convert from the C code in the manual into MATLAB and it appears to work.

Most of the commented-out lines can be removed -- this is a very crudely written file, but it has the essentials captured in the "fread" command and the sr620convert.m routine.

You need to login to post a comment.