element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Project Videos
  • Challenges & Projects
  • element14 presents
  • Project Videos
  • More
  • Cancel
Project Videos
Documents DIY Shapeoko CNC Pendant -- Episode 420
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Project Videos to participate - click to join for free!
Related
Recommended
Engagement
  • Author Author: tariq.ahmad
  • Date Created: 11 Nov 2019 10:04 PM Date Created
  • Last Updated Last Updated: 15 Nov 2019 8:24 AM
  • Views 11176 views
  • Likes 10 likes
  • Comments 81 comments

DIY Shapeoko CNC Pendant -- Episode 420

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

One of the great joys of being able to design with electronics is the ability to make your own custom tools. DJ recently picked up a CNC router and in order to make his life a wee bit easier, he’s designed and built a pendant that will allow him to more comfortably, and accurately set up his parts in the machine. Follow along as he tinkers his way to new gadget that, hopefully, will be of use or inspiration for fellow makers and CNC enthusiasts.

Bill of Material:

Product Name Manufacturer Quantity Buy Kit
Panel Mount Push Button Grayhill 7 Buy Now
5mm LED Multicomp 7 Buy Now
680R Resistor Multicomp Pro 7 Buy Now
3D Filament Verbatim 1 Buy Now
Rotary Encoder Bourns 1 Buy Now

 

Additional Parts:

 

Product Name
Teensy LC
Attachments:
Resources_DIY Shapeoko CNC Pendant.zip
image
DIY Shapeoko CNC Pendant

element14 Presents  |  DJ Harrigan's VCP Profile  |  Project Videos

  • shapeoko
  • carbide 3d
  • digital fabrication
  • fusion 360
  • cnc
  • 3D Printing
  • cad
  • usb hid
  • element14 presents
  • xxl
  • rotary encoder
  • microcontroller
  • multicomp
  • dj
  • cam
  • bourn
  • arduino
  • router
  • dj harrington
  • friday_release
  • woodworking
  • e14presents_djharrigan
  • Share
  • History
  • More
  • Cancel
Actions
  • Share
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • rogo
    rogo over 5 years ago +2
    The project is very nice but a cabling scheme would not be refused!
  • thomasvdd
    thomasvdd over 5 years ago +1
    Awesome project! I'm definitely building this, it solves exactly the annoyance I encounter when milling. Could you share the file for the front plate which includes the text?
  • DAB
    DAB over 5 years ago +1
    Nice build. DAB
Parents
  • thomasvdd
    thomasvdd over 5 years ago

    I have made the project and can confirm that the original code runs just fine.

    The behavior you described is how it is intended to function, as you can see from the code:

     

    When pressing one of the speed buttons, the activespeed variable is being changed.

     

      if (buttonFast.fallingEdge()) {

        activeSpeed = SPD_FAST;

      }

     

    The next time the loop() executes, the if statement triggers and presses a key (KEY_4)

     

    if (activeSpeed != lastSpeed){

        digitalWrite(lastSpeedLED, LOW);

        switch(activeSpeed){

          case SPD_FAST:

            Keyboard.press(KEY_4);

            Keyboard.release(KEY_4);

            digitalWrite(PIN_LED_FAST, HIGH);

            lastSpeedLED = PIN_LED_FAST;

          break;

     

    When pressing one of the X, Y, Z buttons, the activeAxis variable is being changed.

    (uncomment the serial print to verify if your button works)

     

      if (buttonX.fallingEdge()) {

        activeAxis = X_AXIS;

        //Serial.println("X");

      }

     

    HOWEVER, the corresponding button (KEY_RIGHT) is ONLY being pressed when the encoder is turned.
    Pressing the X, Y or Z button only will NOT press any keyboard key.

     

      if (abs(newScrollPos - lastScrollPos) >= 4) { // there are roughly four presses detected from each rotation to the next detent

        if (newScrollPos - lastScrollPos > -1){ // positive increase

          switch(activeAxis){

          case X_AXIS:

            Keyboard.press(KEY_RIGHT);

            Keyboard.release(KEY_RIGHT);

          break;

     

    In conclusion: if your CNC doesn't move, your rotary encoder is probably badly connected.

    Check the connections from encoder to teensy (also the middle ground pin). If that fails, I would buy a new encoder and try again.

     

    Hope this helped

    Thomas

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • thomasvdd
    thomasvdd over 5 years ago

    I have made the project and can confirm that the original code runs just fine.

    The behavior you described is how it is intended to function, as you can see from the code:

     

    When pressing one of the speed buttons, the activespeed variable is being changed.

     

      if (buttonFast.fallingEdge()) {

        activeSpeed = SPD_FAST;

      }

     

    The next time the loop() executes, the if statement triggers and presses a key (KEY_4)

     

    if (activeSpeed != lastSpeed){

        digitalWrite(lastSpeedLED, LOW);

        switch(activeSpeed){

          case SPD_FAST:

            Keyboard.press(KEY_4);

            Keyboard.release(KEY_4);

            digitalWrite(PIN_LED_FAST, HIGH);

            lastSpeedLED = PIN_LED_FAST;

          break;

     

    When pressing one of the X, Y, Z buttons, the activeAxis variable is being changed.

    (uncomment the serial print to verify if your button works)

     

      if (buttonX.fallingEdge()) {

        activeAxis = X_AXIS;

        //Serial.println("X");

      }

     

    HOWEVER, the corresponding button (KEY_RIGHT) is ONLY being pressed when the encoder is turned.
    Pressing the X, Y or Z button only will NOT press any keyboard key.

     

      if (abs(newScrollPos - lastScrollPos) >= 4) { // there are roughly four presses detected from each rotation to the next detent

        if (newScrollPos - lastScrollPos > -1){ // positive increase

          switch(activeAxis){

          case X_AXIS:

            Keyboard.press(KEY_RIGHT);

            Keyboard.release(KEY_RIGHT);

          break;

     

    In conclusion: if your CNC doesn't move, your rotary encoder is probably badly connected.

    Check the connections from encoder to teensy (also the middle ground pin). If that fails, I would buy a new encoder and try again.

     

    Hope this helped

    Thomas

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • wildmack
    wildmack over 5 years ago in reply to thomasvdd

    Hello Thomas, thank you so much for helping me out with this, it's driving me nuts.   I bought 2 encoders, so I'll try changing them out today.  I checked the impedance on the encoder, and it changed as I rotated it, so I assumed it was working.  I used the three sided pins of the encoder, outer pin goes to pin 9 on the controller, the center pin is to ground, and the other outer pin is connected to pin 10 on the controller.   I opened the serial monitor and uncommitted the serial print line and each time I press the X,Y,X buttons it shows on the output of the serial monitor screen.  Should it repeat the X,Y,Z on the screen if I turn the encoder?   I'm still learning how to program, so this is way above my understanding.  Is there any way to see if the controller is actually sending the commands, like KEY_RIGHT?  I really need to get this working, so I really appreciate your help.  I just can't figure out what I'm doing wrong.  I have tried it on Easel, and Universal Gcode Sender, and my CNC doesn't move, but it moves if I use the up,down,left,right on my keyboard.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mayermakes
    mayermakes over 5 years ago in reply to wildmack

    the commands are specific to DJs Shapeoko,

    Depending on your machine you need to change the commands it sends.

     

    If the commands are correct for your interface software it might be that the teensy does not show up as a HID for the OS, on Linux this should work find, Windows i can behave differnet depending on active drivers for other HID devices that are used on your system. MacOSX is also non problematic for most people.

    Alternatively: connect the pendant directly to your machine and make it send the Gcode commands specific to your machine : this controller does pretty much that:  an Arduino micro acts as HID for an Uno that runs GRBL
    https://www.youtube.com/watch?v=KOVkOZUeTwQ

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • wildmack
    wildmack over 5 years ago in reply to mayermakes

    Looks like the commands are the same, just sending a right,left,up,down command as a keyboard.   I'm not sure how to connect the pendent directly to my machine, I'll take a look at what you sent me and see if that will work for me.  Thanks Dave....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • thomasvdd
    thomasvdd over 5 years ago in reply to wildmack

    It's my pleasure to help, but please try to understand the code by yourself too. It's not the hardest code, well written and it's well documented.

    Turning the encoder doesn't print X, Y, Z. As you can see in the code, there is no Serial.println in that part of the code.

    You can test if the encoder is triggering (which I think is not the case) by adding serial.println, as an example (lines in bold):

     

      if (abs(newScrollPos - lastScrollPos) >= 4) { // there are roughly four presses detected from each rotation to the next detent

        if (newScrollPos - lastScrollPos > -1){ // positive increase

         Serial.println("ENCODER CLOCKWISE"); // ADDED BY THOMASVDD

          switch(activeAxis){

          case X_AXIS:

            Keyboard.press(KEY_RIGHT);

            Keyboard.release(KEY_RIGHT);

          break;

          case Y_AXIS:

            Keyboard.press(KEY_UP);

            Keyboard.release(KEY_UP);

          break;

          case Z_AXIS:

            Keyboard.press(KEY_PAGE_UP);

            Keyboard.release(KEY_PAGE_UP);

          }

        } else {

          Serial.println("ENCODER COUNTER CLOCKWISE"); // ADDED BY THOMASVDD

          switch(activeAxis){

          case X_AXIS:

            Keyboard.press(KEY_LEFT);

            Keyboard.release(KEY_LEFT);

          break;

          case Y_AXIS:

            Keyboard.press(KEY_DOWN);

            Keyboard.release(KEY_DOWN);

          break;

          case Z_AXIS:

            Keyboard.press(KEY_PAGE_DOWN);

            Keyboard.release(KEY_PAGE_DOWN);

          }

        }

        lastScrollPos = newScrollPos;

      }

     

    Since you already mentioned the speed buttons do send characters (1,2,3,4) we know that part should work.

    You could verify the CNC movement by moving the key presses to the detection of the buttons:

     

      if (buttonX.fallingEdge()) {

        activeAxis = X_AXIS;

        Serial.println("X");

        Keyboard.press(KEY_RIGHT);

        Keyboard.release(KEY_RIGHT);

      }

     

    Could you tell us the exact teensy model you are using, and include a picture of the encoder connected to the teensy?

     

    Greetings

    Thomas

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • thomasvdd
    thomasvdd over 5 years ago in reply to mayermakes

    The controller in fact does not send any commands to the arduino directly. It sends keypresses to your PC, that's it.

    Your CNC control program (Easel, universal gcode sender, whatever) interprets those and it sends the corresponding GRBL commands.

    At no point is there a direct connection between the controller and arduino running grbl.

    A controller like Clem made directly sends gcode, but that's a completely different project and would require the code to be re-written.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • wildmack
    wildmack over 5 years ago in reply to thomasvdd

    OK, I'm using the teensy 3.2   Attached are some pics of the project.  I moved theimage

    if (buttonX.fallingEdge()) {

        activeAxis = X_AXIS;

        Serial.println("X");

        Keyboard.press(KEY_RIGHT);

        Keyboard.release(KEY_RIGHT);

      }

    to the detection part of the program, and every press moves the gantry to the right, so that signal is getting through.  I changed out the encoder, but still no difference.  I took it off the breadboard and hard soldered everything together and double checked the pin connections, but no difference from when it was on the breadboard. I have the center lead of the encoder going to ground, could it possibly need to go to +    ??   Thanks Dave.....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • wildmack
    wildmack over 5 years ago in reply to thomasvdd

    imageimageimage

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • thomasvdd
    thomasvdd over 5 years ago in reply to wildmack

    Alright, good that we know the key pressing parts is working.

    I meant a picture of the connections to the Teensy, to see how you soldered it.

    Normally the encoder middle pin should be connected to ground, since the microcontroller has pullups enabled.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • wildmack
    wildmack over 5 years ago in reply to thomasvdd

    Look OK?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • thomasvdd
    thomasvdd over 5 years ago in reply to wildmack

    Wiring looks good too.

    Try adding a println here:

     

    long newScrollPos = encoderScroll.read();

    Serial.println(newScrollPos );

     

    The number should increase every time you turn the encoder.

    As an additional check, also add these lines (will trigger if the encoder gives a pulse):

     

    if (digitalRead(PIN_ENC_A) == LOW){

        Serial.println("ENC A TRIGGERED");

      }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube