You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.7KB

  1. classdef Oscilloscope < Equipment
  2. %OSCILLOSCOPE Summary of this class goes here
  3. % Detailed explanation goes here
  4. properties
  5. nchannels
  6. horizontalPosition
  7. timescale
  8. ch1
  9. ch2
  10. ch3
  11. ch4
  12. trigger
  13. acquisition
  14. end
  15. methods
  16. function sc = Oscilloscope(ipAddress,port,nchannels)
  17. %OSCILLOSCOPE Construct an instance of this class
  18. % Detailed explanation goes here
  19. sc@Equipment(ipAddress,port,-1);
  20. sc.trigger = Trigger(sc);
  21. for i = 1:nchannels
  22. sc.(['ch',num2str(i)]) = Channel(sc,i);
  23. end
  24. end
  25. function s = get.acquisition(sc)
  26. s = sc.query('ACQ:STAT?');
  27. end
  28. function run(sc)
  29. sc.write('RUN');
  30. end
  31. function single(sc)
  32. sc.write('SING');
  33. end
  34. function stop(sc)
  35. sc.write('STOP');
  36. end
  37. function auto(sc)
  38. sc.write_noerror('AUT');
  39. end
  40. function enable_channels(sc)
  41. for i = 1:sc.nchannels
  42. sc.(['ch',num2str(i)]).state = 'ON';
  43. end
  44. end
  45. function disable_channels(sc)
  46. for i = 1:sc.nchannels
  47. sc.(['ch',num2str(i)]).state = 'OFF';
  48. end
  49. end
  50. function setMeasurement(sc,measurement,type,source1,source2)
  51. prefix = ['MEAS',num2str(measurement),':'];
  52. fprintf(num2str(nargin))
  53. if nargin < 5
  54. source2 = 'CH2';
  55. if nargin < 4
  56. source1 = 'CH1';
  57. end
  58. end
  59. source = [source1,', ',source2];
  60. sc.write([prefix,'SOUR ',source]);
  61. sc.write([prefix,'MAIN ',type]);
  62. end
  63. function m = getMeasurement(sc,measurement)
  64. m = sc.query(['MEAS',num2str(measurement),':RES:ACT?']);
  65. end
  66. % function data = waveform(ch,cha)
  67. % ch.scope.clear;
  68. % ch.scope.write('CHAN1:TYPE HRES');
  69. % ch.scope.write('FORM REAL');
  70. % ch.scope.write('FORM:BORD MSBF');
  71. % ch.scope.write('CHAN1:DATA:POIN DEF');
  72. % ch.scope.write('SING');
  73. % header = str2num(ch.scope.query('CHAN1:DATA:HEAD?'));
  74. % ch.scope.write_unsafe('CHAN1:DATA?');
  75. % prefixstring = fscanf(ch.scope.tcp,'%c',2);
  76. % prefixlength = str2double(prefixstring(2));
  77. % datalength = fscanf(ch.scope.tcp,'%c',prefixlength);
  78. % data = fread(ch.scope.tcp,header(3),'float');
  79. % flushinput(ch.scope.tcp);
  80. % end
  81. end
  82. end