CEB Press/Research Development/Controller Design/Plot Script

From Open Source Ecology
Jump to: navigation, search
## Gnu Octave script to draw illustration of the OSE CEB Press operation cycle

## There are 15 identified events in the cycle
##  listed here with times in seconds
events{1} = "Secondary cylinder begins extending";
evt(1) = 0;
events{2} = "Main cylinder starts down";
evt(2) = 0.5;
events{3} = "Secondary cylinder completes extending (full left)";
evt(3) = 1;
events{4} = "Main cylinder completes downstroke (full down)";
evt(4) = evt(2) + 2.5;
events{5} = "Shaker motor start";
evt(5) = max(evt(3), evt(4));
events{6} = "Shaker motor stop";
evt(6) = evt(5) + 2;
events{7} = "Secondary cylinder begins first retraction";
evt(7) = evt(6) + 0.5;
events{8} = "Secondary cylinder completes move (middle position)";
evt(8) = evt(7) + 0.5;
events{9} = "Main cylinder starts upward (compression stroke)";
evt(9) = evt(8);
events{10} = "Main cylinder starts down (release stroke)";
evt(10) = evt(8) + 2;
events{11} = "Main cylinder stops";
evt(11) = evt(10) + 1;
events{12} = "Secondary cylinder begins second retraction";
evt(12) = evt(11);
events{13} = "Secondary cylinder completes retraction (full right)";
evt(13) = evt(12) + 1;
events{14} = "Main cylinder starts up";
evt(14) = evt(13);
events{15} = "Main cylinder completes upstroke";
evt(15) = evt(14) + 2;
global evt;

function t = eventTime(i)
  global evt;
  if i <= 0
    t = 0;
  else
    t = evt(i);
  endif
endfunction

## sensor positions
mainSensors = [1 4 7];
secSensors = [ 1 7 12];
senseWidth = .5;

## movement points of the cylinders
mainPos = [0, 7.5; 2, 7.5; 4, 1; 9,1; 10,3.5; 11, 3; 14,3; 15, 7.5];
secPos = [0, 1; 1,1; 3, 13; 7, 13; 8, 7; 12, 7; 13, 1; 15, 1];


## Now make the plot using the above data

mainT = arrayfun(@eventTime, mainPos'(1, :));
secT = arrayfun(@eventTime, secPos'(1, :));
mt = max(evt);
timerange = [0 mt];
clf
subplot (2,1,1)
barh(mainSensors, [mt mt mt], senseWidth, "facecolor", "c", "edgecolor", "c");
hold on
plot(mainT, mainPos'(2, :), "linewidth", 3)
axis([timerange 0 8]);
title("Main Cylinder");
xlabel("time - sec");
ylabel("inch");
text(evt(10), mainPos(lookup(mainPos'(1, :), 10), 2)+.5,
  "compression   release     .", 
  "horizontalalignment", "center");
text(-.5,0,"bottom", "horizontalalignment", "right");
text(-.5,max(mainPos'(2,:)),"top", "horizontalalignment", "right");
for i=1:length(secSensors)
  text(.25+1*i, mainSensors(i), cstrcat("sensing zone ",int2str(i)));
endfor
hold off

subplot (2,1,2)
barh(secSensors, [mt mt mt], senseWidth, "facecolor", "c", "edgecolor", "c");
hold on
plot(secT, secPos'(2, :), "linewidth", 3)
title("Secondary Cylinder");
ylabel("inch");
text(-.5,0,"retract", "horizontalalignment", "right");
text(-.5,max(secPos'(2,:)),"extend", "horizontalalignment", "right");
for i=1:length(secSensors)
  text(.25+1*i, secSensors(i), cstrcat("sensing zone ",int2str(i)));
endfor
axis([timerange 0 14]);
hold off