commit a869efc299ea5f3ebc18522587bb708e2338e3a5 Author: Wouter Horlings Date: Thu Oct 6 16:11:41 2016 +0200 initial commit, 4 scripts to: start, stop connection; read error; set waveform diff --git a/Equipment/prologix_connect.m b/Equipment/prologix_connect.m new file mode 100644 index 0000000..9b982cd --- /dev/null +++ b/Equipment/prologix_connect.m @@ -0,0 +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 + diff --git a/Equipment/prologix_disconnect.m b/Equipment/prologix_disconnect.m new file mode 100644 index 0000000..b8a274c --- /dev/null +++ b/Equipment/prologix_disconnect.m @@ -0,0 +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 + diff --git a/Equipment/prologix_error.m b/Equipment/prologix_error.m new file mode 100644 index 0000000..fb769d8 --- /dev/null +++ b/Equipment/prologix_error.m @@ -0,0 +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 + diff --git a/Equipment/prologix_function_generator_waveform.m b/Equipment/prologix_function_generator_waveform.m new file mode 100644 index 0000000..447736b --- /dev/null +++ b/Equipment/prologix_function_generator_waveform.m @@ -0,0 +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 +