現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)
