이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Communication with Standford Research Syteme DG535 Digital Delay/Pulse Generator
조회 수: 16 (최근 30일)
이전 댓글 표시
Dear All,
Has anyone ever controlled a Stanford Research Systems Model DG535 via Matlab? I'am in desperate need to remotely control the DG535 with Matlab but I have no chance to build a connection between them. In the manual it seems easy, but somehow the connection with the GPIB and Matlab does not work properly.
Maybe there is someone in the community who has already connected a DG535 with Matlab? Any help would be much appreciated.
Thanks
댓글 수: 10
ProblemSolver
2023년 6월 29일
Could you share so far what you have done. So that we can see where you are facing the problem.
René Lampert
2023년 6월 29일
I have done what I always do when I want to control a device with Matlab. I have written a class in which the serial communication is established in the constructor - see code below
I use exactly the same code for several devices like oscillosopes, spectra analyzer etc. and it works perfectly. I always us the serial object (which forever reason is not recommended from Matlab). For GPIB there is "visadev" but it is poorly explained how it works .
Like:
classdef ModelDG535 < handle
properties
comPort % COM port (string), e.g. 'COM11'
baudRate % BaudRate, e.g. 19200
terminator % Terminator (string), e.g. 'CR/LF'
parity % Parity (string),e.g. 'none'
dataBits % dataBits, e.g. 8
stopBits % stopBits, e.g. 0
InputBufferSize % inputbuffersize, e.g. 8*20001
Timeout % in seconds
ls % serial object
end
methods
%Mit dieser Funktion wird das Objekt erstellt.
function this = ModelDG535(comPort)
this.comPort = comPort;
this.baudRate = 9600;
this.terminator = 'CR/LF';
this.parity = 'even';
this.dataBits = 8;
this.stopBits = 1;
this.InputBufferSize = 10*20001;
this.Timeout = 7 ;
%OSA=serial(comStr,'Terminator', 'CR/LF','InputBufferSize', 10*20001,...
%'timeout',5);
this.ls = serial(comPort) % make connection serial
set(this.ls,'BaudRate',this.baudRate);
set(this.ls,'Terminator',this.terminator);
set(this.ls,'Parity',this.parity);
set(this.ls,'DataBits',this.dataBits);
set(this.ls,'StopBits',this.stopBits);
set(this.ls,'InputBufferSize',this.InputBufferSize);
set(this.ls,'Timeout',this.Timeout);
fopen(this.ls);
fprintf(this.ls, '++addr 15'); % GPIB address 15
fprintf(this.ls, '++mode 1'); % Configure as Controller (++mode 1) fprintf(this.ls, '++addr 15'); % GPIB Address 15
query(this.ls,'*IDN?')
flushinput(this.ls);
end
end
end
ProblemSolver
2023년 6월 29일
편집: ProblemSolver
2023년 6월 29일
@René Lampert: If you are already providing the serial port = COM11 in your code, then why are you sending the command again
fprintf(this.ls, '++addr 15');
I don't have access to the instrument with me currently , so I am not able to try and help you accurately, but I would comment this line, and see if it works?
Also I see that you haven't a destructor function for the object that you opened. That is also necessary as if you rerun the program you might still have previous connection active, therefore add something in the end like this:
fclose(this.ls);
I hope this helps!
René Lampert
2023년 6월 29일
I already did this and it does not help unfortunately. Serial communication in Matlab is a mess...
Do you have the same instrument ?
ProblemSolver
2023년 6월 29일
편집: ProblemSolver
2023년 6월 29일
Not the same, I use DG645 - Low jitter delay generator, but I had it connected with NI LabVIEW. and I alternate between RS232 and Ethernet, when it provides me with troubles.
I thing I forgot to mention is that you have you have activate the configuration. What I have to do when I am using DG645, for RS232 I have to press SHIFT and RS232 to activate the mode. So you should also check that.
The other way you can try is. just try to operate directly from Command Window. Using VISA something like this:
>> DG535object = visa('name of the device', GPIBaddress);
%then open the connect using fopen
>> fopen(DG535object);
% then just send one of the commands
>> fprintf(this.ls, '++mode 1');
and see if this works?
OR run this to check if you are getting any errors:
DG535object = serial('COM11','BaudRate',19200,'Parity','even', ...
'DataBits',8,'FlowControl','none');
if isempty(DG535object) % please simply test this
errordlg(...)
return;
end
René Lampert
2023년 6월 29일
the return command in your last code block is not valid - and what is s_port ?
the visa method was also not succesfsul, i always get the error "The specified VENDOR adaptor could not be found" . I'm completely confused with this visa method and how this should work, do I need special drivers for the used GPIB module?
ProblemSolver
2023년 6월 29일
That block was invalid because the variable name in the parantheses was suppose to be DG535object. Then it will not give an invalid command.
All you need is Instrument Control ToolBox.
René Lampert
2023년 6월 29일
I do have the Instrument Control ToolBox, but it is still not valid and says that return is illegal ...
René Lampert
2023년 6월 29일
I tried it again with the visa method
serialdev = visadev("COM6");
then I used
writeline(serialdev,'CL')
to test the communication ( "CL" is the command to clear the instrument according to the manual and set the instrument to default settings). The LED on th instrument REM (remote) turns to green but at the dispaly ist says "Bad Command", unfortunately there is no decription in the manual what this actually means. But something has been communicated ....
René Lampert
2023년 7월 3일
Now it works ! The problem was that the manual was wrong with the commands. For instannce, the command 'CL' had to be written as 'C L', so there must be a space bewteen every character. I am not sure why this is the case and why there is nothing about it in the manual, but at least it works now.
Thanks
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Instrument Control Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
