OpenFlexure Microscope OpenSCAD docs
libs/cameras/logitech_c270.scad
Mounting functions and modules for the Logitech C270 webcam.
This file contains the functions and modules in the pattern pre-defined by
libs/cameras.scad.
function c270_camera_dict()
[Source]
function c270_camera_dict() = [["mount_height", 4.5], ["sensor_height", 0.2]];
function c270_camera_bottom_z()
[Source]
function c270_camera_bottom_z() = -key_lookup("mount_height", c270_camera_dict());
function c270_tallest_clearance()
[Source]
function c270_tallest_clearance() = 6.5;
Height of tallest components, plus clearance
Returns:6.5
function c270_camera_hole_spacing()
[Source]
function c270_camera_hole_spacing() = 8.25;
Spacing of the lens mount holes at the sensor
Returns:8.25
function c270_near_third_hole_pos()
[Source]
function c270_near_third_hole_pos() = [5,-9.5,0];
Position of camera board hole near the sensor
Returns:vector from optical axis to the mounting hole
function c270_far_third_hole_pos()
[Source]
function c270_far_third_hole_pos() = [-6,42.3,0];
Position of camera board hole at the cable end
Returns:vector from optical axis to the mounting hole
module c270_cutout(beam_r=4.3, cover=true)
[Source]
module c270_cutout(beam_r=4.3, cover=true){ //cut-out to fit Logitech C270 webcam //optical axis at (0,0) //top of PCB at (0,0,0) mount_h = key_lookup("mount_height", c270_camera_dict()); inner_w = c270_dims().x; // inner size is outer size minus roof thickness in_h_main = mount_h - 1; in_h_tall = c270_tallest_clearance(); block_h = 15; mirror([0,0,1]){ //parts cut out of the mount are z<0 //beam clearance hull(){ cube([8,8,6], center=true); translate_z(-mount_h){ cylinder(r=beam_r, h=2*tiny(), center=true); } } // with a cover below the camera, make the cut-out a bit longer cut_length = 37; cut_end = (cover)? 45.5 : 43.5; cut_mid = cut_end - cut_length / 2; cut_length_tall = cut_end - abs(c270_y_offset()) - 2; cut_mid_tall = cut_end - cut_length_tall / 2; difference(){ union(){ // component clearance, cable end translate([0, cut_mid, block_h-in_h_main]){ rotate_y(180){ round_top_cube([inner_w, 37, block_h], 1.5, center=true); } } translate([0, cut_mid_tall, block_h-in_h_tall]){ rotate_y(180){ intersection(){ round_top_cube([inner_w, cut_length_tall, block_h], 1.5, center=true); slope_top_cube([inner_w, 2*cut_length_tall, block_h], slope_angle=30, slope_depth=3, center=true); } } } // component clearance, sensor end hull(){ z = block_h/2 - in_h_main; translate([0, 3, z]){ cube([inner_w, 16, block_h], center=true); } translate([0, -4, z]){ cube([9, 9.5*2, block_h], center=true); } } } union(){ // add cube at third mounting hole, cable end h_c = 10; translate(c270_far_third_hole_pos()-[0,0,h_c-tiny()]){ hull(){ hull(){ cylinder(d=4, h=h_c); translate_z(-2){ cylinder(d=5, h=h_c); } } translate_x(-10){ cylinder(d=5, h=h_c); } translate_y(10){ cylinder(d=5, h=h_c); } } } // add a pillar at the 'near third hole' place translate(c270_near_third_hole_pos()){ hull(){ translate([1, -2.4, -(1.5 + mount_h/2)]){ cube([8, 10, mount_h], center=true); } translate([1.5, -2.4, tiny()]){ cube([6, 10, tiny()], center=true); } } } // add mount around the camera sensor, // the same shape as the supplied lens mount cube([14,14,99], center=true); cube([21,5,99], center=true); } } } }
function c270_dims()
[Source]
function c270_dims() = [21, 58];
function c270_y_offset()
[Source]
function c270_y_offset() = -13;
function c270_mount_y_excess()
[Source]
function c270_mount_y_excess() = 8;
function c270_backshell_screw_positions(flip_x=false)
[Source]
function c270_backshell_screw_positions(flip_x=false) = let( h = c270_dims().y, w = c270_dims().x, y_offset = c270_y_offset(), y_excess = c270_mount_y_excess(), y_pos = h+y_offset+y_excess-4, sign = flip_x ? 1 : -1 ) [[sign*(-w/2+4), y_pos, 3], [sign*(w/2-4), y_pos, 3]];
module c270_camera_mount(screwhole=true)
[Source]
module c270_camera_mount(screwhole=true){ // camera mount dims h = c270_dims().y; w = c270_dims().x + 1.5; //wider_ section around lens h_w = 2*abs(c270_y_offset()); w_w = c270_dims().x + 2.5; y_offset = c270_y_offset(); // Extra room for cable if the mount has a cover below, // which is when the screwholes are not present from below. y_excess = (screwhole)? 0 : c270_mount_y_excess(); mount_height = key_lookup("mount_height", c270_camera_dict()); difference(){ union(){ // Cube over sensor for hulling to the lens mount, slightly raised // because the spheres making the round top are cut off in the STL representation rounding = 2; translate([-w_w/2, y_offset-rounding, -mount_height]){ round_top_cube([w_w, h_w+rounding, mount_height+2*tiny()], rounding, $fn=16); } // Cube over the rest of the board, slightly lower down so that it // is not used for the lens mount. translate([-w/2, y_offset+y_excess, -mount_height]){ round_top_cube([w, h, mount_height-2*tiny()], rounding, $fn=16); } // Cube over the end of the board, slightly higher up to give // more space for large components. start_pos = -y_offset + tiny(); end_pos = h - (-y_offset) + y_excess; length = abs(end_pos - start_pos); centre = start_pos + (end_pos - start_pos) / 2; // outer size over tall components is inner plus roof thickness bulge = c270_tallest_clearance() + 1; translate([0, centre, -mount_height]){ intersection(){ round_top_cube([w, length, bulge], 2, center=true, $fn=16); slope_top_cube([w, 2*length, bulge], slope_angle=30, slope_depth=3, center=true); } } } translate_z(-mount_height){ // if there are screwholes from below, there is no cover below c270_cutout(cover=!screwhole); c270_self_tap_screwholes(screwhole=screwhole); } c270_backshell_self_tap_screwholes(); } }
A mount for the Logitech C270 USB webcam
This has the top at z=0+tiny(), with a surface that can be hull-ed onto the lens assembly.
screwhole:Boolean for adding tri-linder holes for self-tapping screws
module c270_self_tap_screwholes(screwhole)
[Source]
module c270_self_tap_screwholes(screwhole){ mount_height = key_lookup("mount_height", c270_camera_dict()); if(screwhole){ // Self tap mounting holes for camera reflect_x(){ translate_x(c270_camera_hole_spacing()){ no1_selftap_hole(h=6); // chamfer in base to overcome overextrusion translate_z(-0.5){ cylinder(r1=2,h=2,r2=0,$fn=12); } } } } // third mounting hole, cable end translate(c270_far_third_hole_pos()){ // hole depth does not extend through the top of the mount no1_selftap_hole(h=mount_height-0.6); // chamfer in base to overcome overextrusion translate_z(-0.5){ cylinder(r1=2,h=2,r2=0,$fn=12); } } }
module c270_backshell_self_tap_screwholes()
[Source]
module c270_backshell_self_tap_screwholes(){ mount_height = key_lookup("mount_height", c270_camera_dict()); for (i = [0, 1]){ translate(c270_backshell_screw_positions()[i]){ translate_z(-mount_height-5.5){ no2_selftap_hole(h=6); } } } }
function c270_backshell_height()
[Source]
function c270_backshell_height() = 6;
Height of the backshell for the C270 camera
The height of the backshell part of the C270 camera cover. It is a function so that the backshell can be translated easily from its to to its base.
Returns:6
module c270_backshell()
[Source]
module c270_backshell(){ height = c270_backshell_height(); wall_t = 0.75; shelf = 0.5; h = c270_dims().y; w = c270_dims().x; case_w = w + 2*wall_t; hollow_w = w - shelf; y_offset = c270_y_offset(); // y offset is -ve //extra room for cable y_excess = c270_mount_y_excess(); rotate_y(180){ // This whole element is built upside down along the y-axis and needs to // be rotated 180 degrees about y to be in place // y here remains y // z here becomes -z // x here becomes -x difference(){ //The main block end_from_centre = 3; // distance from axis of end of the cover cover_length = h + y_offset + y_excess - end_from_centre; difference(){ translate([-(case_w)/2, 0, 0]){ round_top_cube([case_w, cover_length+end_from_centre, height], 2, $fn=16); } // trim to length cube([2*case_w, 2*end_from_centre, 99], center=true); } // cut out space for PCB translate([-(w)/2, y_offset, -tiny()]){ cube([w, h, 1+tiny()]); } difference(){ //Hollow out main block union(){ translate([-(hollow_w)/2, -tiny(), -1.5]){ round_top_cube([hollow_w, h+y_offset+y_excess-2, height], 1.5, center=false); } // A tiny bit more space for cable } // Subtract (from the hollowing-out subtraction) stand offs // for the backshell. for (i = [0, 1]){ translate(c270_backshell_screw_positions(flip_x=true)[i]){ cylinder(d=7, h=2*height, center=true); } } } for (i = [0, 1]){ translate(c270_backshell_screw_positions(flip_x=true)[i]){ mirror([0,0,1]){ no2_selftap_counterbore(flip_z=true, tight=true); } } } //wire cutout cube([5, 50, h], center=true); } } }
Generate a cover for the back of the C270 camera board
The cover does not reach over the entire board. It is designed to reach up to the camera platform when used with a lens spacer
module c270_cable_exit()
[Source]
module c270_cable_exit(){ translate_y(-5/2){ cube([14, 5, 6.5], center=true); } rotate_y(90){ cylinder(d=6.5, h=14, center=true); } translate_x(3){ cube([1, 10, 10], center=true); } cube([25, 4, 4], center=true); }
A module currently not used. If split in half it can clamp around the block at the end of C270 cable & e-clip
module c270_counterbore()
[Source]
module c270_counterbore(){ camera_mount_height = key_lookup("mount_height", c270_camera_dict()); lens_base = camera_mount_height + 5; translate_z(c270_camera_bottom_z()-1){ at_c270_hole_pattern(){ cylinder(r=1.1, h=lens_base, $fn=12); } } translate_z(c270_camera_bottom_z()+1){ at_c270_hole_pattern(){ cylinder(r=2.1, h=lens_base-1, $fn=12); } } }
module c270_camera_bottom_mounting_posts( optics_config, outers=true, cutouts=true, bottom_slice=false )
[Source]
module c270_camera_bottom_mounting_posts(optics_config, outers=true, cutouts=true, bottom_slice=false){ if (bottom_slice){ //if we want the bottom slice intersect with the bottom of the whole //post found by recalling the function intersection(){ cylinder(h=tiny(), r=99); c270_camera_bottom_mounting_posts(optics_config, outers=outers, cutouts=cutouts); } } else{ // posts to mount to Logitech C270 camera from below r1=3; r2=2.5; h = key_lookup("mounting_post_height", optics_config); at_c270_hole_pattern(){ difference(){ if(outers){ cylinder(r1=r1, r2=r2, h=h, $fn=12); } if(cutouts){ translate_z(h-6+tiny()){ // The C270 board holes are smaller than #2 screws no1_selftap_hole(h=6); } } } } } }
module at_c270_hole_pattern()
[Source]
module at_c270_hole_pattern(){ screw_x = c270_camera_hole_spacing(); // Third hole position at the far end of the board [-6,42.3,0] is too far away and makes // the camera platform too big for mounting from above. //c270_third_hole_pos = [5,-9.5,0]; reflect_x(){ translate([screw_x, 0, 0]){ children(); } } translate(c270_near_third_hole_pos()){ children(); } }
Replicate and place geometry at the mounting positions for the Logitech C270 USB webcam
A transformation that replicates the geometry, and positions the replicas at the mounting hole positions for the Logitech C270 USB webcam.