| @@ -1,19 +1,19 @@ | |||||
| function [ t,version ] = prologix_connect(ipAddress,port) | |||||
| %PROLOGIX_CONNECT open TCP/IP connection with Prologix Ethernet GPIB | |||||
| %converter | |||||
| % Detailed explanation goes here | |||||
| if nargin < 2 | |||||
| port = 1234; | |||||
| if nargin < 1 | |||||
| ipAddress = '10.0.0.2'; | |||||
| end | |||||
| end | |||||
| echotcpip('on', port); | |||||
| t = tcpip(ipAddress,port); | |||||
| fopen(t); | |||||
| fprintf(t, '++mode 1'); | |||||
| fprintf(t, '++auto 0'); | |||||
| fprintf(t, '++ver'); | |||||
| version = ['Firmware Version: ', fscanf(t)]; | |||||
| end | |||||
| function [ t,version ] = prologix_connect(ipAddress,port) | |||||
| %PROLOGIX_CONNECT open TCP/IP connection with Prologix Ethernet GPIB | |||||
| %converter | |||||
| % Detailed explanation goes here | |||||
| if nargin < 2 | |||||
| port = 1234; | |||||
| if nargin < 1 | |||||
| ipAddress = '10.0.0.2'; | |||||
| end | |||||
| end | |||||
| echotcpip('on', port); | |||||
| t = tcpip(ipAddress,port); | |||||
| fopen(t); | |||||
| fprintf(t, '++mode 1'); | |||||
| fprintf(t, '++auto 0'); | |||||
| fprintf(t, '++ver'); | |||||
| version = ['Firmware Version: ', fscanf(t)]; | |||||
| end | |||||
| @@ -1,11 +1,11 @@ | |||||
| function prologix_disconnect( prologix_connection ) | |||||
| %PROLOGIX_DISCONNECT Summary of this function goes here | |||||
| % Detailed explanation goes here | |||||
| echotcpip('off'); | |||||
| if nargin == 1 | |||||
| fprintf(prologix_connection,'++loc'); | |||||
| fclose(prologix_connection); | |||||
| delete(prologix_connection); | |||||
| end | |||||
| end | |||||
| function prologix_disconnect( prologix_connection ) | |||||
| %PROLOGIX_DISCONNECT Summary of this function goes here | |||||
| % Detailed explanation goes here | |||||
| echotcpip('off'); | |||||
| if nargin == 1 | |||||
| fprintf(prologix_connection,'++loc'); | |||||
| fclose(prologix_connection); | |||||
| delete(prologix_connection); | |||||
| end | |||||
| end | |||||
| @@ -1,11 +1,11 @@ | |||||
| function error = prologix_error(addr) | |||||
| %PROLOGIX_ERROR Summary of this function goes here | |||||
| % Detailed explanation goes here | |||||
| t = prologix_connect(); | |||||
| fprintf(t, ['++addr ', num2str(addr)]); | |||||
| fprintf(t, 'system:error?'); | |||||
| fprintf(t, '++read'); | |||||
| error = fscanf(t); | |||||
| prologix_disconnect(t); | |||||
| end | |||||
| function error = prologix_error(addr) | |||||
| %PROLOGIX_ERROR Summary of this function goes here | |||||
| % Detailed explanation goes here | |||||
| t = prologix_connect(); | |||||
| fprintf(t, ['++addr ', num2str(addr)]); | |||||
| fprintf(t, 'system:error?'); | |||||
| fprintf(t, '++read'); | |||||
| error = fscanf(t); | |||||
| prologix_disconnect(t); | |||||
| end | |||||
| @@ -1,50 +1,50 @@ | |||||
| function prologix_function_generator_waveform(waveform,frequency,amplitude,offset,ipAddress,port) | |||||
| %PROLOGIX_FUNCTION_GENERATOR Summary of this function goes here | |||||
| % Detailed explanation goes here | |||||
| %% test for valid input data | |||||
| if nargin < 4 | |||||
| offset = 0; | |||||
| end | |||||
| switch waveform | |||||
| case {1,'s','sin','sinus','sinusoid'} | |||||
| waveform = 'sinusoid'; | |||||
| case {2,'S','sq', 'square'} | |||||
| waveform = 'square'; | |||||
| case {3,'t','triangle'} | |||||
| waveform = 'triangle'; | |||||
| case {4,'r','ramp'} | |||||
| waveform = 'ramp'; | |||||
| otherwise | |||||
| error('waveform is not correctly defined'); | |||||
| end | |||||
| switch waveform | |||||
| case {'square','sinusoid'} | |||||
| if (1e-04 > frequency) || (frequency > 1.5e07) | |||||
| error(['frequency is out of range for ',waveform,' waveform (100uHz - 15MHz)']); | |||||
| end | |||||
| case {'triangle','ramp'} | |||||
| if (1e-04 > frequency) || (frequency > 1e05) | |||||
| error(['frequency is out of range for ',waveform,' waveform (100uHz - 100kHz)']); | |||||
| end | |||||
| end | |||||
| %% start connection with prologix | |||||
| if nargin < 5 | |||||
| t = prologix_connect(); | |||||
| elseif nargin < 6 | |||||
| t = prologix_connect(ipAddress); | |||||
| else | |||||
| t = prologix_connect(ipAddress,port); | |||||
| end | |||||
| %% | |||||
| fprintf(t,'++addr 10'); | |||||
| fprintf(t, ['apply:',waveform,' ',num2str(frequency),',',num2str(amplitude),',',num2str(offset)]); | |||||
| prologix_disconnect(t); | |||||
| end | |||||
| function prologix_function_generator_waveform(waveform,frequency,amplitude,offset,ipAddress,port) | |||||
| %PROLOGIX_FUNCTION_GENERATOR Summary of this function goes here | |||||
| % Detailed explanation goes here | |||||
| %% test for valid input data | |||||
| if nargin < 4 | |||||
| offset = 0; | |||||
| end | |||||
| switch waveform | |||||
| case {1,'s','sin','sinus','sinusoid'} | |||||
| waveform = 'sinusoid'; | |||||
| case {2,'S','sq', 'square'} | |||||
| waveform = 'square'; | |||||
| case {3,'t','triangle'} | |||||
| waveform = 'triangle'; | |||||
| case {4,'r','ramp'} | |||||
| waveform = 'ramp'; | |||||
| otherwise | |||||
| error('waveform is not correctly defined'); | |||||
| end | |||||
| switch waveform | |||||
| case {'square','sinusoid'} | |||||
| if (1e-04 > frequency) || (frequency > 1.5e07) | |||||
| error(['frequency is out of range for ',waveform,' waveform (100uHz - 15MHz)']); | |||||
| end | |||||
| case {'triangle','ramp'} | |||||
| if (1e-04 > frequency) || (frequency > 1e05) | |||||
| error(['frequency is out of range for ',waveform,' waveform (100uHz - 100kHz)']); | |||||
| end | |||||
| end | |||||
| %% start connection with prologix | |||||
| if nargin < 5 | |||||
| t = prologix_connect(); | |||||
| elseif nargin < 6 | |||||
| t = prologix_connect(ipAddress); | |||||
| else | |||||
| t = prologix_connect(ipAddress,port); | |||||
| end | |||||
| %% | |||||
| fprintf(t,'++addr 10'); | |||||
| fprintf(t, ['apply:',waveform,' ',num2str(frequency),',',num2str(amplitude),',',num2str(offset)]); | |||||
| prologix_disconnect(t); | |||||
| end | |||||
| @@ -1,23 +0,0 @@ | |||||
| local_port = randi([49152 65535]); | |||||
| remote_port = 3040; | |||||
| hudpr = dsp.UDPReceiver('LocalIPPort',local_port); | |||||
| hudps = dsp.UDPSender('RemoteIPAddress','255.255.255.255','RemoteIPPort',remote_port,'LocalIPPortSource','Property','LocalIPPort',local_port); | |||||
| setup(hudpr); | |||||
| %['5a' '00' '5b' 'db' 'ff' 'ff' 'ff' 'ff' 'ff' 'ff' '00' '00']); | |||||
| % | |||||
| step(hudps,uint8([90 0 91 219 255 255 255 255 255 255 00 00])); | |||||
| for i = 1:10 | |||||
| pause(1); | |||||
| msg = step(hudpr); | |||||
| if numel(msg)>0 | |||||
| break; | |||||
| end | |||||
| end | |||||
| if numel(msg)==0 | |||||
| error('No prologix found on network'); | |||||
| end | |||||
| ipaddress = join(num2str(msg(21:25)),'.'); | |||||
| release(hudps); | |||||
| release(hudpr); | |||||