diff --git a/Equipment/prologix_connect.m b/Equipment/prologix_connect.m index 9b982cd..eb47c0e 100644 --- a/Equipment/prologix_connect.m +++ b/Equipment/prologix_connect.m @@ -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 + diff --git a/Equipment/prologix_disconnect.m b/Equipment/prologix_disconnect.m index b8a274c..7025373 100644 --- a/Equipment/prologix_disconnect.m +++ b/Equipment/prologix_disconnect.m @@ -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 + diff --git a/Equipment/prologix_error.m b/Equipment/prologix_error.m index fb769d8..4b7e430 100644 --- a/Equipment/prologix_error.m +++ b/Equipment/prologix_error.m @@ -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 + diff --git a/Equipment/prologix_function_generator_waveform.m b/Equipment/prologix_function_generator_waveform.m index 447736b..79adc58 100644 --- a/Equipment/prologix_function_generator_waveform.m +++ b/Equipment/prologix_function_generator_waveform.m @@ -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 + diff --git a/Prologix_discovery.m b/Prologix_discovery.m deleted file mode 100644 index a720f0c..0000000 --- a/Prologix_discovery.m +++ /dev/null @@ -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); \ No newline at end of file