/* First attempt at making large electric motor using 3D printer to create the complex parts */ // allviews winding_base winding_top arbre stator rotor // testviews assemblage comb include use <../cadlib.h> nbpole=12; stator_ray=20; winding_ray=30; tooth_height=2; // For winding width=10; thick=2*3.1416*(stator_ray+winding_ray)/12; arbre_ray=10; arbre_extra=20; arbre_inside=30; arbre_base=10; arbre_len=arbre_inside+arbre_extra+arbre_base; bearing_ray=15; bearing_thick=7; module cubestator(offthick,offray){ raysum=stator_ray+winding_ray+offray; widthsum=width+tooth_height*2+offthick; intersection(){ cylinder(r=raysum,h=widthsum,$fn=80); translate([raysum,0,-1]) rotate([0,0,90]) triangle_isocel(thick,raysum,widthsum+2); } } module shape(w,len){ linear_extrude(height = len, center = false, convexity = 10, twist = 0 , slices = 20, scale = 1.0) { polygon([[0,0],[0,w],[tooth_height,w/2]]); } } module comb(do_threads){ height=10; len=winding_ray-10; shapeh=2; r=2; r2=r*2; translate([0,shapeh,2*shapeh]){ minkowski(){ cube([len,height-r2,width-r2]); rotate([0,90,0]) cylinder(r=r,h=1,$fn=40); } } if (do_threads){ nb=10; step=len/nb; step2=step/2; angleh=atan2(step,height); anglew=atan2(step,width); w=step; intersection(){ for (i=[1:nb-1]){ translate([step*i,0,shapeh+r]) rotate([angleh,0,-90]) shape(w,height-r2); translate([step*i-1,height,shapeh+r]) rotate([angleh,0,90]) shape(w,height-r2); translate([step*i,r,width+shapeh]) rotate([anglew,-90,-90]) shape(w,width-r2); translate([step*i,width-r,shapeh]) rotate([anglew,90,-90]) shape(w,width-r2); } translate([0,-shapeh,0]) cube([len,height+2*shapeh,width+2*shapeh]); } } } module winding_base(){ off=4; difference(){ cubestator(0,0); translate([0,0,-1]) union(){ t=width+2*tooth_height+2; cylinder(r=stator_ray,h=t,$fn=40); translate([stator_ray+off,-50,0]) cube([winding_ray-10,100,t]); //nbpole2=nbpole*2; //rotate([0,0,360/nbpole2]) translate([0,thick/2,0]) cubestator(2,20); //rotate([0,0,-360/nbpole2]) translate([0,-thick/2,0]) cubestator(2,20); } } translate([stator_ray+off,-width/2,0]) comb(false); } module winding_top(){ } module all_windings(){ for (i=[0:nbpole-1]){ rotate([0,0,360/nbpole*i]) winding_base(); } } module arbre(){ cylinder(r=arbre_ray,h=arbre_len,$fn=80); translate([0,0,arbre_inside+arbre_base]) cylinder(r1=arbre_ray+3,r2=arbre_ray,h=5,$fn=80); translate([0,0,arbre_base-5]) rotate([0,0,0]) cylinder(r2=arbre_ray+3,r1=arbre_ray,h=5,$fn=80); } // Le stator supporte les winding_base (x nbpole) // Il supporte aussi les 2 roulements à billes qui soutinnent l'arbre // À une extrémité du stator, il y a une plaque de montage. C'est là que le moteur // s'attache à la machine module stator(){ w=stator_ray+winding_ray+10; thick1=5; thick=bearing_thick+thick1; difference(){ union(){ translate([-w/2,-w/2,0]) cube([w,w,thick1]); translate([0,0,thick1]) cylinder(r=stator_ray,h=bearing_thick,$fn=80); } union(){ translate([0,0,thick-bearing_thick]) cylinder(r=bearing_ray,h=bearing_thick+1,$fn=80); translate([0,0,-1]) cylinder(r=arbre_ray+2,h=thick+2,$fn=80); } } translate([0,0,thick]) difference(){ cylinder(r=stator_ray,h=arbre_inside,$fn=80); translate([0,0,-1]) cylinder(r=bearing_ray+0.5,h=arbre_inside+2); } } module main_view(view){ if (view=="winding_base"){ winding_base(); }else if (view=="winding_top"){ winding_top(); }else if (view=="stator"){ stator(); }else if (view=="arbre"){ arbre(); }else if (view=="rotor"){ rotor(); }else if (view=="assemblage"){ middlez=winding_ray+stator_ray; translate([arbre_inside/2,0,middlez]) rotate([0,90,0]) all_windings(); translate([0,0,middlez]) rotate([0,90,0]) stator(); translate([0,0,middlez]) rotate([0,90,0]) arbre(); }else if (view=="comb"){ comb(); } }