Saturday, September 29, 2018

To Control Stepping Motor using Python with a Raspberry

In this tutorial, I will show you how to setup a stepper motor with a Raspberry Pi. I’m using a 40 pin Raspberry Pi 3 (same for 28 pin) and Kumantech Motor Stepper kit.



When I got started with Stepper Motors I followed this well explained video below. There is no written portion or at least as of now, the link in the description no longer works. I’m simply providing my code sample and more images of my setup.

Connecting

The first step will be connecting to your Pi. I recommend plugging in your Pi to a monitor, just to verify everything is correctly setup. You will need to be connected to the internet. You will also have to run the command below to get the IP address to SSH into:
hostname -I
With that IP address, on your personal computer (I’m using OSx), run ssh pi@___YOUR_PI_IP_ADD___ in the terminal app. This will allow me to program on my Pi through my personal computer. The password is probably raspberry .

Software

The software is explained in the video below. You will have to create a file on the command line so I ran:
cd Desktop
nano test_stepper.py
Copy and paste the following code, then save and exit.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
control_pins = [7,11,13,15]
for pin in control_pins:
  GPIO.setup(pin, GPIO.OUT)
  GPIO.output(pin, 0)
halfstep_seq = [
  [1,0,0,0],
  [1,1,0,0],
  [0,1,0,0],
  [0,1,1,0],
  [0,0,1,0],
  [0,0,1,1],
  [0,0,0,1],
  [1,0,0,1]
]
for i in range(512):
  for halfstep in range(8):
    for pin in range(4):
      GPIO.output(control_pins[pin], halfstep_seq[halfstep][pin])
    time.sleep(0.001)
GPIO.cleanup()
This code won’t work yet because we still have to connect our Pi with the stepper motor.

Hardware

A very useful aspect of the video was it didn’t matter if you used a 40 pin Pi or a 28 pin, the GPIO’s were the same. I’ve included a diagram below of both and we will be using GPIO 04 (Pin 7), GPIO 17 (Pin 11), GPIO 27 (Pin 13), and GPIO 22 (Pin 15).
The following is images of my hardware setup and the wire mappings are as follows:
  • In1 to Pin 7 (Blue wire)
  • In2 to Pin 11 (Green wire)
  • In3 to Pin 13 (Yellow wire)
  • In4 to Pin 15 (Orange wire)
  • 12v to Pin 4 (Red wire)
  • 5- to Pin 6 (Black wire)



If you are following the video above, wiring mapping is:
  • In1 to Pin 7 (Purple wire)
  • In2 to Pin 11 (Orange wire)
  • In3 to Pin 13 (Yellow wire)
  • In4 to Pin 15 (Green wire)
  • Same power setup as mine.

Running

Now that you have the code living on the Pi and the hardware setup, run:
python test_stepper.py
And you should see something similar.

Saturday, September 15, 2018

How to Configure a Stepper Motor and Driver

You can follow these steps to configure your motion stepper driver and test a step motor: 
  1. Open the Measurement & Automation Explorer (MAX)
  2. Navigate to your NI Motion Device
    1. In the Configuration panel, expand the My System tree
    2. Expand the Devices and Interfaces tree
    3. Expand the NI Motion Devices tree
    4. Expand the PCI-73xx tree
    5. Expand the Default 73xx Settings tree
  3. ​Configure your stepper settings
    1. Go to the Axis Configuration option, under the desired axis (e.g. Axis 1)
    2. In the Axis Configuration tab, set Type to Stepper.
    3. In the Stepper Settings tab (near the bottom of the screen), select your Stepper Steps Per Revolution, Stepper Loop Mode, Stepper Polarity, Stepper Output Mode, and Pull-in Tries
      Note: For P-Command motors, select P-Command for Stepper Loop Mode
  4. For now, disable your inhibit, home, and limit signals
    1. Select the Motion I/O Settings option under the axis tree 
    2. Disable all the signals in this tab (Limit Filters, Forward Limit Switches, Reverse Limit Switches, Home Switch, Forward Software Limit, Reverse Software Limit, Inhibit Output)
  5. Initialize your motion controller with your current MAX settings by click on the Initialize button

  6. Test your stepper settings with your stepper motor
    1. Expand the Interactive tree
    2. Select 1-D Interactive
    3. Set Stepper Loop Mode to Open Loop
    4. Set Velocity, Acceleration, and Deceleration to values slow enough for your motor to perform
    5. Set Operation Mode to Relative Position
    6. Set Target Position to the number of your Stepper Steps Per Revolution (as set in Step 2c)
    7. Click the Start button
      1. Your motor should move one full revolution. If the motor moves but goes over or under one revolution, then most likely the Stepper Steps Per Revolution is incorrect.
      2. Your motor should rotate in the forward direction (if Target Position is a positive value). If the motor rotates in the wrong direction, then you may need to switch either phase A and A- or B and B- (effectively reversing directions) leads from your drive to your motor, as it is possible to Determine My Stepper Motor Wiring without the Stepper Motor Pinout.
  7. If you are using feedback in your motion system, proceed to step 8. If you are not using an encoder, you are done configuring and testing your open loop stepper system.
  8. Configure your feedback settings
    1. Follow the instructions below if you are using a two-phase quadrature encoder for feedback
      1. In the Axis Configuration option, set Type of Feedback to Encoder
      2. Go to the Encoder Settings option
      3. Enter your encoder counts per revolution

        Note 1: If you can kill your motor and rotate the motor manually, then you can determine the correct encoder counts per revolution by steps here

        Note 2: To increase feedback accuracy, NI motion controllers read every edge of an encoder feedback signal. With a quadrature encoder, this results in four edges (rising and falling on lines A and B) for every quadrature pulse of the encoder. Thus, if your quadrature encoder is rated at 2000 quadrature pulses per revolution, the controller will actually read 8000 edges per revolution – and each of these is considered a "count".

        When setting the Encoder counts per revolution input in MAX, it is common to mistake this value for the encoder's physical resolution. Instead, this setting needs to hold the corresponding number of counts read by the controller, which is four times that resolution.  Following Error in a Motion System can result from this being improperly set.
    2. If you are using analog feedback, you can set up Analog Feedback with a Stepper Motor.
  9. Initialize your motion controller with your current MAX settings by click on the Initialize button
  10. Test your encoder settings
    1. Go to the Main tab of 1-D Interactive 
    2. Set Stepper Loop Mode to Closed Loop
    3. Set Velocity, Acceleration, and Deceleration to values slow enough for your motor to perform
    4. Set Operation Mode to Absolute Position
    5. Click the Reset Position button to reset the Current Trajectory Data Position to 0.
    6. Set Target Position to the number of your Stepper Steps Per Revolution (see Step 3c)
    7. Click the Start button
      1. Your motor should move one full revolution
      2. The Current Trajectory Data’s Position should match the Target Position
  11. Re-enable the inhibit, home, and limit signals that you will be using
    1. Go to the Motion I/O tab
    2. Enable the signals that you will be using and configure the correct polarity for each
  12. Configure the rest of options in MAX as is necessary
    1. Click on the Show Help button to display the MAX Help sidebar

    2. Use the MAX help for more information on the rest of the settings. Hover your mouse over a setting to populate the MAX Help with a description.



      Note: You do not need to configure anything in the Control Loop Settings tab for a cheap stepper motor.
  13. Initialize your motion controller with your final MAX settings by click on the Initialize button

Friday, August 31, 2018

Simple Tips on Wiring a Stepping Motor

In previous articles we have gone over how to choose a best stepper motors online for a particular application. This article goes into detail on how a stepper motor is wired.

A stepper motor can come with assortment of wire configurations. The type of motor you’ve selected will determine the wire setup. Most commonly stepper motors come with four, five, six, or eight wires.

To begin, if your stepper motor only has four wires, this means it can only be used with a bipolar driver. You will notice each of the two phase windings has a pair of wires, use your meter to identify the wires.

Find the wires that have the continuity between them and connect these to the stepper motor.

Simple Tips on Wiring a Stepping Motor


Like the four wire motor, six wire stepper motors have a pair of wires for each winding. However, it also has a center-tap for each winding as well, this gives it the option to be wired as bipolar or unipolar.

With your meter, divide the wires into sets of three that have continuity to each other, next identify the center taps. If you are connecting to a unipolar driver use all six of the stepper motor wires.

A bipolar driver will require you use only one end wire and one center tap of each winding. With a five wire stepper motor the wire setup is very similar to the six wire driver, the main difference being the center taps are connected together internally, bringing it out as one wire. This will make the motor only function as a unipolar driver. Also, the windings will be impossible to identify without trial and error, the best you can do is try to identify the center tap wire since it has half the resistance.

Finally there is the eight wire stepper motor, which is much like the six wire. The difference being that the two phases are split into two separate windings. When this is done it allows for the stepper motor to be connected as a unipolar stepping motor, as well as three different bipolar combinations.

Wednesday, August 15, 2018

What stepper motor technology is best for this application?

As outlined in our original parameters, the final design must be inexpensive and have simple drive architecture. Stepper motors satisfy both of these requirements. However, minimizing this machine’s overall volume is also important, so a stepper isn’t recommended: The 17.64-W minimum power requirement at the load (not including system losses and instantaneous peak power) would necessitate a large stepper. A brushless motor solves the problem of design footprint, but adds cost and complicates the drive architecture.

The third option — a dc-brush gearmotor with an in-line planetary gearhead — provides a small footprint, simplified drive, and relatively low cost. Adding a leadscrew for rotary-to-linear conversion keeps gear reduction stepper motor
 output speed at around 1,000 rpm, which reduces generated heat at the leadscrew and nut-thread interface.

Gearmotor output

3. What’s the velocity, reflected inertia, and reflected load at the gearmotor output shaft (acting as the leadscrew input)?
Step one: Calculate the peak linear velocity of the application with its 1/3-1/3-1/3 motion profile:

Step two: Calculate the minimum pitch needed to keep the leadscrew speed at about 1,000 rpm:

where pmin = minimum leadscrew pitch, m.
For one typical linear stepping motor, the closest pitch in an 8-mm screw diameter is 20.32 mm.
Step three: Calculate the peak shaft speed of the leadscrew (in rad/sec) for a linear velocity of 0.3 m/sec:

The leadscrew we select is TFE coated, 275-mm long, 8 mm in diameter with a 20.32-mm pitch, and paired with a freewheeling nut. Assume the leadscrew efficiency, ηs, is 86% and its inertia, Js, is 38.8 × 10-7 kg-m2.
Step four: Determine the total reflected inertia, JT, back from the load to the leadscrew shaft:

where JL = reflected load inertia, kg-m2; m = mass, kg; and p = leadscrew pitch, m.
Step five: Determine the shaft torque needed to accelerate the load inertia Ta:




where TJ = torque required to overcome load inertia, Nm; Tf = torque required to overcome friction, Nm; Tg = torque required to overcome gravity, Nm; a = linear acceleration,
m/sec2; Θ = load orientation, with horizontal = 0° and vertical = 90°; m = mass, kg; g = gravitational constant = 9.8 m/sec2; p = leadscrew pitch, m; vf = final linear velocity, m/sec; vi = initial linear velocity, m/sec; tf = final time, sec; ti = initial time, sec; and α = angular acceleration, rad/sec2.

WHERE TO GET 3 AXIS CNC CONTROLLER



Friday, August 10, 2018

Advantage of CNC router machine

Function: A more economical model CNC machining center, suitable for routing,relief, drilling, cutting, edge chamfering, etc.

Advantage of CNC router machine


Construction: Whole machine table adopts high strength thick steel pipe welded. Whole working table cast by resin sand. The annealing and other heat treatment methods ensure that the whole structure is tested to the limit for sturdiness and reliability.
Spare parts: Features world top class mechanical and electronic components, e.g. German rack and pinion, Taiwan rail and ball screw, Taiwan reducer, French Shneider electrical components, which guarantee stable performance and high quality.
Precision: Excellent spare parts, accurate precision detection instrument, which make sure the machine with perfect location and working precision.
High-speed: Adopt reducer direct design, high torque, high-energy, X axis dual motor drive, runs smoothly with high efficiency.
Table: Double adsorbable countertops, material in HPL, large suction by slots.
Tool magazine: Carousel tool magazine for optional. 

Main configuration
Working Area1300*2500*200mm
SpindleCE Standard Changsheng 3.0kw Water Cooling Spindle
Motor And DriverLeadshine Stepper Motor And analog Stepper Driver
Control SystemRichAUTO A11 DSP System 
TransmissionX,Y Axis Germany Helical Gear Transmission;Z Axis Taiwan TBI Ball Screw Transmission
Working Voltage380V/220V  3Phase/1phase
InverterTaiwan Delta  Inverter
BodyHeavy Duty Body 8mm Thickness
Guide RailsTaiwan Hiwin 20mm Guide Rails
cnc kit4 axis cnc kit3 axis cnc kit 

Friday, August 3, 2018

Advantages over servo motors

Closed loop-capable stepper motors merge the benefits of stepper and servo motor technology. They run more quietly and have a lower resonance than stepper motors, provide position feedback and control, feature short settling times, and exhibit no step loss at all. They are an alternative to stepper motors if energy efficiency, smooth running and a high load tolerance are required.Compared to servo motors, they have advantages due to their high torque at low speeds, short settling times, correct positioning without back swing and a lower price for sizes that are often smaller.

Closed loop step motors from Nanotec are an alternative to servo drives in many cases, such as in winding applications or conveyor belt drives. Not only can the rotational speed and position be more precisely controlled, but the torque can be controlled as well (in torque mode, as typically required in winding applications). Closed loop stepper motors combine the benefits of both worlds. They achieve the highest maximum torque, the best efficiency and optimum dynamics, but also feature the lowest torque ripple and exceptionally smooth running.

Advantages over servo motors

In torque mode, the closed loop stepper motor functions analogously to a spring, whereby the spring tension characteristic curve can be set via a potentiometer. Thus, the closed-loop stepping driver a stable force, even when the motor counteracts a force while at a standstill. When the force declines, the motor begins to turn proportionally to the declining force up to the current and torque setpoint values. Thus, closed loop stepper motors prove ideal for any type of winding, stretching and pressing applications.

Advantages over servo motors


Friday, July 27, 2018

Driving a Stepper as a 2-Phase Brushless Motor

To achieve the highest performance, the stepper motor can be treated as a 2 phase brushless servo motor. Current to the motor will then be controlled as a function of the error signal just as with standard servo motors. Galil refers to as 2 Phase Brushless mode, or 2PB. Figure 7 details the stepper motor system being driven in this mode. Now, rather than step pulses, a torque command signal (brown line) is generated by the controller to be fed to one of Galil's internal amplifiers operating in 2PB mode in order to control the position of the motor. times. A stepper motor driven in 2PB mode is analogous to a classic servo motor attached to a speed reduction gearbox.

Driving a Stepper as a 2-Phase Brushless Motor

Closed Loop Stepper Control
By leveraging Galil's methods of closed loop stepper control, the various shortcomings of stepper motors can be overcome. The endpoint position can be adjusted for inaccuracies with stepper position maintenance mode, the position can be dynamically adjusted with closed loop microstepping, and lastly the stepper motor can be treated as a 2-phase brushless servo to further increase the performance and efficiency of the motor. If you have questions on which mode of closed loop stepper operation is appropriate for your application, contact our Applications Engineering department at oyostepper.com.

Innovation methods of a hollow rotary actuator

1.What is a hollow rotary actuator? A hollow rotary actuator is an integrated electromechanical assembly that produces controlled rotationa...