Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    VESC spindle control for CNC mill

    Scheduled Pinned Locked Moved
    CNC
    4
    9
    1.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • keyz182undefined
      keyz182
      last edited by

      I'm looking at controlling a CNC mill spindle at the moment. I have a basic module that accepts PWM, and runs the motor, but it's cheap and nasty. I'd like to use a VESC to run the motor, allowing me a lot more control and tweak-ability to things.

      The VESC however is targeted at RC, and so rather than PWM, it takes PPM (pulse position modulation). Is it possible to get the duet to output PPM rather than PWM for a spindle? That is, is it electronically possible (I suspect so), and is the firmware capable (I can't see any info, so I'm guessing it's not implemented).

      How big of a lift would it be to add PPM if it's not there currently? There are various Arduino sketches out there to convert PWM to PPM, which I could stick in the middle if it came to it (but no extra bits is always better!). Also the VESC can do analogue control, so I could wrap the PWM out in a low pass filter (I think) to get a good enough analogue level to control.

      The VESC also accepts UART and I2C control, but I don't know if that would be any easier than the above.

      JoergS5undefined 1 Reply Last reply Reply Quote 0
      • JoergS5undefined
        JoergS5 @keyz182
        last edited by JoergS5

        @keyz182

        According to http://vedder.se/2015/01/vesc-open-source-esc/ the VESC can produce PPM itself: "Optional PPM signal output. Useful when e.g. controlling an RC car from a raspberry pi or an android device."

        So you can let the VESC do the work (which I would not let do the Duet, because it seems to be processing intensive).

        So the question is how to control the VESC. The description of protocols is a bit mixed: "Interface to control the motor: PPM signal (RC servo), analog, UART, I2C, USB or CAN-bus."
        PPM and analog is to create the pulses, which you don't need, because of PPM above.
        The other proctols will be there to control the VESC behaviour.

        I would think the I2C is best to proceed, e.g. discussed here: https://forum.duet3d.com/topic/4887/i2c-bus/3

        Edit: better a different protocol according to http://vedder.se/forums/viewtopic.php?t=1417
        Or I2c is implemented in the meantime...

        One issue to think of: to use I2C, you may need a level shifter to change the signal base between 3.3 and 5 volt. But this needs to be clarified.

        Switching to the UART option: https://forum.duet3d.com/topic/7036/connecting-paneldue-and-arduino-to-one-serial-port
        Here you have to check for potential level shifter also.

        dc42undefined 1 Reply Last reply Reply Quote 0
        • keyz182undefined
          keyz182
          last edited by

          The PPM out iirc is for providing feedback, I can't exactly control the VESC using itself 😛

          PPM is only a control method for the VESC itself, similar to PWM controlling a servo. Think of the VESC as the electronics in the servo.

          My understanding is that PPM is very similar to PWM, except that the duty cycle is fixed rather than modulated, and instead the start point of the cycle is modulated. So this wouldn't be much work beyond what the duet already does for PWM.

          I'd be happy to go with any control method, what I'd like most though is something that will work directly with M3 and M4 commands, to minimise/eliminate post processing.

          I'm aware the duet can send I2C commands, but can it be configured to send those to e.g. set spindle speed if on M3/M4, or do I need to add post processing to insert the I2C gcode?

          JoergS5undefined 1 Reply Last reply Reply Quote 0
          • JoergS5undefined
            JoergS5 @keyz182
            last edited by JoergS5

            @keyz182

            As far as I know, M3 is not implemented in the firmware. see below

            For VESC I have no more ideas, only one: there is a VESC Tool at https://vesc-project.com/vesc_tool with source code on github which can help you analyzing how to handle VESC.

            1 Reply Last reply Reply Quote 0
            • keyz182undefined
              keyz182
              last edited by

              https://duet3d.dozuki.com/Wiki/Gcode#Section_M3_Spindle_On_Clockwise_CNC_specific

              M3,4, and 5 are all implemented.

              Thanks for the pointers, but it's all stuff I'm aware of, my questions are more directly to @dc42 about implementing in firmware.

              I have ways that work now, either with a converter to take PWM from duet and output PPM to VESC, or by converting PWM to analogue with a filter. I would just prefer to use PPM directly, if possible.

              Catalin_ROundefined 1 Reply Last reply Reply Quote 0
              • Catalin_ROundefined
                Catalin_RO @keyz182
                last edited by

                @keyz182 What kind of spindle are you using? DC or induction?

                keyz182undefined 1 Reply Last reply Reply Quote 0
                • keyz182undefined
                  keyz182 @Catalin_RO
                  last edited by

                  @catalin_ro It's a BLDC motor, thus the use of the VESC. Very similar to this - https://www.banggood.com/400W-12000rpm-ER11-Chuck-CNC-Brushless-Spindle-Motor-with-Driver-Speed-Controller-and-Clamp-p-1149321.html

                  1 Reply Last reply Reply Quote 0
                  • dc42undefined
                    dc42 administrators @JoergS5
                    last edited by

                    @joergs5 said in VESC spindle control for CNC mill:

                    So the question is how to control the VESC. The description of protocols is a bit mixed: "Interface to control the motor: PPM signal (RC servo), analog, UART, I2C, USB or CAN-bus."

                    I presume "PPM signal (RC servo)" means the standard RC servo protocol, as generates by the M280 command in RRF. So i suggest you use that. I2C should only be used except to connect devices within the same PCB, or devices on two PCBs that are very close to each other, because it is not tolerant of noise.

                    Duet WiFi hardware designer and firmware engineer
                    Please do not ask me for Duet support via PM or email, use the forum
                    http://www.escher3d.com, https://miscsolutions.wordpress.com

                    keyz182undefined 1 Reply Last reply Reply Quote 0
                    • keyz182undefined
                      keyz182 @dc42
                      last edited by

                      @dc42 Aaah, I see. I had gotten mixed up at some point assuming that the output from M280 etc was PWM, not PPM (from my understanding, yes, standard RC servo protocol).

                      If that's the case, I just need to figure out the wiring. While the VESC seems like solid hardware/software, I've found it's documentation to be vague, and highly disconnected - I've been spoiled by Duet! 😛

                      I'll post here for future reference if/when I get everything working.

                      1 Reply Last reply Reply Quote 0
                      • T3P3Tonyundefined T3P3Tony referenced this topic
                      • First post
                        Last post
                      Unless otherwise noted, all forum content is licensed under CC-BY-SA