@o_lampe said in Standalone Config Snippets:
@deckingman said in Standalone Config Snippets:
Two lugs only give me 4 possibilities. One switch triggered is hot end A, the other switch triggered is hot end B, both switches triggered are hot end C and no switches triggered means no hot end fitted.
Is it possible to run a trigger macro with two inputs? Or do you have to read 'the other' trigger inside the macro and use 'if' conditions to finally start the right macro?
I haven't actually implemented this "hot end sensing" system on my printer yet. The hot end mounts have the lugs but I haven't yet fitted the switches to the carriage. However, I plan to use the same system that I use with the joystick jog control that I have fitted. This uses 4 micro switches and gives me movement in 8 directions depending on which combination of either one or two switches are closed. There is also a button that when pressed, gives my long moves (about 20mm) and when not pressed gives me short moves (about 0.5mm). So 8 move directions and two "speeds" (actually distances) giving 16 combinations from 5 switches. Essentially it's a single macro which uses conditional gcode to sense the status of the 5 switches. It runs a loop and repeats as long as one or more switches are closed. Here it is in it's entirety which should show how it works.
; ******Trigger 5 - Joystick lefgt,right, forward or backwards ********
; IO Pin to switch connections J5=left, J6=Right, J7=Forward, J8=Backward
if state.status != "processing" ; make sure that a print is NOT running
G91; Set relative
M400; wait for any moves to finish
G1 F3000 ; set feedrate to 100mm/sec
M118 S"Trigger 5 - Joystick"
while sensors.gpIn[5].value=0 | sensors.gpIn[6].value=0 | sensors.gpIn[7].value=0 | sensors.gpIn[8].value=0
if sensors.gpIn[5].value=0; joystick left
if sensors.gpIn[7].value=0 ; joystick left and forwards
M400
echo "Left and forward"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 X-20 U-20 A-20 Y-20 V-20 B-20
else
G1 X-0.5 U-0.5 A-0.5 Y-0.5 V-0.5 B-0.5
elif sensors.gpIn[8].value=0; joystick left and backwards
M400
echo "Left and backwards"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 X-20 U-20 A-20 Y20 V20 B20
else
G1 X-0.5 U-0.5 A-0.5 Y0.5 V0.5 B0.5
else ; joystick left only
M400
echo "Left"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 X-20 U-20 A-20
else
G1 X-0.5 U-0.5 A0.5
elif sensors.gpIn[6].value=0; joystick right
if sensors.gpIn[7].value=0 ; joystick right and forwards
M400
echo "Right and forward"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 X20 U20 A20 Y-20 V-20 B-20
else
G1 X0.5 U0.5 A0.5 Y-0.5 V-0.5 B-0.5
elif sensors.gpIn[8].value=0; joystick right and backward
M400
echo "Right and backwards"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 X20 U20 A20 Y20 V20 B20
else
G1 X0.5 U0.5 A0.5 Y0.5 V0.5 B0.5
else ; joystick right only
M400
echo "Right"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 X20 U20 A20
else
G1 X0.5 U0.5 A0.5
elif sensors.gpIn[7].value=0 ; joystick forwards only
M400
echo "Forward"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 Y-20 V-20 B-20
else
G1 Y-0.5 V-0.5 B-0.5
elif sensors.gpIn[8].value=0 ; joystick backward only
M400
echo "Backwards"
if sensors.gpIn[4].value=0 ; check for long move button press
G1 Y20 V20 B20
else
G1 Y0.5 V0.5 B0.5
else break
else break