Macro trigger firing randomly
-
Hey everyone,
I have an emergency switch with 2NC and 1NO contacts (name brand one, not some cheapo) that I use to
- cut the mains power (life and neutral) for the heated bed and the 24V PSU (5V standby power is not cut)
- trigger a macro with the NO contact connecting GND to IO1.in (at the moment the macro only consists of M112)
this is how it is configured:
M950 J1 C"^io1.in" ; create input 1 on pin io1.in, pullup enabled M581 P1 T9 S0 ; trigger emergency off macro when input 1 is falling
The switch is working fine so far and does what it should do but from time to time trigger9 will randomly fire. So far it only happened when the printer was idling but I fear that it will cancel a print someday.
Wiring really isn't complicated and is completely stationary there is no movement at all, it is just
IO1.gnd - terminal(1) - emergency switch(NC) - terminal(2) - IO1.inI have have no clue why this happens, could someone help me out here?
Thanks in advance -
Update: it just happend and aborted a print midway through
-
@schild0r NO connections can be influenced by electro interference. This can cause the switch to appear closed when it's not. Ideally NC switches should be used. The other option is to make sure you're using screened cable.
If you can't do either of those, some conditional gcode to only pause when the switch has been pressed for an extended period might be the solution -
@schild0r You can try adding an external pull-up resistor in addition to the built-in "weak" pullup resistor.
Something in the 1K to 4K Ohm range would be an aggressive pull-up and would help get you some resistance to noise from motors and other things.
-
Thanks for the answers.
I am not sure about interference because this is a single cable that is isolated from others and this also happens when the machine is idle and nothing has changed for hours that could suddenly induce anything.
External pullup might be an option but just now I was wondering if it would help if I would configure the trigger to fire on a rising edge instead of a falling one and of course wire the switch to the IO1.5v (which is fed by 5V standby power) instead of IO1.gnd because if the IO1.in with internal pullup tends to fall below the threshold, it might be better to use a pulldown on it and trigger on the rising edge of the input.Btw I am using a Duet 3 6HC, so using the IO5.5v instead of IO1.gnd would just be a matter of seconds (using a different pin on the plug and changing it in software) and wouldn't require additional hardware...
-
@schild0r Let us know how it goes.
-
@alankilian forgot, theres no pulldown to enable in software... So either wire up an external one (pullup or down doesn't matter in that case) which I'd like to avoid or get another NC contact for my Schlegel switch.
-
So with try and error I found out that the problem has something to do with the cable that is running from the backpanel to the emergency off switch. It is a cable with 7 wires (7x1.5mm²) that are running mains voltage L and N to and from the switch (2 NC contacts) as well as the reset signal/macro trigger to and from the switch (NO contact) plus one PE line to connect the front of the frame to the mounting plate.
So either it was indeed interference from 230V mains voltage that was able to pull the 3.3V from the input pin 27k pullup to GND or it had to to with the wire cross section transitioning from 0.34mm² (from the input port) to 1.5mm² for the 7 wire cable in a terminal.I now replaced the 7x1.5mm² cable with a 5x1.5mm² one plus one 2x0.34mm² shielded cable for just the reset signal and haven't had the described behaviour since.
-
@schild0r Great news. Thanks for getting back to the group.
i don't want to be a "Safety Sam", but mixing high-voltage mains and low-voltage signaling wires in the same cable is a big mistake. In many states in the US it's illegal.
It can cause signalling problems like you experienced, but more importantly, if the insulation gets abraded by movement or anything, you can get mains voltage on your digital circuits which can get to metal parts of your machinery, low-voltage switches or even touch panels and it can kill people.
So be careful.
-
@alankilian I think have my machine wired up properly, with all the metal parts being continuous with PE so the RCD would trip before you get electrocuted in case of a faulty insulation on the primary/AC side (components might get damaged but you wouldn't get hurt)
Also PE is continuous with the secondary/DC 0V so if I have a faulty insulation on the DC side of things, the PSUs would error out due to their short circuit protection.
The "mixed cable" actually was the idea of an electrical engineer (German guy with quite some experience) so I didn't think much of it...