586,042 active members*
3,718 visitors online*
Register for free
Login
IndustryArena Forum > CNC Electronics > CNC Machine Related Electronics > Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2013
    Posts
    14

    Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    I am a hobbiest and this is my first post, thought to share and take opinions of what I am doing. Its more of a self challenge project to learn more about electronics and Arduinos teensy etc…

    I have a CNC sherline 5410 run by Mach3, via a C11G BOB all is working fine. Two issues annoy me and have caused me some problems (honestly they are user errors, i.e. me being hasty)

    First, The spindle issues; when it over heats, the thermal cutoff turns off the spindle and you have a damaged piece or bit and mostly both. Sometimes it’s a deep cut by mistake or forgetting to reset the Z after a tool change etc…

    Second; the steppers sometimes skip steps, also due to some hasty error like a big cut or not resetting the Z as above, sometimes I increase the rapids etc…

    My small project in short is using Arduinos and a Teensy (small programmable microprocessors) hooked to sensors to measure most of the critical stats of the CNC mill, and have it control additionally the Spindle and EN-Safety switch.

    This is how I approached the issue:
    The Teensy will be the Master and receive info of the sensors via I2C from the other Arduinos, each Arduino will have a certain task to read the sensor Values, consolidate them and send them to the Teensy via I2C
    The Teensy is Also hooked up to a 4.3 " touch screen to display all the sensor values graphically. It will also control the Spindle and EN-Safety switch.

    I planned to have one Arduino for each stepper motor (lets call them Arduino UNO X,UNO Y and UNO Z); it will read the pulses and direction sent to the Stepper from the BOB, and also read the rotation status of the Stepper motor. Additionally with all the wiring I added a temp sensor for each stepper and Stepper Driver (just for fun)

    So lets say I have 1600 steps per 1 rotation of the Stepper motor, giving a movement of 1 mm. I have attached a slotted disc with 10 notches, having the notches equal to the un notched part. A photointerrupter reads status of the stepper motor rotation. each 80 (1600/20) pulses should change the status of the photointerrupter, if more than 80 pulses are detected and no change in the photointerrupter reading means the stepper started skipping.

    Now why 3 arduinos, one for each stepper. Each Arduino can monitor 2 interrupts. So 1 interrupt will be reading the pulses, the second interrupt will be reading the photointerrupter. And a digital pin to read the Direction. One Teensy can do the Job of the 3 arduinos, but I couldn't manage to get all the interrupts working... thats another project.

    As for the Spindle, I had to use 2 Arduinos, why? (lets name them Arduino UNO 1 and Arduini UNO 2
    I have my spindle wired to the C11G BOB, and according th the C11 manual, the 12V supply should not be sharing a ground with the 5V supply to the Board. The I2C communication needs to have a common ground between all the communicating Arduinos and Teensy. To solve the issue, One Arduino will be powered from a separate 12V power supply thru a 7805, which also powers the spindle 12V part of the C11G BOB. The other Arduinos, Teensy and the C11 are powered by a separate 5V Power Supply.

    So one Arduino (Arduino UNO 1) will read the Amps on the Spindle, the P2 voltage applied to the Sherline Speed Controller (0-10V) and the 0-130V out put to the motor. These values will be transmitted via 7no 4N35 Optoisolators to the Second Arduino (Arduino UNO 2), had to write a seperate code to get this working.

    The secont Arduino (Arduino UNO 2) will additionally read the spindle rpm via a photointerrupter and some Temperatures it will send all the Data to the Teensy.

    I am half way thru the project below is my status:
    • I2C communication between UNO X, UNO 2 and Teensy - Done
    • Displaying the Data on the 4.3"TFT, Done, needs refinement.
    • Custom encoder disc and Photointerrupter, mocked up and working. needs refinement
    • UNO 1 reads Dir, Pul and custom encoder Photointerrupter, almost done; problems with pulse reading
    • UNO 2 reading the spindle speed, almost done
    • UNO 1 to UNO 2 optoisolated communication - Done
    • Temeprature reading to be done last, they should not be an issue.


    This will be a long Project, and hopefully I will try updating every now and then. I do have some issues which I will be requesting some assistance but will keep for the following posts.

    Opinions, Comments are most welcome.

  2. #2
    Join Date
    Jan 2005
    Posts
    1943

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    This has come up before and I know that with linuxcnc you can simply add rotary encoders to the steppers and have linuxcnc monitor them. If the programmed position differs from the encoders by some set amount you can set it up so the mill faults and stops. I don't use Mach3, but the times this has come up before it has been said by others that mach3 can do the same. I would think that the spindle monitoring could be done through linuxcnc or mach3 as well.

  3. #3
    Join Date
    Feb 2006
    Posts
    7063

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    I would expect that approach would easily detect a stepper that has completely stalled (albeit a long time after the fact), but it's not going to help you much in detecting when you've simply lost steps, a few here, a few there, even a lot of them. And any time an axis reverses, you'll introduce an error of up to 80 motor steps in your count, due to the low resolution of your "encoders". Unless you set your error threshold very high (which would seem to defeat the whole purpose....), this error will accumulate over time in such a way that you'd be likely to either have a large error and not know it, or conclude that there is an error when there really isn't. Even an error of 80 steps, which is the very least you could possibly detect, would surely be enough to scrap the part and perhaps enough to break the tool.

    Regards,
    Ray L.

  4. #4
    Join Date
    May 2014
    Posts
    182

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    New Schneider MDM1CSZ17B4 EHL Mdrive 17 Driver Hybrid Stepper Motor CNC 3D Print | eBay

    It sounds like your router is not a super high powered one? I would look into something like the above - it'll do everything you want and more. It'll work with your BOB and step/direction inputs. You can set the following error/faults such that if a fault were to happen it could output to your BOB input and have Mach3 do something.

  5. #5
    Join Date
    Jan 2005
    Posts
    1943

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    Here is a link and description of how LinuxCNC can do it if you have enough inputs. If on a desktop like you should be with LinuxCNC, you can just add anothe parallel port board and get more.

    LinuxCNC Documentation Wiki: Steppers With Encoders

    Here is a link to encoders that can be configured for between 48 and 2048 counts per revolution

    CUI AMT102-V Encoder KIT and 6 feet Cable | Automation Technology Inc

    I decided to do some checking online about doing it in mach and although possible to do the same thing as linuxCNC and read encoder inputs, it is not "as good" apparently because mach is on Window and can't read the encoders fast enough. LinuxCNC runs on a real time version of linux and therefore can read those encoders. Apparently there are a few hardware pieces that can do this and send a e-stop signal back to mach.

    If you do go with the arduino method, have you considered using a Mega rather than an UNO. The Mega has a lot more pins. I can't believe that theer wouldn't be enough pins on a mega to do all 3 axes.

  6. #6
    Join Date
    May 2013
    Posts
    14

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    Quote Originally Posted by 109jb View Post
    This has come up before and I know that with linuxcnc you can simply add rotary encoders to the steppers and have linuxcnc monitor them. If the programmed position differs from the encoders by some set amount you can set it up so the mill faults and stops. I don't use Mach3, but the times this has come up before it has been said by others that mach3 can do the same. I would think that the spindle monitoring could be done through linuxcnc or mach3 as well.
    Thanks but I only use Mach3. Mach3 does monitor the spindle rpm but to my knowledge you can't configure Mach3 to engage EN safety and turn off spindle if the rpm's are very low or the current is very high due to an error.

  7. #7
    Join Date
    May 2013
    Posts
    14

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    Quote Originally Posted by SCzEngrgGroup View Post
    I would expect that approach would easily detect a stepper that has completely stalled (albeit a long time after the fact), but it's not going to help you much in detecting when you've simply lost steps, a few here, a few there, even a lot of them. And any time an axis reverses, you'll introduce an error of up to 80 motor steps in your count, due to the low resolution of your "encoders". Unless you set your error threshold very high (which would seem to defeat the whole purpose....), this error will accumulate over time in such a way that you'd be likely to either have a large error and not know it, or conclude that there is an error when there really isn't. Even an error of 80 steps, which is the very least you could possibly detect, would surely be enough to scrap the part and perhaps enough to break the tool.

    Regards,
    Ray L.
    You are right, Its kind of Passive Safety not Active. The way I am programming the Arduino is to count the number of pulses on every pass of the encoder (notched or un- notched part); the pulses have to be in the same direction, that's why I am monitoring the Direction output also. So the number of pulses counted are reset to zero on each change of the photointerrupter. Setting a limit of lets say 100 pulses in my case will in the worst case cut 0.0625 mm 0.0025" wrongly. I'm trying to avoid catastrophes and can live with small scratches. these accidents usually occur on the rough passes, and very rarely on the finish passes. so the scratch or over cut would most probably be not an issue.

  8. #8
    Join Date
    May 2013
    Posts
    14

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    Quote Originally Posted by 109jb View Post
    Here is a link and description of how LinuxCNC can do it if you have enough inputs. If on a desktop like you should be with LinuxCNC, you can just add anothe parallel port board and get more.

    LinuxCNC Documentation Wiki: Steppers With Encoders

    Here is a link to encoders that can be configured for between 48 and 2048 counts per revolution

    CUI AMT102-V Encoder KIT and 6 feet Cable | Automation Technology Inc

    I decided to do some checking online about doing it in mach and although possible to do the same thing as linuxCNC and read encoder inputs, it is not "as good" apparently because mach is on Window and can't read the encoders fast enough. LinuxCNC runs on a real time version of linux and therefore can read those encoders. Apparently there are a few hardware pieces that can do this and send a e-stop signal back to mach.

    If you do go with the arduino method, have you considered using a Mega rather than an UNO. The Mega has a lot more pins. I can't believe that theer wouldn't be enough pins on a mega to do all 3 axes.
    Thanks for the info and links, very interesting. The encoders I will most probably be using at a later stage (funds...) I'm just a hobbyest, and don't get income from my CNC, its just for pleasure.
    The Mega does have 6 interrupts, but the teensy has 8 as i recall and is a lot faster. the good thing about the Uno's is you can use them in their bare chip form and just add a crystal, caps and resistor. costing you like 8 bucks for a fully functional Arduino; and saves space a lot! I'll try post some pics of by breadboard they way I have it till now.

    As for the linux Mach3 issue, I have already chose Mach3 when I first started this hobby, and feel quite familiar with it. it wo't be easy to go and change to Linux for me at this stage. but thanks for your comments.

  9. #9
    Join Date
    May 2013
    Posts
    14

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    Just a quick note here on what I am trying to achieve, I am not trying to better closed loop systems or reinvent the wheel. Its just a $100 to $150 budget with the screen to get all this passive safety and some readouts. Its more of a DIY project, definitely not intended for professional systems and professionals. heck I use my CNC in my kitchen couple of hours a week.

    But I really appreciate all the comments. here are some few photos of where I am in this project.

    Attachment 272166

    The 3 no Arduino Unos (in bare format) on a breadboard and the Teensy on top under the TFT.

    Attachment 272168
    This is my mocked up encoder, planning on using a smaller end mill to try get more than 30 resolution per 1 revolution. needs to be smaller in Diameter to have a cover for it and not protrude from the stepper profile.

    Attachment 272170
    Honestly the whole Idea started by trying to display RPM and some temperatures on a nice screen.
    The top left Dial has the RPM in Yellow, Green and Cyan are for the P2 controller voltage and the Spindle motor voltage applied to the motor. The small dial with red needle is the Amps of the spindle.
    On the top Right, the graph is a continuous graph display of the RPM, Voltages and Amps.
    The bottom Dials are for Temperatures. ignore the numbers on the left, just for debugging.

  10. #10
    Join Date
    Jan 2009
    Posts
    484

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    I get the why, lol. Just to see you can (and learn something) is to me the very best of reasons, lol.

    Cool project, I'm tracking along just so maybe I can learn some myself. I'm familiar with Arduino but not Teensy.

    Thanks for posting the info!
    Q: How many tools does it take before a simple task becomes a project?
    A: Just one. I'm the Tool that turns a simple task in to a project.

  11. #11
    Join Date
    Feb 2007
    Posts
    966

    Re: Using Arduinos and Teensy to detect Spindle overload and missed Steps in Steppers

    Here is my Steplok that monitors for loss of steps. You can gang up to 8 and they can also act as a DRO so you can turn off the steppers and keep the position displayed on the screen when you crank the hand wheels.

    Step Lock, ViperServo

    Larry K

Similar Threads

  1. Missed steps
    By natev in forum Uncategorised WoodWorking Machines
    Replies: 1
    Last Post: 06-15-2014, 01:43 AM
  2. Picking up missed steps
    By ekcourter in forum G-Code Programing
    Replies: 6
    Last Post: 02-13-2014, 04:46 PM
  3. Missed steps on y axis
    By flyrobby in forum Gecko Drives
    Replies: 0
    Last Post: 07-24-2011, 05:29 AM
  4. Missed steps and back EMF question
    By wjfiles in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 3
    Last Post: 08-14-2006, 02:11 PM
  5. Missed Steps
    By fool in forum Machines running Mach Software
    Replies: 11
    Last Post: 04-05-2006, 12:51 AM

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
  •