Enable/Disable steppers with toggle switch

New Home Forum Mostly Printed CNC – MPCNC Advice – MPCNC Enable/Disable steppers with toggle switch

This topic contains 16 replies, has 5 voices, and was last updated by  John 3 weeks, 5 days ago.

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #46447

    John
    Participant

    Hello again all,

    I’m putting together a control box to house all/most of my electronics.  What I want to do is mount 3 toggle switches for X Y Z stepper motors to be able to enable/disable each separately if I need to.  I looked on google and didn’t find any info on how to wire the switches.  So I ask you lovely people if anyone has done this and how.  I am running external drivers on my ramps 1.4 board.

    I’m thinking I can either switch 1 coil wire from each coil (2 wires) using a DPDT toggle switch, or switch the +12V of the driver.  I’m also thinking that switching the driver on and off would/may not be that good for the driver, so I’m leaning towards my first option.

    Is there another, better option that I haven’t thought of?

    I use the LCD and don’t have a laptop/PC next to the machine to do it through repetier etc.  I really do prefer to do it manually through switches, probably more than having the option on the LCD menu (which mine doesn’t have).

     

    Any advice greatly appreciated as always

    #46456

    Sandy Currie
    Participant

    John,

    I don’t know about switches but when I want to do that I do it from the LCD.

    In the “Prepare” menu, the fifth option down is “Disable Steppers”.

    Does your board not have this option?

     

    #46457

    Jeffeb3
    Participant

    I’m curious to know your motivation for this.

    The best place would be the “enable” pin between the driver and the Arduino. You would have to pull the driver off and build a connecting circuit.

    Anytime you flicked the switch, the Arduino wouldn’t know you’ve done it. It would continue as if nothing happened.

    #46462

    Ryan
    Keymaster

    If you disconnect a driver wire while it is engaged you will blow the driver every time. Something to do with the chopper circuit sinking the power back into the driver.

    I think Sandy’s option is the safest way, or killing the power.

    #46477

    Jason
    Participant

    I’m planning on adding an arduino (most likely a pro mini since I have a bunch of them laying around.)  that will read a couple of buttons and send gcode to the RAMPS for things I do regularly.  Engage/disengage steppers is one of the biggies I want it for.  (So I can square my machine then engage the steppers and not worry about them timing out…but can also disengage them when I want.)

    For what you’re looking for you just need to scan the 6 buttons, and then send the appropriate gcode when one is pressed.  My project is a bit more complex (I’m also adding buttons for zeroing and possible homing and probing things…and am toying with a keyboard/LCD for inputting gcode manually.) but I plan on starting simple with basically just an “enable steppers” and “disable steppers” button to test how well it will work.  Just haven’t had time to mess with it since I started thinking about it.

     

     

    #46483

    John
    Participant

    Jeff it’s mainly so I can adjust the Z height before I start the job, and also aligning the machine.  This way I don’t have to turn the machine off and on, wait for the LCD to restart etc.

    I already have external drivers so I have wiring going to Ramps, giving me access to the driver wiring.

    I just checked and my LCD does have the disable steppers option.  But this will disable all.  I want to be able to disable them independently, if I have X and Y in place and all I want to do is adjust the Z height I can do it without worrying about moving the other axis.

    I might have to re think this though, as Ryan said you can’t disconnect a driver wire while it’s engaged, and I have read somewhere that when disconnecting power to a driver you should wait a while (up to a minute) before re-connecting it.

    #46489

    Jason
    Participant

    If you’re running tethered you can do it with gcode:

    Disable: http://marlinfw.org/docs/gcode/M018.html

    Enable: http://marlinfw.org/docs/gcode/M017.html

    The commands do allow control over individual axes.

    M18 Z  ;Disable only Z stepper

    If you’re ok with using the LCD for it you could fairly easily modify the LCD to have commands to enable/disable individual steppers.   In the ultralcd.cpp file on line 2567:

    https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/ultralcd.cpp#L2567

    MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR(M84));

    You could add a few lines under that like:

    MENU_ITEM(gcode, “Disable Z Stepper”, PSTR(M84 Z));

    MENU_ITEM(gcode, “Disable XY Steppers”, PSTR(M84 X Y));

    MENU_ITEM(gcode, “Enable  XY Steppers”, PSTR(M17 X Y));

    MENU_ITEM(gcode, “Enable Z Stepper”, PSTR(M17 Z));

    MENU_ITEM(gcode, “Enable Steppers”, PSTR(M17));

    You could even add them elsewhere in that file to put them closer to the top of the menus if you use them frequently.

    I’m actually still running an old RC6 version of marlin in part because I added an extra “MPCNC” menu and haven’t bothered to try and bring it over to a newer release and don’t want to give it up:  https://github.com/jhitesma/Marlin-Folger/commit/6988f456ec8eaf8ae629d0c41d873119e491e353

     

     

    1 user thanked author for this post.
    #46493

    John
    Participant

    Thanks Jason,

    I might have to go this way yet.  I will do abit more searching on the effects of turning external drivers on and off, but I can see that I will probably go this way in the end.

    Always wondered where the LCD info was.

    #46505

    Jeffeb3
    Participant

    I could see the benefit of Z alone. That makes sense.

    Making it in the LCD is a good option, and it’s very useable by others (if you care about that sort of thing). If you’re using a computer, you can also make macros for that sort of thing in repetier or pronterface or octoprint. Driving them from switches isn’t trivial though.

    Making an arduino send the gcode is a little troublesome, because you can’t then use the serial port for other things (UART is 1-1 without some goofy hardware). If you weren’t using the USB for anything else, then I could see that working. I’m not sure what would happen if you hit the button while running a print from SD.

    Removing 12V power from the driver while it’s running is a no-no (as Ryan pointed out) but cutting the stepper enable pin is the same thing that Marlin does when it disables the driver (I think, I didn’t write it 😀 ). So I think that’s actually safe. It’s definitely a “do at your own risk” type of thing though. You don’t see me doing it. My biggest complaint about the enable pin approach is that Marlin has no idea that it’s not controlling the stepper anymore, so it’s builtin logic about state when disabled (like homing after enable) will be completely off. If, for example, you had the Z at Z=2.0, and you switched off the Z, moved it down to the workpiece, and turned it back on, then Marlin would think that a) it’s at Z=2 and b) There’s no reason to think that it’s not perfectly correct.

    Definitely an interesting problem.

    #46516

    John
    Participant

    My enable pins are not connected at all. Only DIR, PUL and obviously steppers and power so not sure if I could some how use the EN pins.

     

    #46517

    Jeffeb3
    Participant

    Huh, that’s a little goofy. I don’t know what drivers you have, but if you don’t have that connected, then I don’t think Marlin can control the stepper activation via LCD either. What drivers do you have?

    This is from pololu w.r.t. drv 8825:

    “The chip has three different inputs for controlling its power states: RESET, SLEEP, and ENBL. For details about these power states, see the datasheet. Please note that the driver pulls the SLEEP pin low through an internal 1MΩ pull-down resistor, and it pulls the RESET and ENBL pins low through internal 100kΩ pull-down resistors.” (sorry, there are bars over the names on the webpage, but I can’t copy the formatting, so these are all inverted). https://www.pololu.com/product/2133

    So if you’re using drv8825’s but you haven’t connected the ENBL pin, then the drv8825 will always drive it low, which means it will always be enabled. If you connected that to the enable pin on the ramps, then the software would be able to toggle it. If you wanted to disable them manually, then you would connect ENBL to high (above 2.2v, and below 5.25V). This is with DRV8825s, you’d have to look up the info on your drivers for something else.

    Now I’m really curious about your setup. What are you doing? 🙂 If it’s crazy enough, I just might want to do it myself! I’d at least talk about it occasionally.

    #46519

    John
    Participant

    HY DIV268N are the drivers.  When I was trying to find wiring to connect them, I found 2 different ways badically. 1 way was to use the enable pins and one without.  I tried with the enable pins connected but no matter what I did I could not get the steppers to work properly.   From memory I think they would only spin one way regardless of which way you told them to go.

    Then I tried the other way and it worked as it should.

    Ahhh come to think of it it’s coming back to me now.  I just remembered I am unable to ‘disable steppers’ as when I select it from menu the steppers are still active

    #46521

    Jeffeb3
    Participant

    Interesting. So I’m guessing that pink wire is going to some constant VCC value? and the other greyish wires are going to the arduino?

    My first guess would be to wire those the other way, with the (-) side going to ground and the (+) side going to the signals. At any rate, you should be able to put a positive voltage on the EN(+) and ground on the EN(-) side and control the enabledness of the steppers. I’m still looking in this chinese translation datasheet for exactly what voltage is needed….

    https://www.rcscomponents.kiev.ua/datasheets/div268n-5a-datasheet.pdf

    It’s got a 270 Europe internal resistor 🙂

    It my chinese-english to english translation is correct, you can drive the difference with 5V without adding a resistor. If you want to drive it with 12V, then you need a 1k (Ohms, presumably) resistor.

    “EN +: offline can reset signal input side is
    EN-: offline can reset signal input negative terminal
    Offline enable signal is active, reset drive failure to prohibit any pulse, the output of the drive
    Power component is turned off, the motor holding torque.”

    So.. then if you put a 5V difference across the EN pins, that should disable the steppers… So if you wanted to drive that with the Arduino, you’d need to hook the EN(-) to ground and the EN(+) to the EN pin on the ramps board, I think. The DRV8825 expects inverted logic, so the arduino should pull that pin low when it wants to enable the motors, which would turn off the current to the EN, which would enable the driver. When the arduino wants to disable the motors, it would have to pull that pin high, which would send 5V through the EN pins to ground, and that would disable the motors.

    If you wanted to do it manually, then you could connect the EN(-) to ground, and the EN(+) to the output of your switch. The switch input would be 5V. When you closed the switch, it would disable the motors.

    #46535

    John
    Participant

    I’ll give that a go on the weekend on my days off.  I’ll try to do it manually. If all else fails I’ll sort something out.  Maybe even swap to the small plug in type drivers.  I just wanted to experiment with those drivers since I had them from an unfinished project

     

    Thank you for your help

    #46563

    John
    Participant

    I just got home early from work and literally went over to the shed straight away to try your wiring suggestion, EN- to ground and switch EN+ to 12V and you were spot on.  Well it worked.  Supplying 12V to EN+ disables the stepper motor.  So this control box is going to have 3 switches for the steppers, an ON/OFF switch, RESET switch, tool speed pot and hopefully an emergency stop as well.

    #46570

    Jeffeb3
    Participant

    Awesome. But if you’re using 12V, then you want a 1kohm resistor in line. The diagram shows an led that’s doing the enabling, so if you put too much current it will pop.

    12V -> 1k -> EN(+)

    or eventually:

    12V -> switch -> 1k -> EN(+)

    Or the 1k can be on the other side of the switch.

    #46596

    John
    Participant

    No problem, I would have a few 1K resistors.  Weekend project here I come.  Will let you know how it goes

    Thanks

Viewing 17 posts - 1 through 17 (of 17 total)

You must be logged in to reply to this topic.