component syringe2 "syringe control"; // syringe2.comp - control syringe for 2gbp // // modes: // 0: idle <- (i_running && M68 E0 Q0 (m68==0))||(!i_running && !i_retract) // en=0 // o-hvon = 0 // // 4: jogging <- !i-running && i_retract // en=1 // ctrl-type = 1 // vel-cmd=1.0 // // 5: extruding <- (i-running || i_retract) && M3 && !(m68==2) // en=1 // ctrl-type = 1 // vel-cmd = extrvel // // 6: spinning <- (i-running || i_retract) && !M3 && M68 E0 Q2 (m68==2) // en=1 // ctrl-type = 1 // vel-cmd = spinvel // o-hvon = hv_arm // // 7: manual extrusion <- i-man-extr // en=1 // ctrl-type = 1 // vel-cmd = man-scale (mm/mL) * man-extr-rate (mL/hr) // * 1209.2 (steps/mm) / 3600 (hr/sec) // o-hvon = hv_arm // pin in float i-extrvel "extrusion velocity"; pin in float i-spinvel "electrospin velocity"; pin in float i-vectrate "vector rate"; pin in float i-m68 "M67/68 E0 value"; pin in float i-manscale "manual extrude scale factor"; pin in float i-manrate "manual extrude rate"; pin in bit i-running "running G-code or MDI"; pin in bit i-hv_arm "arm HV"; pin in bit i-manextr "manual extrusion button"; pin in bit i-retract "syringe retract"; pin in bit i-depress "syringe depress"; pin in bit i-m3 "M3 spindle command on"; pin in float i-spindlespeed "spindle speed value"; pin out float o-velcmd "velocity command for stepgen"; pin out bit o-en "enable stepgen"; pin out bit o-hvon "HV is on"; pin out bit o-spinning "is spinning"; pin out bit o-extruding "is extruding"; pin out float o-mode "debug - current mode"; function _; option singleton yes; license "GPL"; author "Ralph Stirling"; variable int mode = 0; ;; //#include FUNCTION(_) { o_mode = mode; switch (mode) { default: mode = 0; case 0: // idle if (!i_running && (i_retract || i_depress)) mode = 4; if (i_running && i_m3 && i_m68!=2) mode = 5; //if (i_running && !i_m3 && i_m68==2) if (!i_m3 && i_m68==2) mode = 6; if (i_manextr) mode = 7; o_en = 0; o_spinning = 0; o_extruding = 0; o_velcmd = 0; o_hvon = 0; break; case 4: // jogging if (!i_retract && !i_depress) mode = 0; o_en = 1; o_spinning = 0; o_extruding = 0; if (i_retract) o_velcmd = -0.1; if (i_depress) o_velcmd = 0.1; if (i_retract && i_depress) o_velcmd = 0; o_hvon = 0; break; case 5: // extruding if ((i_running && !i_m3) || (!i_running)) mode = 0; o_en = 1; o_spinning = 0; o_extruding = 1; o_velcmd = i_spindlespeed * i_vectrate; o_hvon = 0; break; case 6: // spinning //if ((i_running && i_m68==0) || (!i_running)) if ( i_m68==0 ) mode = 0; o_en = 1; o_spinning = 1; o_extruding = 0; o_velcmd = i_spinvel/3600; o_hvon = i_hv_arm; break; case 7: // manual extrusion if (!i_manextr) mode = 0; o_en = 1; o_spinning = 0; o_extruding = 0; o_velcmd = i_manrate * 1209.2 * i_manscale / 3600.0; o_hvon = i_hv_arm; break; } }