Listing 2. Code for Measuring Response of Servomotor
% this is minimal file for dlxrun.
% it measures the position response to a voltage
% step input.
begin constant defs
volts
end
%
begin constant code
volts = 6.0;
limit_volts[LOW] = -24.0;
limit_volts[HIGH] = 24.0;
end
%
begin control defs
voltage
end
%
begin output defs
position
end
%
begin output translation code
position = RADIANS_PER_COUNT * get_encoder();
end
%
begin control algorithm
voltage = volts;
end
%
begin controller conversion code
double scale; /* genuine local variable */
scale = voltage/24.0; /* saturate the value
if off scale */
scale = (scale > 1.0) ? 1.0 : ((scale < -1.0)
? -1.0 : scale);
set_dac( 128 + scale*127 );
end
%
begin init code
% and finally set the usual runtine parameters:
T_INIT = 0.0;
T_FINAL = 0.2;
SAMPLE_INTERVAL = .001;
N_STEPS = 20000;
end
%
begin utility defs
#include "/usr/local/lib/dlxlab/mpi.h"
#define RADIANS_PER_COUNT (2.0 * 3.1415926
/ 3600.0)
end
%
begin utility code
#include "/usr/local/lib/dlxlab/omnitech.h
end
Copyright © 1994 - 2018 Linux Journal. All rights reserved.