Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- armThickness=10;
- armDepth = 20;
- //defines a section of the arm with hidges highlighted with a pin
- module armSection(l){
- hull(){
- rotate([90,0,0]) cylinder(h=armThickness,d=armDepth,center=true);
- translate([0,0,l]) rotate([90,0,0]) cylinder(h=armThickness,d=armDepth,center=true);
- }
- rotate([90,0,0]) cylinder(h=armThickness*2,d=armDepth/5,center=true);
- translate([0,0,l]) rotate([90,0,0]) cylinder(h=armThickness*2,d=armDepth/5,center=true);
- }
- //defines a simpson arm, origin 0,0,0 with the hindge set correctly for desired elbow angle with the first section held vertical
- module armVert(l,elbowAngle){
- armSection(l/2);
- translate([0,0,l/2]) rotate([0,elbowAngle,0]) armSection(l/2);
- }
- //module to derive a simpson arm based on its x/y orign and machine parameters
- // base the distance between towers (scaler)
- // l the length of the arm at full extension assumes two equal legth sections totaling to this
- // xt tower x cordinate
- // yt tower y cordinate
- // x desired effector x position for machine
- // y desired effector y position for machine
- // z desired effector z position for machine
- module tower(base,l,xt,yt,x,y,z){
- xElement=x-xt;
- yElement=y-yt;
- zElement=z;
- // in a real machine this is the controler parameter,
- // either by line drive or using a worm gear against a fixed pivot point
- // (drive proportional to pully ratio or ration of driven gear to arm length.
- //here we control x y and z and derive from that the elbow angles for the joints
- armLen=sqrt(pow(xElement,2)+pow(yElement,2)+pow(zElement,2));
- //the following elements would be passive and mechanically derived.
- elbowAngle=180-asin((armLen/2)/(l/2))*2;
- baseAngleVert=((180-elbowAngle)/2)-asin(z/armLen);
- baseAngleHor=atan2(yElement,xElement);
- //echo(xelement=xElement);
- //echo(yElement=yElement);
- //echo(zElement=zElement);
- //echo(armLen=armLen);
- //echo(elbowAngle=elbowAngle);
- //echo(baseAngleVert=baseAngleVert);
- //echo(baseAngleHor=baseAngleHor);
- //rotate the whole arm to match the passive joints in the real machine,
- //translate tower to its desired origin
- translate([xt,yt,0]) rotate([0,baseAngleVert,baseAngleHor]) armVert(l,elbowAngle);
- }
- base=180;
- maxArmLen=240;
- //this tower is further back such that it is equidistant from origin
- towerRisersHeight=30;
- x0TowerY=sqrt(pow(base,2)/2);
- echo(x0TowerY=x0TowerY);
- loopVar=(($t))*360;
- x=sin(loopVar)*(base*.45);
- y=cos(loopVar)*(base*.45);
- z=40+loopVar/40;
- translate([0,0,towerRisersHeight]){
- tower(base,maxArmLen,-base/2, -base/2,x,y,z);
- tower(base,maxArmLen, 0, x0TowerY,x,y,z);
- tower(base,maxArmLen, base/2, -base/2,x,y,z);
- }
- translate([-base/2, -base/2,0]) cylinder(h=towerRisersHeight,d=armDepth);
- translate([ 0, x0TowerY,0]) cylinder(h=towerRisersHeight,d=armDepth);
- translate([ base/2, -base/2,0]) cylinder(h=towerRisersHeight,d=armDepth);
- difference(){
- cylinder(r=x0TowerY+armDepth,h=1,center=true);
- cylinder(r=x0TowerY-armDepth,h=2,center=true);
- }
- translate([200,0,0]){
- cube([10,10,x]);
- translate([0,-10,0]) text("x");
- translate([15,0,0]) {
- cube([10,10,y]);
- translate([0,-10,0]) text("y");
- }
- translate([30,0,0]) {
- cube([10,10,z]);
- translate([0,-10,0]) text("z");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement