Announcement

Collapse
No announcement yet.

_ Advice, Help and Info with a stepper motor and Arduino

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • _ Advice, Help and Info with a stepper motor and Arduino

    I would like to start a long term project (converting a manual mill to a hybrid) .

    First stage will be hooking a stepper motor to the Z axis and (hopefully) controlling it manually with a homemade “pendant”. This will be a long term use (and focus of this thread) in case the full hybrid project never gets finished.

    For the record, I know nothing about stepper motors, drivers or Arduino.

    Mill head weighs around 200lbs
    Right now i have no plans on swapping the current lead screw to a ball screw.
    Currently I have a 12v cordless screw guns motor moving the head up and down, the motor does not strain too much while moving the head up, obviously coming down is not a problem.

    What I would like to do:
    • “rapid” with a momentary toggle switch
    • feed with a toggle switch
    • potentiometer to set the feed
    • move the head at .0001 .001 and .01 increments with a hand wheel and selector switch
    • have a re-settable readout which can be used as a DRO (I understand there is a lot of room for error & backlash counting on the lead screw like this and not using real scales, but for the Z, i would just like to zero out and then move down xxx distance)
    • bore & drill to a depth by hooking up a number pad to Arduino, keying in distance (displayed on a second readout) then flip a switch to “engage/start”
    • Use a 12v PC power supply to run everything


    So far heres where im at:
    • Stepper motor (Nema 34 1290 oz) too big, too small ???
    • Arduino Mega 2560 or Arduino Due (knowing nothing, they seam to have the most flexibility/options)
    • Arduino Motor Shield to drive the stepper motor


    The motor will mount on side of column and drive the lead screw via a pulley (have height issue, can not directly lead screw)

    Questions:
    How do these Arduino boards work ?
    1. Do you write the code on a PC
    2. hook a PC to the Arduino
    3. offload the code to the Arduino
    4. disconnect the PC from the Arduino
    5. and now the Arduino runs as a standalone with the code you saved to it ?



    Since I have no need for a PC in the current plan, I do not want one in the operation. I would like to use the Arduino like a “stand alone” device.


    With all of that said, am I close, will it work, what else do I need ?
    What would be better, Arduino Mega 2560 OR Arduino Due ?
    Aside from the switches, buttons, displays, etc for the “pendant” and the code; will the stepper motor, Arduino Mega and Arduino Motor Shield accomplish what im looking to do ?

    Hope I didn't miss anything...
    Any input would be great, any input conveyed like im a simpleton would be better

    Thanks...

    _
    ~ What was once an Opinion, became a Fact, to be later proven Wrong ~
    http://site.thisisjusthowidoit.com
    https://www.youtube.com/user/thisisjusthowidoit

  • #2
    Hi

    Questions:
    How do these Arduino boards work ?
    They are a little micro computer on a standard circuit board that you can program yourself and you can plug various sub boards in to. The sub boards are called 'shields'

    Do you write the code on a PC
    Yes, it is easy if you are experience with versions of 'C'.

    hook a PC to the Arduino
    There is a USB socket on the Arduino


    offload the code to the Arduino
    It is all taken care of in the editor program that you use to write the program.

    disconnect the PC from the Arduino
    Pull the USB cable out!


    and now the Arduino runs as a standalone with the code you saved to it ?
    Yes, thats right although it will need a power supply which you would not have needed when it was plugged into the PC's USB port.

    With all of that said, am I close, will it work, what else do I need ?
    You will need bits and pieces, which may be available as shields, to connect the Arduino to the actual physical devices you want to use. You will need a stepper motor shield and you will need power supply for the Arduino and the stepper(s).

    You will also need some means on putting your commands into the Arduino which might be a shield with push buttons or something custom built that you connect to a port on the Arduino.

    What would be better, Arduino Mega 2560 OR Arduino Due ?
    I think any Arduino would do your task, otherwise sorry but I am not familiar with the various versions available.

    Aside from the switches, buttons, displays, etc for the “pendant” and the code; will the stepper motor, Arduino Mega and Arduino Motor Shield accomplish what im looking to do ?
    First thing is make a detailed plan of exactly what you want to do and go online to get the plan checked by others more experienced. Here as it is a machining application or the Arduino website where there is a lot of knowledge and helpful people (there are also some smart alek snot gobblers who should be confined to their mothers basement, but thats another story.)
    Last edited by The Artful Bodger; 05-26-2014, 09:10 PM.

    Comment


    • #3
      From what little I think I know, the Mega 2560 is way,way overkill for what you want to do. The Uno seems to be quite popular and should be more than capable. I don't think you will be able to move an ordinary 200 LB mill head in 0.0001" increments, the inertia and friction would be too great. I doubt you could get a 0.001" movement, although you could probably get either 0.250" or 0.251". I can't comment on your motor choice except to say it depends a lot on how fast you want the head to move. Unless using a servo system, the motor, screw, head, and other parts have to accelerate from a standstill fast enough for the system to not lose steps and that seems to be the critical requirement for motor power. A too small motor can work but the performance may not be adequate for you.

      You have undertaken a pretty big job, but with time, effort, and money it can certainly be done. Gook luck and keep us posted on your progress. There are a lot of people smarter than me that can help you along.
      Don Young

      Comment


      • #4
        have another look at your torque requirements. You won't find a Arduino Stepper Driver Shield that'll turn that monster you want to use.

        my 2cents: You've bitten off far too much for a first project. Don't get bogged down by feature creep. Get a small stepper, Uno, and driver to go up and down, THEN add functionality. Otherwise you'll likely loose your mind. These type of projects NEVER work the first time.

        Do keep us posted!
        Last edited by superUnknown; 05-26-2014, 09:39 PM.

        Comment


        • #5
          Thanks guys...
          As for the coding, im not worried about that, ive played with a few different languages and have peeked at some things written for Arduino, thats something i can grasp... how much torque i need and how many in/outs terminals/pins and IO/PWM i have no idea.

          Thanks for the brake down Bodger.

          Don Young
          For now, speed is not something which i really care about. The current lead screw rides in a bronze (im assuming, as long as its the same as the X and Y) nut. So i cant go crazy and wear it out. Ill have to do alittle figuring and find out the speed at which the current cordless motor is working at, that current speed would be fine for the "rapid". The reason for choosing the Mega 2560 or more so the Due was the In/Out, IO/PWM and size of RAM. In the end, to do everything i want, it will take alot of code (i think).


          For the first stage (controlling the Z), thats my plan superUnknown, getting rid of the cordless motor (even tho its much better then the hand crank) and just getting a momentary toggle switch in place, then potentiometer and feed switch and so on. I dont expext to do the whole thing all at once.

          More questions:
          * To move the 200lbs head on the mill at the speed in this clip, what size stepper motor should i use ?

          * How many IO/PWM will it take to: rapid up and down via a momentary switch, feed up and down via a toggle switch and use a potentiometer ?

          Not know how the electronics works, i would guess:
          momentary switch = 2 (1 up 1 down)
          toggle switch = 2 (1 up 1 down)
          potentiometer = no clue
          stepper motor = 3 (1 CW 1 CCW 1 Brake)
          7+

          While peeking around i came across someone talking about a number pad saying (stock) it will take up 7 of your digital input/output pins:
          http://www.instructables.com/id/Ardu...Matrix-Keypad/



          _
          ~ What was once an Opinion, became a Fact, to be later proven Wrong ~
          http://site.thisisjusthowidoit.com
          https://www.youtube.com/user/thisisjusthowidoit

          Comment


          • #6
            Steppers operate on pulses, knowing the gear ratio between the motor and the screw (ie one 360 turn of the motor results in how much rotation of the screw on the mill) and the number
            of pulses the stepper provides per 360 rotation, which is standard info on the motor nameplate, you can use the arduino to count the pulses needed to move the elevation screw through a given distance. The arduino does the math to convert distance, entered by number pad or rotary wheels that generate pulses as you turn them (google stepper motor
            pendants for examples) You calibrate the wheel or number pad for fractional or full inches or have a separate switch with 1x, 10x and 100x as pulse multiplier. The arduino takes
            the input, makes the calcs to convert to pulses and outputs the needed number of pulses to the motor driver. Stand alone pendants are available. For a primer on stepper functioning
            look at:
            https://www.geckodrive.com/gecko/ima...cs%20Guide.pdf
            Steve

            Comment


            • #7
              thanks sch...
              Originally posted by sch View Post
              ....The arduino does the math to convert distance, entered by number pad or rotary wheels that generate pulses as you turn them....
              When you say "the arduino does the math" do you mean the Stepper Driver Shield (arduino main board or what ever) or do you mean the code writing (by me or who ever) does the math ? Can you elaborate alitte more with that ?

              I was under the impression i would have to write the code for this:
              simple example:
              pulleys are 1:1 and the lead screw is a 10 tpi (dont know if it is or not, just an example)
              I want to feed down with a boring head .05
              so when i hit the "auto feed button", that sends a signal to the Arduino and my code tells the stepper to "pulse" 180 times CCW
              or
              do you save the necessary info to a "config file" once: pulley ratio, lead screw tpi, what ever motor info is required, then you just tell the Arduino to move this direction, this far and it does the math ?

              Like i said, a simple example, im just trying to understand the logic and communication behind this.

              Ive seen the cost for some of the pendants (they might be tossing an old W&S retro CNC lathe at work and im gonna see if i can have the control and gut it out and use what i can) and for the end result in what i want to do with the Z, those pendants will not do it. If i ever get the full hybrid done, i will buy one then, but for this project, they will not fit the bill... + theres no learning when buying one
              ~ What was once an Opinion, became a Fact, to be later proven Wrong ~
              http://site.thisisjusthowidoit.com
              https://www.youtube.com/user/thisisjusthowidoit

              Comment


              • #8
                Okay its way early in the morning to write for a proper answer, as I'm heading to work in like 5 minutes, but having toyed with Arduinos for a couple of years almost has taught me a lot and I can give you some very detailed ideas for your system that will save coding, money and headaches For the record, I'm the guy who built a working wire EDM with an Arduino So stay tuned, I'll pop back in about 10 hours or so.
                Amount of experience is in direct proportion to the value of broken equipment.

                Comment


                • #9
                  That would be great, Jaakko - thanks.
                  If you could post a link to your EDM that would be nice (never seen it), just tried to search using your name and EDM and forum "error".
                  The following words are either very common, too long, or too short and were not included in your search: EDM

                  [edit]
                  found some stuff, will do alittle (more) reading.
                  https://www.google.com/search?q=Jaak...pmachinist.net

                  _
                  Last edited by iMisspell; 05-27-2014, 12:04 AM.
                  ~ What was once an Opinion, became a Fact, to be later proven Wrong ~
                  http://site.thisisjusthowidoit.com
                  https://www.youtube.com/user/thisisjusthowidoit

                  Comment


                  • #10
                    I was under the impression (I have zero experience with coding) that the arduino could count and make pulses. I presume the device could be programmed to accept an input that corresponds to the number of inches desired, have a table with the pulley/tpi etc ratios that converts inches to pulses and then calculate the number of pulses needed to get that
                    movement. The arduino motor shield is way underpowered for this, I think you would need a more robust controller such as a Geckodrive or Keling motor contoller. Motor controllers
                    work by pulsing the stepper with 10-20x the rated motor voltage at the rated motor current, which the controller is set for. The arduino shield just doesn't have the voltage rating needed for moving a milling table. With this in mind, disregarding cases, switches, power supply and steppers, you are already upwards of $200. All of this is conceptual only, sorry no direct experience. From another POV, a surplus (older) windows computer, with vista or xp and a parallel port, a $200 Mach install will drive a motor controller and stepper under keyboard control. Assuming computer is free, the hardware is going to be about $250, software $200. You will be hard put to beat that with an arduino. Depends on what you have available.
                    Best to see what Jaako suggests.
                    Steve

                    Comment


                    • #11
                      Yes, you can count and make pulses, if you program it to. You can use the accelstepper library to control a step drive.

                      I would skip the arduino and get a beaglebone black and run linuxcnc on it. That would be the quickest way to get you going and one of the cheapest.

                      Comment


                      • #12
                        Im completely open to suggestion and ideas, checking out beaglebone now, thanks macona.

                        In the past i seen (well... im pretty sure i seen) something with linuxcnc and pendants. For now (at this stage), the only thing which im not looking to do is CNC any part of the Mill. I want to control the Z with per-programed "buttons and switches", a standalone unit with out a PC to operate the system.
                        ~ What was once an Opinion, became a Fact, to be later proven Wrong ~
                        http://site.thisisjusthowidoit.com
                        https://www.youtube.com/user/thisisjusthowidoit

                        Comment


                        • #13
                          Im not suggesting CNCing the mill, just using it as a motor controller.

                          Jog boxes are easy to use with linuxcnc, an encoder for the hand wheel and a rotary switch to select the increments. Get a little HDMI display from adafruit and you have your readout.

                          http://www.adafruit.com/products/1726

                          Comment


                          • #14
                            John at NYC CNC has some videos on Youtube related to your contemplated project. He also has a website with blog details of some projects using Arduino and Raspberry Pi. Specifically, he has a video dealing with Nema 34 steppers used with an Arduino:

                            http://www.nyccnc.com/driving-large-...h-arduino.html

                            --
                            Cheers,
                            Gary

                            Comment


                            • #15
                              Okay, finally back home again Hmm, lets see what the wish list for Santa says:

                              • “rapid” with a momentary toggle switch
                              • feed with a toggle switch
                              • potentiometer to set the feed
                              • move the head at .0001 .001 and .01 increments with a hand wheel and selector switch
                              • have a re-settable readout which can be used as a DRO (I understand there is a lot of room for error & backlash counting on the lead screw like this and not using real scales, but for the Z, i would just like to zero out and then move down xxx distance)
                              • bore & drill to a depth by hooking up a number pad to Arduino, keying in distance (displayed on a second readout) then flip a switch to “engage/start”
                              • Use a 12v PC power supply to run everything
                              Looks like a walk in the park compared to the wire EDM project I did (YouTube videos of the machine and its controller at that link if interested), all of those are very easily done with the Arduino and a few components.

                              Lets break it down to controller and power side. On the power side we have the stepper motor, stepper motor controller and a stepper motor power supply. On the controller side we have the Arduino, switches, pots, etc. These are both separate systems, as the only link between them is a line of signal cable.

                              Power side

                              Stepper motor has to be strong enough to move the machine, of course, unless you counter balance so it is only slightly heavy. Other option is to use reduction pulleys and timing belts. I can't offer a solution to the question "how much is enough", but I would think that the NEMA34 size covers your need.

                              Stepper controller of course has to handle the current you want to feed to the motor. These controllers are usually equipped with two signals, DIR and STEP. Whenever there is a pulse transition (usually from low to high) on the STEP input, the motor controller advances the stepper motor to the direction specified by the DIR input. There is no set code for this, but low can be clockwise and high counter clockwise. The output of this controller is the motor. Your problem is that there is not much possibilities to use a PC power supply for these, as the voltage is kind of too low for any reasonable operation and speed.

                              These are available widely and I would go with something like these. They are cheap, robust, come ready to bolt in and have DIP switch settings for the motor current and the microstepping size.

                              Stepper motor power supply is needed if you want good speed and solid operation. The more volts you put to the motor, the faster it can accelerate and move, but to a limit. Usual voltages I've seen and used are between 30-50 VDC and these have usually been restricted by the motor controller specifications. You can find a switch mode power supply (SMPS) from eBay for quite low money. This supply doesn't have to regulated, just smoothed out DC voltage is fine. A crude but effective system is a transformer, bridge rectifier, big capacitor and then feed that to the controller. Again, specs for this power supply come from what your motor can handle as a current and what the controller can output, and what voltage your controller can handle.

                              So in short, you need to choose a motor, looks at its current rating. Then find a controller for it that can supply up to that or more. Then look up a power supply that can supply that current and in the voltage range your motor controller wants.

                              This power side is what you will mostly spend your money on, as the rest is pennies compared to a beefy stepper motor, its controller and the power supply.


                              Controller side

                              According to the requirements, here is a list of what you need:
                              • Arduino microcontroller card
                              • keypad
                              • toggle switch for feed up/down
                              • push button for rapid
                              • potentiometer for setting the feed rate
                              • multi-position selector switch
                              • hand wheel for jogging
                              • some type of display


                              Arduino board can be just about anything, as long as it has enough inputs and outputs for all the stuff we need to connect to it and enough program memory for all the functions. At this point I would guesstimate that the Arduino UNO board would suffice, as it has 13 digital I/O pins and 6 analog inputs which can be used as digital inputs/outputs also (though not recommended when trying to read analog values also).

                              Keypad is an easy one, eBay is full of them. I would opt for the same type of membrane pad as I used on my wire EDM, a 4x4 keypad, as it has all the numbers, four "function" keys, and nice START and STOP keys.

                              Depending on how this keypad is connected to the Arduino, it can swallow either 8 pins (4 rows and 4 columns) or you can get clever with resistor dividers and connect it to only one analog input. Lets see what all the else would need and go from there.

                              Feed up/down toggle switch could be (ON)-OFF-(ON) type, meaning it is normally in the off position and returns to the OFF position when you let go of it.

                              Rapid movement is caused by pushing a button while feeding up or down, so a simple momentary push button works here.

                              Potentiometer for setting the speed requires just one analog pin from the Arduino and the pot can be something like 4.7k - 10k, the value doesn't matter much.

                              Multi-position switch, a.k.a. rotary switch to select jogging rate when using the hand wheel. This can consume pins on the Arduino either many or, again, just one with clever resistor divider.

                              Hand wheel for jogging. Now, either you can buy one and pay dearly, or you can build your own. The hand wheel is basically a quadrature encoder with a fancy knob and a detent. This will eat two pins from the Arduino board, as it requires two signals to dinstinguish direction.

                              Luckily, small versions of these exists and they have a detent already built-in, they are not 100 pulses per rev type but I assume that doesn't matter. Now all you need is a hole to place that in and make or buy a knob you like.

                              Display is of course needed. A 7 segment display would have been very easy and very cheap if all you wanted was just the position, but using it for inputting numbers or a drilling cycle, while possible, a PITA to do and especially use. So, lets opt for a nice 20x4 character LCD with an I2C backpack, which lets us use only two pins from the Arduino instead of 6 or more.

                              Power supply has to be included, as the Arduino requires either a good regulated 5 VDC supply or 7-12 VDC raw input to function. I would suggest using the raw input and feeding it with a 9 VDC wall-wart, as the Arduino has a nice power jack connector on board. The LCD will gets it power from the Arduino.

                              ----------------

                              Everything else is then just code and wires to put it all together, but lets rethink some of the things we listed and see if they are really needed.

                              Lets first see what the pin requirements are for different things, so that we know if the Arduino UNO is sufficient for this or if we need the MEGA version.

                              Available pins are 2 - 13 (digital) and A0 - A5 (analog). Pins 0 and 1 are used for the USB serial connection TX and RX and thus are off-limits.
                              • LCD with I2C backpack requires pins A4 and A5.
                              • potentiometer needs one analog input, lets say pin A3.
                              • assuming you use the small rotary encoder, we need pins 2 and 3 as they are the hardware interrupt pins
                              • the button for rapid needs one input, lets assume pin A2
                              • motor controller needs 2 pins for outputting the DIR and STEP signals, for example pins 4 and 5
                              • 4x4 keypad requires 8 pins, so pins 6-13 are now used too


                              So it seems that an Arduino UNO is capable of handling it all in terms of pins needed. All the digital I/O's were used and half the analog I/O's, but it got everything to spec. And I'm sure the 32 kB program memory is plenty for all this, as this is actually a pretty simple system.

                              You may notice from this list that I dropped some of the switches as you now have a full 4x4 keypad that has 4 function keys plus the START and STOP button and you have a 20x4 character LCD, so programming a few functions for the keys is easy and menus can be done also easily.

                              For example, one menu item could be the drilling cycle, where you can input your total depth, pecking depth and starting position and hit START to get it drilling.

                              One of the function keys would switch the jog size when pressed repeatedly and one of the choices would be "disabled" so that knocking the handwheel does nothing.

                              Couple of the function keys could be the simple up/down selection to drive the Z axis at the speed set by the potentiometer.

                              Menu options could be selected with number keys from the main menu and then using the STOP button to get back to main menu.

                              -----------

                              So there you have it, somewhat complete breakdown of the system with soe component ideas, programming ideas and such Though I would use an Arduino Micro or Mini Pro as they are meant for permanent installations and are much smaller in physical size but still functionally the same as the UNO board. They just require an FTDI USB cable to program.

                              Anything larger and I would hop the Arduino MEGA 2560 board and design a separate shield PCB for it.
                              Amount of experience is in direct proportion to the value of broken equipment.

                              Comment

                              Working...
                              X