// 62.5 x 100, r 7.5
$fn=50;

module frame(width, length, radius, height){
    x_offset = (width-2*radius)/2;
    y_offset = (length-2*radius)/2;
    z_offset = radius; 
hull(){
    translate ([x_offset,y_offset,0]) cylinder(r=radius, h=height);
    translate ([-x_offset,y_offset,0]) cylinder(r=radius, h=height);
    translate ([x_offset,-y_offset,0]) cylinder(r=radius, h=height);
    translate ([-x_offset,-y_offset,0]) cylinder(r=radius, h=height);  

     
    translate ([x_offset,y_offset,z_offset]) sphere(r=radius);
    translate ([-x_offset,y_offset,z_offset]) sphere(r=radius);
    translate ([x_offset,-y_offset,z_offset]) sphere(r=radius);
    translate ([-x_offset,-y_offset,z_offset]) sphere(r=radius);   
    }
}

module loch(height, offset){
   translate([0,0,3.4+offset])  cylinder (h=height, d=4.4);
   translate([0,0,height+3.4+offset]) cylinder (h=3.5, d1=4.4, d2=11);
}
// Halter nach oben
dicke= 5.7+7.5;
breite = 20;
innerebreite = 17;
achsendurchmesser = 8;
dia = 4.4;
top = 9.4 +dia/2;
right = 14 +dia/2;

//
// beweglicher Arm

*translate([0,-79.5,26.5])rotate ([0,180,0]) difference(){
union(){
    translate([-breite/2,100+120+11,dicke]) rotate([0,90,0]) cylinder(r=dicke, h=breite);
    
    
translate([-breite/2,11,0]) cube([breite,120 +100,10]);
 translate([0,0,2])    minkowski(){
    cylinder(d=30, h=4);
        sphere(2);
    }
  }  
    // kabelkanal
translate([-4,-8,2]) cube([8,120 +120,7]);
translate([-11/2,-15/2,0.8]) cube([11,15,8]);
translate([-5,215,2]) cube([10,20,40]);
//  Seitenscheiben
scheibendicke = (breite - innerebreite)/2 +.1;
  
translate([-breite/2,100+120+11,dicke]) rotate([0,90,0]) cylinder(r=dicke+.1, h=scheibendicke);
translate([breite/2-scheibendicke,100+120+11,dicke]) rotate([0,90,0]) cylinder(r=dicke+.1, h=scheibendicke);
#translate([-breite/2,100+120+11,dicke]) rotate([0,90,0]) cylinder(d=achsendurchmesser, h=breite);
}




difference(){
union(){
frame(62.5, 100, 6.68, 4);
translate([0,0,-3.5])frame(58.5, 96, 3.4, 6);


    
translate([-breite/2,45,0]) cube([breite,120, dicke]);
translate([-breite/2,45+120-dicke,dicke]) rotate([0,90,0]) cylinder(r=dicke, h=breite);
}
translate([-innerebreite/2,45+120-dicke,dicke]) rotate([0,90,0]) cylinder(r=dicke+0.5, h=innerebreite);
// die Achse
translate([-breite/2,45+120-dicke,dicke]) rotate([0,90,0]) cylinder(d=achsendurchmesser+0.1, h=breite);
// oberes und unteres Befestigungsloch
//x:11,8 y:6.5, d=4.4

translate([62.5/2- right, 100/2 - top,0.3]) loch(dicke, -6);
translate([-62.5/2+ right, -100/2 + top,0.3]) loch(dicke, -6);

// innerer Ausschnitt
cube([ 53.5,90.5, 13], center=true);
// Stromversorgung Ausschnitt
translate([0,-55,3.5/2])rotate([0,90,90])cylinder(d=3.5, h=20);
translate([0,-45,-3])cube([3.5,20, 10], center = true);
// Kabelfürung für Taster
translate([-innerebreite/2,45,1]) cube([innerebreite,120, dicke*2/3]);
}



*translate([-62.5/2+ right, -100/2 + top,0.3]) cube([6,6,30], center = true);

*translate([-50,0, -21])cube([100, 50, 21]);
// elektronik-box
difference(){
translate([0,-10, -6.5])cube([53.5,50, 29], center = true);
translate([0,-10, -6.5])cube([51.5,48, 29.1], center = true);
    // Stromversorgung Ausschnitt
translate([0,-50,3.5/2])rotate([0,90,90])cylinder(d=3.5, h=20);
translate([0,-40,-13])cube([3.5,40, 30], center = true);
    // Ausschnitt Sensor und Tasterkabel
translate([0,20,-7])cube([3.5,30, 30], center = true);

}