Преглед изворни кода

initial commit, 4 scripts to: start, stop connection; read error; set waveform

keep-around/c5216e76cad262723738e350daf9fd25abbc8ea7
Wouter Horlings пре 9 година
комит
a869efc299
4 измењених фајлова са 91 додато и 0 уклоњено
  1. +19
    -0
      Equipment/prologix_connect.m
  2. +11
    -0
      Equipment/prologix_disconnect.m
  3. +11
    -0
      Equipment/prologix_error.m
  4. +50
    -0
      Equipment/prologix_function_generator_waveform.m

+ 19
- 0
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


+ 11
- 0
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


+ 11
- 0
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


+ 50
- 0
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


Loading…
Откажи
Сачувај