Commit 32bd1a66 authored by Jan-Gerrit Richter's avatar Jan-Gerrit Richter

changes for new continuous arc in old ita

parent 8fc62359
......@@ -122,6 +122,7 @@ classdef itaMotorControlNanotec < itaMotorControl
pause(this.waitForSerialPort);
end
end
function moveTo(this,varargin)
% if itaCoordinates are given, the position is passed to all
......@@ -178,6 +179,13 @@ classdef itaMotorControlNanotec < itaMotorControl
end
function freeFromStopButton(this)
for index = 1:length(this.motorList)
this.motorList{index}.freeFromStopButton();
end
end
function reference(this)
this.clear_commandlist;
for index = 1:length(this.motorList)
......@@ -212,12 +220,14 @@ classdef itaMotorControlNanotec < itaMotorControl
% first, do a reference move
ita_verbose_info('Moving to reference',1)
this.reference
ita_verbose_info('Disable reference position',1)
this.motorList{1}.disableReference(1);
ita_verbose_info('Moving to pre angle',1)
this.moveTo(motorName,-sArgs.preAngle,'absolut',false,'speed',1)
this.moveTo(motorName,-sArgs.preAngle,'absolut',false,'speed',2)
% now prepare the big move but don't start it
this.moveTo(motorName,360+sArgs.preAngle+15,'speed',sArgs.speed,'absolut',false,'start',0,'limit',0);
this.moveTo(motorName,360-35,'speed',sArgs.speed,'absolut',true,'start',0,'limit',0);
this.preparedList = motorName;
ita_verbose_info('Finished preparing',2)
end
......@@ -246,6 +256,8 @@ classdef itaMotorControlNanotec < itaMotorControl
end
this.wait4everything
this.preparedList = [];
ita_verbose_info('Enable reference position',1)
% this.sendControlSequenceAndPrintResults(':port_in_a=7');
end
function success = add_to_commandlist(this, string_to_send)
......@@ -456,7 +468,11 @@ classdef itaMotorControlNanotec < itaMotorControl
ita_verbose_info('Position reached',1);
else
ita_verbose_info('Position NOT reached! - Check for errors!', 0);
this.send_commandlist(this.failed_command_repititions); % mpo: bugfix: send_commandlist needs argument
%assuming stop button clicked
%call freefrombutton function
% this.freeFromStopButton
% this.send_commandlist(this.failed_command_repititions); % mpo: bugfix: send_commandlist needs argument
% this.isReferenced = false;
end
this.clear_receivedlist;
......
......@@ -29,7 +29,8 @@ classdef itaMotorNanotec < itaHandle
% basic moves: requires execution to halt while something is moving
this = moveToReferencePosition(this);
this = startMoveToPosition(this);
disableReference(this,value);
% this = freeFromStopButton(this);
ret = prepareMove(this,position,varargin);
end
end
\ No newline at end of file
......@@ -81,6 +81,10 @@ classdef itaMotorNanotec_Arm < itaMotorNanotec
name = this.motorName;
end
function disableReference(this,value)
end
function sendConfiguration(this)
motorControl = this.mMotorControl;
motorControl.add_to_commandlist(sprintf('#%d:port_in_a7\r' , this.motorID));
......
......@@ -23,8 +23,8 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
'continuous', false, ...
'absolut', true, ...
'closed_loop', false, ...
'acceleration_ramp',10, ...
'gear_ratio', 5, ...
'acceleration_ramp',800, ...
'gear_ratio', 80, ...
'current', 100, ...
'ramp_mode', 2, ...
'P', 400, ...
......@@ -44,14 +44,21 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
this.motorID = 8;
this.motorName = 'HRTFArc';
this.motorLimits = [-20 380]; % the motor can do a whole rotation + ~15 deg to both sides
this.motorLimits = [-45 330]; % the motor can do a whole rotation + ~15 deg to both sides
end
function this = init(this)
end
function disableReference(this,value)
if value
this.mMotorControl.sendControlSequenceAndPrintResults(':port_in_a=0');
else
this.mMotorControl.sendControlSequenceAndPrintResults(':port_in_a=7');
end
end
function stop(this)
% DO NOT ASK - JUST STOP ALL MOTORS!
for i = 1:5 % repeat several times to ensure that every motor stops!
......@@ -63,6 +70,22 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
end
end
% function freeFromStopButton(this)
% res = motorControl.sendControlSequenceAndPrintResults('Zd');
% resp = res{end};
% direction = str2double(resp(end));
%
% if direction == 0
% direction = -1;
% else
% direction = 1;
% end
% this.allowMoveOverRefButton(1);
% this.prepareMove(direction*20,'absolut',false,'speed',10);
% this.startMoveToPosition();
% this.allowMoveOverRefButton(0);
% end
function getStatus(this)
motorControl.add_to_commandlist(sprintf('#%d$\r' , this.motorID));
......@@ -88,6 +111,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
function sendConfiguration(this)
% Set Input 1 as external Referenceswitch
motorControl = this.mMotorControl;
motorControl.add_to_commandlist(sprintf('#%d:port_in_a=7\r' , this.motorID));
motorControl.add_to_commandlist(sprintf('#%d:port_in_b=7\r' , this.motorID));
motorControl.add_to_commandlist(sprintf('#%d:port_out_a=1\r' , this.motorID));
motorControl.add_to_commandlist(sprintf('#%d:port_out_a=2\r' , this.motorID));
......@@ -105,8 +129,8 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
% endschalterverhalten: the ref manual is not very clear. bit 0
% is the most important bit. all not listed bits are 0
% defValue bin2dec('0100010000100010') = 17442
% motorControl.add_to_commandlist(sprintf('#%dl%d\r' , this.motorID, 5154));
this.allowMoveOverRefButton(0);
% set lower speed to 1 Hz/sec (lowest value)
motorControl.add_to_commandlist(sprintf('#%du3\r' , this.motorID));
......@@ -117,22 +141,23 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
motorControl = this.mMotorControl;
% Turn + some degrees in case we are already at the end of the
% reference switch or already passed it:
this.prepareMove(10,'absolut',false,'speed',1);
this.startMoveToPosition();
if this.mMotorControl.send_commandlist(5);
ita_verbose_info('HRTFarc started move...',2);
end
tmpWait = motorControl.wait;
motorControl.wait = true;
motorControl.wait4everything;
motorControl.wait = tmpWait;
% this.prepareMove(20,'absolut',false,'speed',10);
% this.startMoveToPosition();
% if this.mMotorControl.send_commandlist(5);
% ita_verbose_info('HRTFarc started move...',2);
% end
% tmpWait = motorControl.wait;
% motorControl.wait = true;
% motorControl.wait4everything;
% motorControl.wait = tmpWait;
this.disableReference(0);
% Call Reference-Mode:
motorControl.add_to_commandlist(sprintf('#%dp=4\r' , this.motorID));
% Set direction:
motorControl.add_to_commandlist(sprintf('#%dd=1\r' , this.motorID));
% Calculate and set lower speed:
% stepspersecond = round(this.sArgs_default_motor.speed/0.9*this.sArgs_default_motor.gear_ratio);
motorControl.add_to_commandlist(sprintf('#%du=%d\r' , this.motorID, 1));
stepspersecond = round(this.sArgs_default_motor.speed/0.9*this.sArgs_default_motor.gear_ratio);
motorControl.add_to_commandlist(sprintf('#%du=%d\r' , this.motorID, stepspersecond));
% Calculate and set upper speed:
stepspersecond = round(this.sArgs_default_motor.speed/0.9*this.sArgs_default_motor.gear_ratio);
motorControl.add_to_commandlist(sprintf('#%do=%d\r' , this.motorID, stepspersecond));
......@@ -192,6 +217,21 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
methods(Hidden = true)
function this = allowMoveOverRefButton(this,value)
motorControl = this.mMotorControl;
if value
motorControl.sendControlSequenceAndPrintResults('l17442');
else
motorControl.sendControlSequenceAndPrintResults('l5154');
end
% Frei rckwrts
% 5154
% Stop
% 9250
end
function ret = prepare_move(this, angle, varargin)
% This function prepares the moves of the turntable, counterclockwise for a negative
% angle and clockwise for a positive angle.
......@@ -297,7 +337,7 @@ classdef itaMotorNanotec_HRTFarc < itaMotorNanotec
% Choose ramp mode: (0=trapez, 1=sinus-ramp, 2=jerkfree-ramp):
motorControl.add_to_commandlist(sprintf('#%d:ramp_mode=%d\r', this.motorID, this.sArgs_motor.ramp_mode));
% % Set maximum acceleration jerk:
motorControl.add_to_commandlist(sprintf('#%d:b=20\r' , this.motorID));
motorControl.add_to_commandlist(sprintf('#%d:b=80\r' , this.motorID));
% % Use acceleration jerk as braking jerk:
motorControl.add_to_commandlist(sprintf('#%d:B=20\r' , this.motorID));
% Closed_loop?
......
......@@ -99,6 +99,10 @@ classdef itaMotorNanotec_Slayer < itaMotorNanotec
end
function disableReference(this,value)
end
function this = moveToReferencePosition(this)
% Prepare reference move (arm)
......
......@@ -136,6 +136,9 @@ classdef itaMotorNanotec_Turntable < itaMotorNanotec
this.mMotorControl.add_to_commandlist(sprintf('#%dA\r' , this.motorID));
end
function disableReference(this,value)
end
function started = prepareMove(this,position,varargin)
......
......@@ -209,12 +209,14 @@ classdef test_itaEimarMotorControl < itaMeasurementTasksScan
speed = 360/(numRepetitions*timePerRepetition);
% preangletime
preAngleTime = 2/64*numRepetitions; % it takes 2 seconds to start recording
preAngle = preAngleTime*speed;
preAngle = 45;
preAngleTime = preAngle/speed; % it takes 2 seconds to start recording
preAngle = min(preAngle,20);
preAngle = max(preAngle,20);
numTotalRepetitions = numRepetitions+ceil(preAngleTime/(timePerRepetition))+9;
postAngle = 10;
postAngleTime = postAngle/speed;
additionalReps = ceil((postAngleTime+preAngleTime + 1)/timePerRepetition);
numTotalRepetitions = numRepetitions+additionalReps;
this.measurementSetup.repetitions = numTotalRepetitions;
%prepare motors for continuous measurement
......@@ -236,7 +238,7 @@ classdef test_itaEimarMotorControl < itaMeasurementTasksScan
function [result, result_raw] = runContinuousMeasurement(this)
this.mMotorControl.setWait(false);
this.mMotorControl.startContinuousMoveNow;
pause(1);
pause(0.1);
result_raw = this.measurementSetup.run_raw_imc;
result = this.measurementSetup.deconvolve(result_raw);
% this.stop;
......
......@@ -151,7 +151,7 @@ classdef itaEimar < itaMeasurementTasksScan
sArgs_default_turntable = struct( ...
'wait', true, ...
'speed', 5, ...
'speed', 2, ...
'VST', 'adaptiv', ...
'limit', false, ...
'continuous', false, ...
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment