Analog buttons for machine control

New Home Forum Mostly Printed CNC – MPCNC Hardware Development – MPCNC Analog buttons for machine control

This topic contains 5 replies, has 2 voices, and was last updated by  Leo69 1 year, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #6067


    I found this interesting post:,307988,612660#msg-612660. I’ve posted a question about it there, but thought I’d check here as well, in case anyone has done this or knows what I would need to do to make one.

    According to the post, he has a bunch of buttons, each one apparently hooked up to a different valued resistor, so that pressing any single button sends a discrete voltage to pin D0 on the ramps board. Each voltage has an associated bit of gcode that is sent to the ramps board, and the machine does whatever the command is. It’s stated in the post that nothing needs to be done to the firmware, but it provides a sketch that contains voltage/gcode pairs. How would the I incorporate that sketch into my MPCNC setup? What would the value of the resistors need to be?

    Thanks for any help!



    Hi Karl. Sounds like you’re describing a multiplexer circuit. There are plenty of tutorials for doing this with arduino but definitely a firmware mod. Now that I’m running Ramps I’m planning on making a number of changes. I’ve already modded my firmware to accept file extensions with g or n. I’m planning to create a pendant to control axis movements, laser power and zero touch plate set up too.

    How many buttons did you need? I was looking at ramps schematic and it looks like there’s a few unused i/o pins there so lots of opportunity to add input device. Since Marlin accepts commands and reports status over serial protocol the ideal thing is to use a cheap arduino pro micro to build a pendant with xyz axis display and jog controls as a seperate device and have it communicate with marlin over a serial( wired or Bluetooth) connection.



    Hi Leo. I’m glad to hear your mod for g and n filenames worked – I plan to do it soon.

    Controlling axis movement, laser power, and touch plate are my main goals for analog controls. Maybe a button to set zero offsets. Sounds like we are on the same page as far as what we want. I think you are much better equipped to actually accomplish it, though.

    I don’t really care if there is a display (I have the smart LCD already), or whether it’s a wired pendant, wireless pendant, or just a mounted control board. My main desire is to have my most commonly needed functions available at a single button push, instead of scrolling through menus on the LCD.

    I will see what I can find about multiplexer circuits. The project I linked to in the original post had 24 functions, plus power on/off, which would be plenty for my needs.

    Let me know what I can do to help. Do we want to start by documenting our requirements?



    I’m accustomed(spoiled) to a PC monitor with Mach3 so I think I’ll find the RepRap LCD a bit awkward. It doesn’t bother me on my 3d printer but a router needs more operator involvement and just jogging an axis is a frustrating exercise with the Marlin interface. There are some unused pins on the Mega2560 that we could use for controls but they’re hidden by the Ramps board so it would be a pain to break them out. On top of that, using those pins would require significant firmware edits which I prefer to avoid because I do plan to put an extruder on my build at some point and want my Marlin to be fully compatible.

    I think a cheapo Chinese Arduino pro micro or mini clone would be perfect for a standalone pendant device and if we use a serial hookup we’ll just be sending commands that are already built in to the firmware the same way that host software like Printrun and Cura do. This means less firmware edits and maximum compatibility. I think we agree on requirements but you can PM me and detail them. Last year I designed and built a prototype 4-port Mitutoyo gage interface with HID output using a pro micro with about $20 in parts. People couldnt’t believe those things sell for around $500 in the commercial marketplace. I used every single input and output pin and still didn’t have enough for the eight buttons and rotary controller interface so I used a multiplexer circuit like you mentioned and it worked perfectly. I wouldn’t connect more than 5 switches per analog input myself. The more switches, the smaller voltage difference between each one. This increases the odds that a dirty switch may read as a different button due to the increased/decreased resistance and you don’t want that with a CNC control. If we build a pendant device using a separate MCU then we should have plenty of I/O pins available and possibly avoid the need for a multiplexing circuit.

    I gave you some bad info on the filename extension mod the other day. Guess I read it to fast:) The correct patch is for the carreader.cpp file in the Marlin folder as I mentioned before.

    Find this line:
    if (!filenameIsDir && ([8] != ‘G’ ||[9] == ‘~’)) continue;

    Replace with:
    if (!filenameIsDir && (([8] != ‘N’ &&[8] != ‘G’) ||[9] == ‘~’)) continue;

    That patch will allow display of files with extension beginning with ‘G’ or ‘N’. I’m still connecting my motors to the Ramps board but I did load this firmware patch and was able to test and see that files displayed as expected and ran when executed.



    I’m excited about this project. I don’t have a lot of experience with arduino and the other parts, but I have a pretty good understanding of how they work, and I’m eager to learn more. Any estimate on what it will cost? Once we have a BOM (or even just an initial BOM), I’ll start collecting the parts needed.

    I’ll PM what I think my requirements would be sometime tomorrow. I need to think about it. Would it work similar to the one I originally referenced – each button push would trigger some gcode on the ramps for execution?



    Yes each button can trigger any command that marlin can respond to over serial connection including gcodes and mcodes. Pretty much anything you can control with host software like printrun can be done.I have drawers full of electronic parts so i can breadboard a prototype and give you a better idea about bom and cost once i know requirements.

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

You must be logged in to reply to this topic.