Custom Keyboard for G0704 CNC Mill, controlled by PlanetCNC software

I recently updated my G0704 CNC mill to add an external keyboard for commonly used functions. My reason for doing this was that some of the functions I use most are really buried in the menu structure of the Planet-CNC.com control software I use on the mill.

For example, I use the Zero X Offset and Zero Y Offset all the time, yet these are in a menu 3 levels deep in the software. Also, I find that having dedicated buttons is a bit safer for functions like Start, Stop, and Measure Z Offset. In particular, the Measure Z Offset button on screen is right beside the Measure Tool Offset – which does really long tool measurement sequence, involving a fixed tool location measurement – really easy to select this by mistake.

My solution was to create an external box, with the 7 buttons I use most, and connect this box to the Control PC using USB.

CNC Custom Keyboard

Here’s a video about this project:

More Details:

The Planet-CNC.com control software has keyboard codes for each menu item. You can simply type the keyboard code when the program is running, and that menu item will be executed. For example, the keyboard code for Zero X Offset is “/45211” These keyboard codes are visible when you drop down a menu in the software.

I used a Teensy 2.0 Arduino controller, which is perfect for this application as it can be configured to emulate a USB keyboard. I connected the 7 buttons to pins 0-6 on the Teensy, and connected the other side of all the buttons to the Ground pin.

  • Pin 0 – Zero X Offset (Sends keycode /45211)
  • Pin 1 – Home (Sends keycode /470)
  • Pin 2 – Zero Y Offset (Sends keycode /45212)
  • Pin 3 – Zero Z Offset (Sends keycode /45213)
  • Pin 4 – Measure Z Offset (Sends keycode /459)
  • Pin 5 – RUN (Sends keycode /401)
  • Pin 6 – STOP (Sends keycode /406)

Here’s the Arduino Sketch (the program) that I used for this project.

The software scans the pins, looking for a pin to be “Zero”, which means a key is pressed. When it finds a pressed key, it uses the println function to send the Planet-CNC keycode to the software.

Note: The keypad sends the keycode to whatever program is running in the foreground on the PC. You shouldn’t rely on this for critical keypresses like ESTOP. The ESTOP key should be hard-wired to the appropriate pin on the Planet CNC control board.

8 thoughts on “Custom Keyboard for G0704 CNC Mill, controlled by PlanetCNC software

  1. Henrik Wessberg

    Hi Rich,

    I really like the idea of having an arduino simulate a keyboard towards the planet cnc software.

    I have tried to compile your sketch to an arduino, but i am getting an error code.

    It states that keyboard was not declared in this scope.

    I am not at all experienced with arduino programming, so i have no clue what it means.

    I would be grateful for any assistance.

    Regards Henrik

    Reply
  2. Tom Cutitta

    Hi Rich,
    Love your video and your solution. I have a few questions .
    1) Which Planet CNC controller are you using with your Teknic ClearPath servos, CNC USB controller Mk3 (9 axis) or CNC USB controller Mk3/4 (4 axis)?
    2) Is one better than the other?
    3) Can you show how you wired the Teknic ClearPath servos to the controller. I noticed one Planet CNC (9 axis) has ERR pins and one (4 axis) does not.

    Thanks you in advance for your help and keep up the great work.

    Tom Cutitta

    Tom

    Reply
    1. rich Post author

      Always use the newest controller available from PlanetCNC. With each new iteration, the CPU is more capable. I’m using the Mk3/4.

      For more info re wiring the servo motors see this post, and also the comments there.
      http://makerrich.com/?p=77
      I don’t use the ERR pins. I just wire up the standard step and dir pins.

      I hooked it up according to this guide:
      https://www.teknic.com/files/downloads/clearpath_user_manual.pdf
      The motors have a lot of modes. I used SD motors – Step and Direction. This is described on page 81 of the pdf.
      Input A is direction. High= CW.
      Input B is step.
      Enable is High to enable.
      Ground the A- and B- pins.
      You need to connect power as well of course.

      Reply
  3. Ivan Kalpakchiev

    Hi to all,

    I have similar setup with 84 buttons and it works just fine, but every time when the mouse is used (for example to open a file) the MDI field loses focus and I have to click on it to put it back in focus.

    Is there a way to avoid this or is there a short cut to go in MDI mode?

    Regards Ivan

    Reply
    1. rich Post author

      Yes, that is an issue. The Planet CNC software needs to be in the foreground in order to receive keystrokes. You could contact support at Planet-cnc.com to see if they have any ideas.

      You may be able to come up with a keyboard macro or something that makes the Planet CNC app come to the foreground, or maybe the app developer needs to register a global keyboard hotkey that would always bring the app to the foreground.

      I find that I’m interacting with the app enough that it’s always the foreground app for me. Also, I am using a dedicated PC to control the CNC, so nothing else will ever grab the foreground. I keep it clean – no browser running or any other apps at all.

      Reply

Leave a Reply to Henrik Wessberg Cancel reply

Your email address will not be published. Required fields are marked *