OpenFlexure Microscope OpenSCAD docs

libs/microscope_parameters.scad

Parameters for building/customising the OpenFlexure Microscope.

The key editable parameters are in a dictionary. Other parameters are defined as functions to limit the need for global variables and the risk that these global variables are overwritten in other scopes. Any parameter that shouldn't be edited is a function.

Some function parameters depend on parameters in this file, some depend on the parameter dictionary. If they depend on the parameter dictionary then the dictionary must be supplied as an argument.

function default_params()
[Source]
function default_params() = [["leg_r", 30],     // radius on which the innermost part of legs sit. (This sets the stage size)
                             ["sample_z", 75 ], // z position of sample
                             ["stage_t", 15],   //thickness of the XY stage (at thickest point, most is 1mm less)
                             ["leg_block_t", 5], // Thickness of the block at the top and bottom of the leg
                             ["stage_hole_r", 20], // size of hole in the stage
                             ["xy_lever_ratio", 4.0/7.0], // mechanical advantage of actuator over xy-stage - can be used to trade speed and precision
                             ["z_lever_ratio", 1.0], //  mechanical advantage of actuator over objective mount (must be >1)
                             ["print_ties", true], //sets whether the ties that support printing are on. It is useful to be able to turn these off for rendering
                             ["smart_brim_r", 5], // The radius of the smart brim on the main body
                             ["actuator_h", 25], //height of the actuator columns
                             ["include_motor_lugs", true], //sets whether the motor lugs are included
                             ["foot_height", 15], //the height of the feet
                            ];

* * Sets the basic geometry of the default microscope * Stages can be built with modified parameters but with no guarantee that any other * set of parameters will work. * These parameters define the default size for the structural elements of the micoroscope, optics parameters are set separately.

function min_z_feature()
[Source]
function min_z_feature() = 0.5;

* * The minimum recommended size in z of a feature. This is approximately 2-3 layers when printed

function leg_height(params)
[Source]
function leg_height(params) = let(
    sample_z = key_lookup("sample_z", params),
    stage_t = key_lookup("stage_t", params),
    leg_block_t = key_lookup("leg_block_t", params)
) sample_z - stage_t + leg_block_t;

* * Height of the top of the leg. * Shorter than sample_z so that you can get nuts into the stage nut traps, * and so the slide doesn't crash into the legs.

function stage_hole_inset()
[Source]
function stage_hole_inset() = flex_dims().y+4;

* * The distance holes on the XY stage are inset from leg_r (the radius on which the legs sit)

function leg_middle_w()
[Source]
function leg_middle_w() = 12;

* * Width of the middle part of each leg

function microscope_base_t()
[Source]
function microscope_base_t() = 1;

* * Thickness of the base of the main body

function x_actuator_pos(params)
[Source]
function x_actuator_pos(params) = let(
    leg_r = key_lookup("leg_r", params),
    radial_distance = leg_r+actuating_nut_r(params)
) [1, 1, 0]*radial_distance/sqrt(2);

* * Position of the x actuator

function y_actuator_pos(params)
[Source]
function y_actuator_pos(params) = let(
    x_pos = x_actuator_pos(params)
) [-x_pos.x, x_pos.y, x_pos.z];

* * Position of the y actuator

function z_actuator_pos(params)
[Source]
function z_actuator_pos(params) = [0, z_nut_y(params), 0];

* * Position of the z actuator

function flex_dims()
[Source]
function flex_dims() = let
(
    // width  of flexures
    flex_w = 4,
    // length of flexures
    flex_l = 1.5,
    // thickness  of flexures
    flex_t = 0.75
)  [flex_w, flex_l, flex_t];

* * The dimensions of the flexures for the main body * These dimensions are well tested with PLA.

function flex_a()
[Source]
function flex_a() = 0.105;

Sine of the design angle through which flexures should be bent

Returns:0.105 (corresponding to 6 degrees)

function xy_actuator_extra_space(params)
[Source]
function xy_actuator_extra_space(params) = let (
    old_travel = xy_actuator_travel(params) * (0.15 / flex_a()),
    new_travel = xy_actuator_travel(params)
) old_travel - new_travel;

Extra space inside the x or y actuator casing, beyond the required height for the actuator travel

The overall height of the actuator columns in v6 and up to v7.0.0-beta4 was set using flex_a()=1.5 to define the actuator travel, and from there the cut out inside the actuators. The actuators have a fixed thickness top above the cut out.

To keep the same overall height with a different definition of the travel, extra space is defined.

params:microscope parameters dictionary

Returns:difference between the nominal travel and the travel defined in v6 of the microscope

function z_actuator_extra_space(params)
[Source]
function z_actuator_extra_space(params) = let (
    old_travel = z_actuator_travel(params) * (0.15 / flex_a()),
    new_travel = z_actuator_travel(params)
) old_travel - new_travel;

Extra space inside the z actuator casing, beyond the required height for the actuator travel

The overall height of the actuator columns in v6 and up to v7.0.0-beta4 was set using flex_a()=1.5 to define the actuator travel, and from there the cut out inside the actuators. The actuators have a fixed thickness top above the cut out.

To keep the same overall height with a different definition of the travel, extra space is defined.

params:microscope parameters dictionary

Returns:difference between the nominal travel and the travel defined in v6 of the microscope

function actuator_travel_clearance_top()
[Source]
function actuator_travel_clearance_top() = 0.4;

A physical distance for clearance of the actuator columns at the top inside the housing.

Top and bottom set to be different because the clearance at the bottom is about layer heights, at the top is layer heights and sagging of bridges.

Returns:0.4

function actuator_travel_clearance_foot()
[Source]
function actuator_travel_clearance_foot() = 0.2;

A physical distance for clearance of the actuator columns at the bottom in the feet.

Top and bottom set to be different because the clearance at the bottom is about layer heights, at the top is layer heights and sagging of bridges.

Returns:0.2

function xy_travel_adjustment(params)
[Source]
function xy_travel_adjustment(params) = let(
    nominal_travel = xy_actuator_travel(params),
    lever_change = 1.75/1.52
 ) (nominal_travel * lever_change) - nominal_travel;

Actuator travel adjustment to account for measured motion ratio

The nominal standard xy axis lever ratio is 7/4 (1.75). In a built stage the effective lever ratio can be measured by counting turns of the M3 actuator screw while measuring the stage movement with a dial micrometer. This gives a measured ratio of 1.52.

This function assumes that the modification is a scale factor to the ratio that is similar if the lever ratio is changed.

params:microscope parameters dictionary

Returns:An extra travel distance to be used for x and y actuators - top and bottom.

function xy_actuator_top_nub(params)
[Source]
function xy_actuator_top_nub(params) = xy_actuator_extra_space(params)
                                        - actuator_travel_clearance_top()
                                        - xy_travel_adjustment(params);

Height of a nub on top of the x or y actuator to set the designed travel

The inside of the actuator casing is taller than the actuator column plus the clearance required. A nub on the top of the column provides a stop at the correct position

params:microscope parameters dictionary

Returns:difference between the xy_actuator_extra_space() and the actuator top clearance

function z_actuator_top_nub(params)
[Source]
function z_actuator_top_nub(params) = z_actuator_extra_space(params) - actuator_travel_clearance_top();

Height of a nub on top of the z actuator to set the designed travel

The inside of the actuator casing is taller than the actuator column plus the clearance required. A nub on the top of the column provides a stop at the correct position

params:microscope parameters dictionary

Returns:difference between the z_actuator_extra_space() and the actuator top clearance

function lower_xy_flex_z()
[Source]
function lower_xy_flex_z() = 0;

* * z position of lower flexures for XY axis

function upper_xy_flex_z(params)
[Source]
function upper_xy_flex_z(params) = leg_height(params) - key_lookup("leg_block_t", params);

* * z position of upper flexures for XY axis

function leg_dims(params)
[Source]
function leg_dims(params) = let(
    height = upper_xy_flex_z(params)+flex_dims().z
) [4, flex_dims().x, height];

* * Dimensions of the thin vertical legs that support the stage

function leg_outer_w(params)
[Source]
function leg_outer_w(params) = leg_middle_w() + 2*flex_dims().y + 2*leg_dims(params).x;

* * Overall width of a pair of legs (parallelogram linkage) that support the stage

function actuating_nut_r(params)
[Source]
function actuating_nut_r(params) = let(
    xy_lever_ratio = key_lookup("xy_lever_ratio", params)
) (upper_xy_flex_z(params) - lower_xy_flex_z()) * xy_lever_ratio;

* * The radius upon which the x and y actuating nut sits in the frame of reference of the leg * The total distance from the centre of the microscope to the x and y actuating nuts is then * calculated as leg_r + actuating_nut_r(params) where leg_r is set in the * parameters dictionary * * This is also the length of actuating lever for x and y. * It is calculated from the difference in distance between flexures * at top and bottom of leg, multiplied by the lever ratio.

function xy_actuator_travel(params)
[Source]
function xy_actuator_travel(params) = actuating_nut_r(params)*flex_a();

* * distance moved by XY axis actuators

function xy_actuator_inner_h(params)
[Source]
function xy_actuator_inner_h(params) = let(
    column = key_lookup("actuator_h", params),
    gap = xy_actuator_travel(params) + xy_actuator_extra_space(params)
) column + gap;

Complete internal height of the x and y actuator casings

params:microscope parameters

function z_strut_l()
[Source]
function z_strut_l() = 18;

* * Length of struts supporting Z carriage.

function objective_mount_y()
[Source]
function objective_mount_y() = 18;

* * y position of the optics mounting wedge

function objective_mount_nose_w()
[Source]
function objective_mount_nose_w() = 6;

* * width of the pointy end of the mount

function lower_z_flex_z()
[Source]
function lower_z_flex_z() = 8;

* * height of the lower flexure on z actuator

function upper_z_flex_z(params)
[Source]
function upper_z_flex_z(params) = min(leg_height(params) - 12, 35);

* * height of the upper flexure on z actuator

function objective_mount_back_y()
[Source]
function objective_mount_back_y() = objective_mount_y() + 2;

* * y position of the back of the objective mount

function z_anchor_y()
[Source]
function z_anchor_y() = objective_mount_back_y() + z_strut_l() + 2*flex_dims().y;

* * y position of the fixed end of the flexure-hinged lever that actuates the Z axis

function z_anchor_w()
[Source]
function z_anchor_w() = 20;

* * Width of the fixed structure where that joints to the z-axis flexures

function z_lever_length(params)
[Source]
function z_lever_length(params) = let(
    z_lever_ratio = key_lookup("z_lever_ratio", params)
) (z_strut_l() + flex_dims().y)*z_lever_ratio;

* * The length of the actuating lever for the z_axis * * This is calculated from the desired lever ratio and the length * the struts that form the parallelogram linkage for the z-axis. * The flexure length is added to the strut length under the approximation * that the flexures act like a hinge located in the middle of the flexure.

function z_nut_y(params)
[Source]
function z_nut_y(params) = let(
    // Note that the lever is tilted so we need to find the y projection
    // from the z lever length and the z position of the bottom z flexure
    lev_len_sq = pow(z_lever_length(params), 2),
    bot_z_flex_z_sq = pow(lower_z_flex_z(), 2),
    z_lever_y_proj = sqrt(lev_len_sq - bot_z_flex_z_sq)
) z_anchor_y() - flex_dims().y/2 + z_lever_y_proj;

* * The y position of the z-actuator nut.

function z_actuator_travel(params)
[Source]
function z_actuator_travel(params) = z_lever_length(params)*flex_a();

* * distance moved by z axis

function z_actuator_inner_h(params)
[Source]
function z_actuator_inner_h(params) = let(
    column = key_lookup("actuator_h", params),
    gap = z_actuator_travel(params) + z_actuator_extra_space(params)
) column + gap;

Complete internal height of the z actuator casing

params:microscope parameters

function z_actuator_tilt(params)
[Source]
function z_actuator_tilt(params) = -asin(lower_z_flex_z()/z_lever_length(params));

* * The angle (in degrees) through which the z_actuator is tilted

function motor_connector_size()
[Source]
function motor_connector_size() = [5.5, 14.5, 8];

* * Approximate size of the connector for the 28BYJ-48 stepper motors

function motor_lug_h()
[Source]
function motor_lug_h() = 11;

* * Height of the printed lug on which the motors are mounted

function motor_bracket_h()
[Source]
function motor_bracket_h() = 0.8;

* * height(thickness) of the lug/bracket on the motor itself

function motor_shaft_pos(h)
[Source]
function motor_shaft_pos(h) = [0,-20,h+2];

* * Motor shaft position relative to the x-z position of the actuating nut. * h is the actuator height plus the travel for the axis.

function motor_screw_separation()
[Source]
function motor_screw_separation() = 35;

* * Distance between the screws that attach the motor to the microscope

function motor_screw_pos(h)
[Source]
function motor_screw_pos(h) = let(
    shaft_pos = motor_shaft_pos(h)
) [motor_screw_separation()/2,shaft_pos.y+7.8,shaft_pos.z+motor_lug_h()];

* * Position of the motor screws in the same frame of reference as motor_shaft_pos

function y_motor_z_pos(params)
[Source]
function y_motor_z_pos(params) = motor_screw_pos(xy_actuator_inner_h(params)).z;

The z-position (height) of the y-motor mounting face

params:microscope parameters dictionary

Returns:height of the y-motor mounting face

function z_motor_z_pos(params)
[Source]
function z_motor_z_pos(params) = motor_screw_pos(z_actuator_inner_h(params)).z;

The z-position (height) of the z-motor mounting face

params:microscope parameters dictionary

Returns:height of the z-motor mounting face

function lug_back_offset()
[Source]
function lug_back_offset() = [-5, -8, 0];

* * The distance that the back of the microscope mounting lugs is offset from the * centre of the hole in the lug

function back_lug_x_pos(params)
[Source]
function back_lug_x_pos(params) = let(
    leg_r = key_lookup("leg_r", params),
    fifth_of_radius = max(5,leg_r*0.2),
    // Compatibility factor added as earlier versions were calculated
    // from an errant calculation that included 1/10th of flex_dims().z
    // this factor ensures perfect compatibility with v7-beta versions
    // already in the field.
    compatibility_factor = .075
) (leg_r-flex_dims().y-fifth_of_radius-compatibility_factor)*sqrt(2);

* * Sets the position of the back lugs (These are the lugs by the legs) * The front lugs are set by the position of the actuator housing. * To get all holes see base_mounting_holes in microscope_structure.scad

function lug_angles(params)
[Source]
function lug_angles(params) = let(
    xy_cable_tidies = key_lookup("include_motor_lugs",params)
) xy_cable_tidies? [-120, 120, 50, -50] : [-120, 120, 105, -105] ;

* * The angle which the four lugs face in the order that the hole positions * are listed in base_mounting_holes in microscope_structure.scad.

function actuator_wall_h()
[Source]
function actuator_wall_h() = 15;

* * Height of walls between the actuators

function microscope_wall_t()
[Source]
function microscope_wall_t() = 2;

* * Thickness of the walls on the main body * The wall where the reflection illumination cut-out is has double thickness

function inner_wall_h(params)
[Source]
function inner_wall_h(params) = upper_z_flex_z(params) - 10;

* * Height of walls inside xy_stage

function reflection_cutout_height()
[Source]
function reflection_cutout_height() = 16;

* * Height of the cutout in the main body wall for the reflection optics