Difference: SteppingMotor (1 vs. 8)

Revision 82017-11-27 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

Line: 101 to 101
 
META FILEATTACHMENT attachment="steppingMotor.odt" attr="" comment="" date="1508957719" name="steppingMotor.odt" path="steppingMotor.odt" size="236655" user="uli" version="1"
META FILEATTACHMENT attachment="clockwise.png" attr="" comment="" date="1509019476" name="clockwise.png" path="clockwise.png" size="2970" user="uli" version="1"
META FILEATTACHMENT attachment="counterClockwise.png" attr="" comment="" date="1509019476" name="counterClockwise.png" path="counterClockwise.png" size="3001" user="uli" version="1"
Added:
>
>
META FILEATTACHMENT attachment="stepping.pdf" attr="" comment="" date="1511778876" name="stepping.pdf" path="stepping.pdf" size="317403" user="uli" version="1"

Revision 72017-11-01 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

Line: 20 to 20
 
  • 5V (check for “5V +” and “-” on the board)

  • Gnd

  • 4 phases denominated In0..In3

Added:
>
>
If you want to be compatible with my solutions then you should hook up the phases as follows:
  • phase 1 on pin 27
  • phase 2 on pin 22
  • phase 3 on pin 18
  • phase 4 on pin 17
 The state of each of the In lines is shown on its corresponding LED. We will have to provide a sequence of pulses

to make the motor move by 4 full steps. This is what we call single phase stepping where only 1 coil is energized at a time. In this case we have

Changed:
<
<
    Step 1 Step 2 Step 3 Step 4
In 1 coil 1 + 1 0 0 0
In 2 coil 2 - 0 1 0 0
In 3 coil 1 - 0 0 1 0
In 4 coil 2 + 0 0 0 1
>
>
 We can also drive the motor by energizing both coils as follows:
Changed:
<
<
    Step 1 Step 2 Step 3 Step 4
In 0 coil1 + 1 0 0 1
In 1 coil2 - 1 1 0 0
In 2 coil1 - 0 1 1 0
In 3 coil2 + 0 0 1 1
>
>
 This way of driving the motor is called double phase stepping. It needs more power since we always have both windings energized but it will also provide a higher torque.

Last not least we can use a combination of single and double phase stepping to produce half steps. In this case the angular resolution is better by a factor of 2. The polarization table looks like this:

Changed:
<
<
    Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8
In 0 coil1 + 1 1 0 0 0 0 0 1
In 1 coil2 - 0 1 1 1 0 0 0 0
In 2 coil1 - 0 0 0 1 1 1 0 0
In 3 coil2 + 0 0 0 0 0 1 1 1
>
>
 Connect the stepping motor to the driver board and the driver board to the Raspberry Pi. The In0 .. In3 lines must be connected to GPIO pins (e.g. 17,18,27,22). Now set only the GPIO line, to which In0 is connected, to high, all the others to low and make sure that the corresponding LED lights up. Do the same thing for all the connected GPIO pins.

Exercise 2: Write a program to move the stepping motor by 2048 steps.

Revision 62017-10-26 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

Line: 50 to 50
  Use the single phase sequence to make the stepping motor move. One sequence corresponds to 4 full steps. Make sure to wait at least 25 ms in between each setting:
  • set 1 0 0 0, wait 25ms

Changed:
<
<
  • set 0 1 0 0, wait 25 ms …

>
>
  • set 0 1 0 0, wait 25 ms …

  Write a subroutine which moves the motor by 4 steps. Then call this subroutine 512 times. Use C arrays to define which In line corresponds to which GPIO line and a 2 dimensional array to mimic the above table.
Line: 75 to 75
 
  • -h or –halfStep: half step

Additional Exercises:

Changed:
<
<
The "inverse device" to the stepping motor is a rotary encoder. Here we do not sent the pulse sequence to move a motor but we receive the receive the sequence to be able to tell by how far the motor has moved. The encoder is usually fixed to the motor shaft and it tells us the position of the motor.
>
>
The "inverse device" to the stepping motor is a rotary encoder. Here we do not send the pulse sequence to move a motor but we receive the sequence to be able to tell by how far the motor has moved. The encoder is usually fixed to the motor shaft and it tells us the angle or position of the motor.
  Reading out an encoder is not really part of this exercise but since we have such an encoder in our sensor kit I played on it and I give you some code to read out the encoder in the solutions section to this exercise.
Added:
>
>
The following signal shapes show the encoder signals when moving clockwise

clockwise.png

and counter clockwise

counterClockwise.png

 -- Uli Raich - 2017-05-11

Comments

Line: 94 to 102
 
META FILEATTACHMENT attachment="stepping.png" attr="" comment="" date="1494505331" name="stepping.png" path="stepping.png" size="187310" user="uli" version="1"
META FILEATTACHMENT attachment="windings.png" attr="" comment="" date="1494505331" name="windings.png" path="windings.png" size="29348" user="uli" version="1"
META FILEATTACHMENT attachment="steppingMotor.odt" attr="" comment="" date="1508957719" name="steppingMotor.odt" path="steppingMotor.odt" size="236655" user="uli" version="1"
Added:
>
>
META FILEATTACHMENT attachment="clockwise.png" attr="" comment="" date="1509019476" name="clockwise.png" path="clockwise.png" size="2970" user="uli" version="1"
META FILEATTACHMENT attachment="counterClockwise.png" attr="" comment="" date="1509019476" name="counterClockwise.png" path="counterClockwise.png" size="3001" user="uli" version="1"

Revision 52017-10-26 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

Line: 72 to 72
 
  • -n or –numberOfSteps: number of steps (default 512)

  • -v or –velocity: velocity of movement

  • -s or –fullStep: full step (this is the default)

Changed:
<
<
  • -h or –halfStep: half step

>
>
  • -h or –halfStep: half step

Additional Exercises:

The "inverse device" to the stepping motor is a rotary encoder. Here we do not sent the pulse sequence to move a motor but we receive the receive the sequence to be able to tell by how far the motor has moved. The encoder is usually fixed to the motor shaft and it tells us the position of the motor.

Reading out an encoder is not really part of this exercise but since we have such an encoder in our sensor kit I played on it and I give you some code to read out the encoder in the solutions section to this exercise.

  -- Uli Raich - 2017-05-11

Revision 42017-10-25 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

Line: 88 to 88
 
META FILEATTACHMENT attachment="stepping.png" attr="" comment="" date="1494505331" name="stepping.png" path="stepping.png" size="187310" user="uli" version="1"
META FILEATTACHMENT attachment="windings.png" attr="" comment="" date="1494505331" name="windings.png" path="windings.png" size="29348" user="uli" version="1"
Added:
>
>
META FILEATTACHMENT attachment="steppingMotor.odt" attr="" comment="" date="1508957719" name="steppingMotor.odt" path="steppingMotor.odt" size="236655" user="uli" version="1"

Revision 32017-10-16 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

Line: 20 to 20
 
  • 5V (check for “5V +” and “-” on the board)

  • Gnd

  • 4 phases denominated In0..In3

Changed:
<
<
The state of each of the In lines is shown on its corresponding LED. We will have to provide a sequence of

    In0 In1 In2 In3
In 0 coil1 1 0 0 0
In 1 coil2 0 1 0 0
In 2 coil1 0 0 1 0
In 3 coil2 0 0 0 1
>
>
The state of each of the In lines is shown on its corresponding LED. We will have to provide a sequence of pulses
  to make the motor move by 4 full steps. This is what we call single phase stepping where only 1 coil is energized at a time. In this case we have
Deleted:
<
<
coil1 coil2
+ 0
0 0
- 0
0 -
 
Added:
>
>
    Step 1 Step 2 Step 3 Step 4
In 1 coil 1 + 1 0 0 0
In 2 coil 2 - 0 1 0 0
In 3 coil 1 - 0 0 1 0
In 4 coil 2 + 0 0 0 1
 We can also drive the motor by energizing both coils as follows:
Deleted:
<
<
coil1 coil2
+ +
- +
- -
+ -
How does the corresponding table giving the values on the In0 .. In3 look like? This way of driving the motor is called double phase stepping. It needs more power since we always have both windings energized but it will also provide a higher torque.
 
Changed:
<
<
Last not least we can use a combination of single and double phase stepping to produce half steps. In this case the angular resolution is better by a factor of 2. The polarization table looks like this:
coil1 coil2
+ 0
+ +
0 +
- +
- 0
- -
0 -
+ -
>
>
    Step 1 Step 2 Step 3 Step 4
In 0 coil1 + 1 0 0 1
In 1 coil2 - 1 1 0 0
In 2 coil1 - 0 1 1 0
In 3 coil2 + 0 0 1 1
This way of driving the motor is called double phase stepping. It needs more power since we always have both windings energized but it will also provide a higher torque.
 
Added:
>
>
Last not least we can use a combination of single and double phase stepping to produce half steps. In this case the angular resolution is better by a factor of 2. The polarization table looks like this:
 
Added:
>
>
    Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8
In 0 coil1 + 1 1 0 0 0 0 0 1
In 1 coil2 - 0 1 1 1 0 0 0 0
In 2 coil1 - 0 0 0 1 1 1 0 0
In 3 coil2 + 0 0 0 0 0 1 1 1
 Connect the stepping motor to the driver board and the driver board to the Raspberry Pi. The In0 .. In3 lines must be connected to GPIO pins (e.g. 17,18,27,22). Now set only the GPIO line, to which In0 is connected, to high, all the others to low and make sure that the corresponding LED lights up. Do the same thing for all the connected GPIO pins.

Exercise 2: Write a program to move the stepping motor by 2048 steps.

Use the single phase sequence to make the stepping motor move. One sequence corresponds to 4 full steps. Make sure to wait at least 25 ms in between each setting:

  • set 1 0 0 0, wait 25ms

Changed:
<
<
  • set 0 1 0 0, wait 25 ms …

>
>
  • set 0 1 0 0, wait 25 ms …

  Write a subroutine which moves the motor by 4 steps. Then call this subroutine 512 times. Use C arrays to define which In line corresponds to which GPIO line and a 2 dimensional array to mimic the above table.
Line: 78 to 72
 
  • -n or –numberOfSteps: number of steps (default 512)

  • -v or –velocity: velocity of movement

  • -s or –fullStep: full step (this is the default)

Changed:
<
<
  • -h or –halfStep: half step

>
>
  • -h or –halfStep: half step

  -- Uli Raich - 2017-05-11

Revision 22017-05-13 - uli

Line: 1 to 1
 
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

Line: 22 to 22
 
  • 4 phases denominated In0..In3

The state of each of the In lines is shown on its corresponding LED. We will have to provide a sequence of
Changed:
<
<
In0 In1 In2 In3
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
to make the motor move by 1 full step.
>
>
    In0 In1 In2 In3
In 0 coil1 1 0 0 0
In 1 coil2 0 1 0 0
In 2 coil1 0 0 1 0
In 3 coil2 0 0 0 1

to make the motor move by 4 full steps. This is what we call single phase stepping where only 1 coil is energized at a time. In this case we have

coil1 coil2
+ 0
0 0
- 0
0 -

We can also drive the motor by energizing both coils as follows:

coil1 coil2
+ +
- +
- -
+ -
How does the corresponding table giving the values on the In0 .. In3 look like? This way of driving the motor is called double phase stepping. It needs more power since we always have both windings energized but it will also provide a higher torque.

Last not least we can use a combination of single and double phase stepping to produce half steps. In this case the angular resolution is better by a factor of 2. The polarization table looks like this:

coil1 coil2
+ 0
+ +
0 +
- +
- 0
- -
0 -
+ -

  Connect the stepping motor to the driver board and the driver board to the Raspberry Pi. The In0 .. In3 lines must be connected to GPIO pins (e.g. 17,18,27,22). Now set only the GPIO line, to which In0 is connected, to high, all the others to low and make sure that the corresponding LED lights up. Do the same thing for all the connected GPIO pins.
Changed:
<
<

Exercise 2: Write a program to move the stepping motor by 512 steps.

>
>

Exercise 2: Write a program to move the stepping motor by 2048 steps.

 
Changed:
<
<
The above sequence must be sent to the stepping motor to make it move 1 full step. Make sure to wait at least 25 ms in between each setting:
>
>
Use the single phase sequence to make the stepping motor move. One sequence corresponds to 4 full steps. Make sure to wait at least 25 ms in between each setting:
 
  • set 1 0 0 0, wait 25ms

  • set 0 1 0 0, wait 25 ms …

Changed:
<
<
Write a subroutine which moves the motor by 1 step. Then call this subroutine 512 times. Use C arrays to define which In line corresponds to which GPIO line and a 2 dimensional array to mimic the above table.
>
>
Write a subroutine which moves the motor by 4 steps. Then call this subroutine 512 times. Use C arrays to define which In line corresponds to which GPIO line and a 2 dimensional array to mimic the above table.

How far does the motor move with 2048 steps? How can you lower the speed of the movement?

Exercise 3: Modify the stepping tables

 
Changed:
<
<
How far does the motor move with 512 steps? How can you lower the speed of the movement?

Exercise 3: Improve your program to give user control over its parameters

>
>
Modify the tables with the values for In0..In3 to use single phase stepping, double phase stepping and half step mode. How do you have to modify these tables if you want the motor to turn the other direction? Try all 6 combinations:
  • single phase forward
  • single phase backward
  • double phase forward
  • double phase backward
  • half step forward
  • half step backward

Exercise 4: Improve your program to give user control over its parameters

  Modify your program in such a way that the user can define its behavior through command line parameters:
  • -f or –forward: move forward (this is the default)

Revision 12017-05-11 - uli

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="CourseExercises"

Stepping Motor Exercises

Goal:

A stepping motor is a device which is often used when a precise amount of movement is required: an exact angle of a an exact position on a linear scale. While DC motors move while they a powered a stepping motor requires a sequence of impulses to move step by step as its name suggests.

In this exercise we will learn how to program different step sequences for full step of half step movement and how to move the motor forward and backward.

This is a photo of the motor itself and its driver module featuring an ULN2803 driver chip.

stepping.png

Exercise 1: Make sure the connections are correct

The stepping motor is has 5 connections which are provided by the cable from the driver module to the motor itself. The 2 coils must be energized in the right order.

windings.png

To do this we have 6 connections from the driver board to the Raspberry Pi:

  • 5V (check for “5V +” and “-” on the board)

  • Gnd

  • 4 phases denominated In0..In3

The state of each of the In lines is shown on its corresponding LED. We will have to provide a sequence of

In0 In1 In2 In3
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
to make the motor move by 1 full step.

Connect the stepping motor to the driver board and the driver board to the Raspberry Pi. The In0 .. In3 lines must be connected to GPIO pins (e.g. 17,18,27,22). Now set only the GPIO line, to which In0 is connected, to high, all the others to low and make sure that the corresponding LED lights up. Do the same thing for all the connected GPIO pins.

Exercise 2: Write a program to move the stepping motor by 512 steps.

The above sequence must be sent to the stepping motor to make it move 1 full step. Make sure to wait at least 25 ms in between each setting:

  • set 1 0 0 0, wait 25ms

  • set 0 1 0 0, wait 25 ms …

Write a subroutine which moves the motor by 1 step. Then call this subroutine 512 times. Use C arrays to define which In line corresponds to which GPIO line and a 2 dimensional array to mimic the above table.

How far does the motor move with 512 steps? How can you lower the speed of the movement?

Exercise 3: Improve your program to give user control over its parameters

Modify your program in such a way that the user can define its behavior through command line parameters:

  • -f or –forward: move forward (this is the default)

  • -b or –backward: move backward

  • -n or –numberOfSteps: number of steps (default 512)

  • -v or –velocity: velocity of movement

  • -s or –fullStep: full step (this is the default)

  • -h or –halfStep: half step

-- Uli Raich - 2017-05-11

Comments


<--/commentPlugin-->

-- Uli Raich - 2017-05-11

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="stepping.png" attr="" comment="" date="1494505331" name="stepping.png" path="stepping.png" size="187310" user="uli" version="1"
META FILEATTACHMENT attachment="windings.png" attr="" comment="" date="1494505331" name="windings.png" path="windings.png" size="29348" user="uli" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback