562,490 active members*
3,727 visitors online*
Register for free
Login
Results 1 to 7 of 7
  1. #1

    Join Date
    May 2022
    Posts
    4

    Encoder Setup for M19 Spindle Position

    Hi all,

    I am after some advice on setting up my spindle to orientate to a set position for tool changer, Back ground is I have a Zenford milling machine running Mach 3, Controller is a Ethernet smoothstepper, 1024ppr Spindle encoder wired to ESS, Fanuc spindle motor controlled by a VSD (No Positioning), & I can lock the spindle by energizing the High & low speed clutch solenoids.

    My plan was to have the M19 macro run the spindle as slow as possible (20 rpm in low gear), Use the encoder for position feedback & when in position disable the spindle motor & engage the solenoids to lock in position for the tool change.

    The problem I have is getting the encoder feedback to rollover or reset every revolution so I have a 0 to 360 degree spindle position, Currently the feedback continuously increments. I should be able to reference it from the Index pulse somehow, but I am unsure of the best way to proceed. Should I be using a Macro? or a Brain? Or is there a better way I could do it? Any help or advice would be greatly appreciated.

    Brad

  2. #2
    Member
    Join Date
    Nov 2013
    Posts
    2198

    Re: Encoder Setup for M19 Spindle Position

    Hi,
    I use Mach4 and have done for eight years however I used Mach3 prior to that. I can't remember the setting, but there is a setting, that allows for 360 degree rollover.
    Even if you get that sorted I'm not sure that what you want to do is feasible, and not because of roll over.

    What you want to do is read the encoder and have Mach react by locking the spindle at a given angular position. The problem is that the motion controller, ESS, reports back to Mach every 25ms
    (default). If Mach decides that the angular position is correct then it will issue signals for the spindle to stop and lock in position. The time taken for those signal to propagate to the ESS
    and pass through the motion buffer, 180 ms (default) means that the 'around the loop delay' could easily be 200 milliseconds or more. I doubt that will be sufficiently accurate for you.

    Lets say you have the spindle rotating and jog speed, say 20rpm. The 200ms delay would equate to a 2.4 degree error as a minimum. Would that be accurate enough for the tool change
    mechanism?

    Craig

  3. #3

    Join Date
    May 2022
    Posts
    4

    Re: Encoder Setup for M19 Spindle Position

    Thanks for your reply Craig, I can get away with a few degrees of inaccuracy, the drive dogs are chamfered & have a fair amount of clearance on the holders, I see in Mach config there is a "Rot 360 rollover" selection, I assumed that was for when Axis A B or C are selected to angular, Im not sure if that can be linked to an encoder input somehow. Is it possible to use A B or C axis with the encoder feedback?.

  4. #4
    Member
    Join Date
    Nov 2013
    Posts
    2198

    Re: Encoder Setup for M19 Spindle Position

    Hi,

    Is it possible to use A B or C axis with the encoder feedback?.
    No, not really. Mach, and really little difference here between Mac3 or Mach4, are NOT feedback control solutions. This is because even if you feedback some signal to Mach,
    Machs response has to filter through the motion buffer, commonly 200ms or so. This delay totally screws any real sense of feedback. You might be able to use feedback to
    control a heating element that has a thermal time constant of seconds, but a motor requires a feedback time constant of a few microseconds, vastly VASTLY faster than Mach can do.

    You might ask well why is Mach so slow? The Windows operating system runs many tens or hundreds of threads and services in addition to our Mach application. Widows does a little of one job
    and then does a little of another job until all jobs get a little bit of work done. The problem is that Mach requires CONTINUOS service, and Windows can't do that, in fact cannot even guarantee
    even regular CPU service. If Mach lacks service our machine stalls and the steppers won't restart so we are buggered. To get around this Mach works out the trajectory of the machine for the next
    wee while, say 200ms, and dispatches that to the motion buffer to be enacted. You might say that Mach has given the machine a movement instruction including a bunch of homework to go
    on with until Mach again sees some CPU service. It's that motion delay which precludes Mach from being a feedback controller.

    Note that this is because of Windows....so all Widows CNC solutions like Mach, UCCNC, PlanetCNC and others ALL have the same motion delay. LinuxCNC is a genuine realtime CNC solution because
    it runs a realtime Linux distro.

    Notwithstanding Mach not being a feedback control it's still pretty useful. Mach plans the trajectory and passes that on to the motion control and the motion control signals
    the stepper drives. Mach assumes that the steppers get to where they are supposed to be but has no way to know if the steppers actually get there. The steppers could be closed
    loop steppers (or servos) and the stepper driver closes the loop and will ENSURE the stepper gets to where its supposed to, which is nearly as good.

    Lets say you have an encoder on a stepper. Mach issues a bunch of movement instructions, but they take time to go through the motion buffer. Thus, there is a lag between where Mach
    thinks the machine is and where it actually is. If the machine comes to a halt, then the actual position catches up with the commanded position, and all's good. Using an encoder to drive
    the DRO will ensure that it always lags about 0.2 seconds or so, and in some cases that quite troublesome in other cases its fine.

    In your case if you can spin the spindle very slowly such that the motion buffer delay/Mach reporting delay is small relative to the desired control bandwidth it might work.

    I would suggest that Mach4 is probably a better candidate for a couple of reasons. Using Mach4 Control plugin and the ESS plugin you can reduce the delays quite a lot, and are in fact
    programmable. You could have the ESS cycle frequency increase to 200Hz say, which would reduce the reporting delay to 5ms. Likewise, you can program the motion buffer to be as short as 30ms.
    Thus, the combined delay would be 35ms. Note this places a premium on well sorted PC hardware but very doable. Mach4 has a PMC module that enacts ladder logic, the advantage being it operates
    very quickly indeed, a few tens of microseconds. Lastly Lua, Mach4s scripting language is fast, much faster than VB (Mcah3's scripting language). The three things combined suggest a closed loop bandwidth of
    about 5Hz, which may well be enough for a satisfactory tool changer.

    Craig

  5. #5
    Member
    Join Date
    Jan 2005
    Posts
    14727

    Re: Encoder Setup for M19 Spindle Position

    Quote Originally Posted by BCow View Post
    Hi all,

    I am after some advice on setting up my spindle to orientate to a set position for tool changer, Back ground is I have a Zenford milling machine running Mach 3, Controller is a Ethernet smoothstepper, 1024ppr Spindle encoder wired to ESS, Fanuc spindle motor controlled by a VSD (No Positioning), & I can lock the spindle by energizing the High & low speed clutch solenoids.

    My plan was to have the M19 macro run the spindle as slow as possible (20 rpm in low gear), Use the encoder for position feedback & when in position disable the spindle motor & engage the solenoids to lock in position for the tool change.

    The problem I have is getting the encoder feedback to rollover or reset every revolution so I have a 0 to 360 degree spindle position, Currently the feedback continuously increments. I should be able to reference it from the Index pulse somehow, but I am unsure of the best way to proceed. Should I be using a Macro? or a Brain? Or is there a better way I could do it? Any help or advice would be greatly appreciated.

    Brad
    This is quite simple to do you can home the spindle just like an axis and use the Z pulse (index pulse) for the Home or M19 position, you then have adjustment on the Encoder mount or optical sensor to get it to be in the correct position

    So, you would not run the spindle at 20 RPM you just do a M19 for it to find the Home position, or the tool change call can do this also T1M6, the spindle should only rotate a max of (1) rotation when doing this.
    Mactec54

  6. #6

    Join Date
    May 2022
    Posts
    4

    Re: Encoder Setup for M19 Spindle Position

    I have been playing with Mach4, the more I play with it the more convinced I am I should bite the bullet & purchase it, I really like the PMC feature, it would make automating my tool changer a lot easier, I have been programming industrial PLC's with ladder logic for the best part of 20 years, editing screens seems to be a lot more user friendly aswell. Anyway using Mach4 I have solved my original problem of having the encoder reading 0 to 360 degrees, I found that Warp9td has a document titled "LUA Encoder in Degrees with Zero", step by step instructions how to set it up. Hopfully Mach & Ess resond quick enough to do what I need

    https://documentation.warp9td.com/Ha...esWithZero.htm

  7. #7
    Member
    Join Date
    Jan 2005
    Posts
    14727

    Re: Encoder Setup for M19 Spindle Position

    Quote Originally Posted by BCow View Post
    I have been playing with Mach4, the more I play with it the more convinced I am I should bite the bullet & purchase it, I really like the PMC feature, it would make automating my tool changer a lot easier, I have been programming industrial PLC's with ladder logic for the best part of 20 years, editing screens seems to be a lot more user friendly aswell. Anyway using Mach4 I have solved my original problem of having the encoder reading 0 to 360 degrees, I found that Warp9td has a document titled "LUA Encoder in Degrees with Zero", step by step instructions how to set it up. Hopfully Mach & Ess resond quick enough to do what I need

    https://documentation.warp9td.com/Ha...esWithZero.htm
    Many have done it with Mach3 so Mach4 should be easier to do, you will have to use DC Breaking for the spindle motor this will be done in the VFD Drive Programing, this will hold the spindle stiff or hard to turn, 0-360° is the most common way that machining centers do spindle positioning also
    Mactec54

Similar Threads

  1. AC servo spindle encoder setup mach3
    By ny_racer_xxx in forum Benchtop Machines
    Replies: 4
    Last Post: 09-10-2021, 02:13 AM
  2. Torq Cut 22 - Spindle oscillates in M19 Spindle Orient mode
    By Monroe Design in forum Bridgeport / Hardinge Mills
    Replies: 6
    Last Post: 09-10-2021, 12:38 AM
  3. Replies: 29
    Last Post: 07-10-2019, 10:43 PM
  4. Spindle Encoder position
    By Ashish B in forum CNC Machining Centers
    Replies: 0
    Last Post: 11-17-2009, 04:58 AM
  5. Spindle encoder setup
    By R.thayer in forum Controller & Computer Solutions
    Replies: 1
    Last Post: 03-03-2009, 06:57 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •