Skip to content

Latest commit

 

History

History

1_Half-Step_Full-Step

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

MCHP

Half-Step and Full-Step



Bipolar Stepper Motor


This example presents a bipolar stepper drive, using Half-Step and Full-Step methods.

Full-Step Mode


In Full-Step mode, the motor rotates complete mechanical steps at once - for a standard 200 full-steps/revolution stepper motor, this would be 1.8 degrees for a sub-step. The motor's two coils are powered sequentially in four full-steps. The sequence determines the stepper motor's direction of rotation. Full-Step mode is simple to control, but can cause vibration and noise due to the larger step angle. Another drawback of using this mode is that the stepper motor's current consumption is at the highest level, having the lowest efficiency. This mode is often used in applications where the drive algorithm simplicity is more important than the smoothness of operation or precision.

Half-Step Mode


In Half-Step mode, four extra steps are inserted between the four initial full-steps, which makes the stepper motor rotate by half of its full-step angle. This effectively doubles the number of mechanical steps per revolution - for a standard 200 full-steps/revolution stepper motor, this would be 0.9 degrees for a complete step, resulting in a smoother operation and less vibration compared to the Full-Step mode.
The benefits of having a balance between simplicity, efficiency, smoothness of operation and a lower current consumption outweigh the increased complexity of the control algorithm needed for this mode. It also provides double resolution of the Full-Step mode.

Related Documentation

More details and code examples on the AVR16EB32 can be found at the following links:

Software Used

Hardware Used

  • AVR® EB Curiosity Nano
  • Multi-Phase Power Board (MPPB)
  • AVR-EB Curiosity Nano Adaptor to MPPB
  • Motor used in the application: 17HS8401S Stepper Motor, but not mandatory
  • A Voltage Power Supply (6-50V and 1-3A current capability, depending on the chosen motor)


The AVR16EB32 Curiosity Nano Development board is used along with the MPPB, AVR-EB Cnano to MPPB Adaptor Board, one stepper motor and a voltage power supply.
Adjust the supply voltage and the current limit according to the stepper motor used.



Hardware used

Functionality


The application is periodically calling the Stepper_Move function with the parameters: initial position, steps (to go) and delay (speed).


The function returns the stepper motor final position after the movement.
The stepper drive schema is controlled by the StepAdvance function. StepAdvance generates a wave 90 electrical degrees shifted.

Full-Step



Ideal waveforms of the current that flows through the coils. Each full-step represents a stepper motor mechanical movement of 1.8 degrees.


Full-Step: four full-steps sequence


For a better aproximation, we are inserting intermediary steps, called half-steps.

Half-Step



Ideal waveforms of the current that flows through the coils. Each half-step represents a stepper motor mechanical movement of 0.9 degrees.


Half-Step: eight half-steps sequence

Note: 0.707 represents sin(45 degrees) or cos(45 degrees).
Back to Top

Configuration


Note: For a standard 200 full-steps/revolution stepper motor, 1.8 mechanical degrees represent 360 electrical degrees (360 electrical degrees/200-steps is 1.8 mechanical degrees).


The motor parameters can be configured in stepper.h.


The AMPLITUDE_DRIVE parameter sets the amplitude of the sine wave signal, ranging from 0 to 1.0 and it is invers proportional with the power supply voltage (vbus) and it is directly proportional with the coil resistance and with the desired current consumption level. AMPLITUDE_DRIVE = desired current consumption * coil resistance/power supply voltage.
For example:
AMPLITUDE_DRIVE = 1.0[A] * 2.5[ohm]/10[V] = 0.25


The AMPLITUDE_STALL parameter represents 10-20% of AMPLITUDE_DRIVE.


The STEP_SIZE parameter is fixed and it represents the step angle of the stepper used in Full-Step mode. For this application, a stepper motor with 200 steps / mechanical revolution is used. 360 mechanical degrees/revolution divided by 200 steps results in 1.8 mechanical degrees/step.


The application contains an option that allows the stepper coils to still remain energized after the steper motor has finished the movement. The user can enable or disable this functionality with the help of the RELEASE_IN_IDLE flag.
The flag is by default true, which means that after every movement the current through the coils is stopped. If the user needs the coils to remain energized while the motor is idle, the RELEASE_IN_IDLE flag must be set to false.



To change the stepping mode, uncomment the corresponding macro in stepper.h.


Back to Top

Flowchart


Flowchart for the Stepper_Move function


Sub-step division:
1 full-step = reference
1 half-step = 1/2 full-step
Back to Top

Setup


To generate this project using MPLAB X IDE and the MPLAB X Code Configurator (MCC) with Melody (MCC Clasic is not supported for this device), follow the next steps:


1. Open MPLAB X IDE and create a new project for the AVR16EB32 device.


2. Open MCC from the toolbar (more information on how to install the MCC plug-in can be found here).


3. From the MCC Content Manager tab click the Select MCC Melody button and then click Finish.



4. Click Project>Resources>System>CLKCTRL, then do the following configuration:

- Disable the Prescaler enable button


5. To add the TCE module, go to Device Resources>Drivers>Timer>TCE0, then do the following configuration:

- Module Enable: Must be enabled by default, if not just toggle the button (it turns blue if enabled)
- Clock Selection: System clock (by default the divider must be 1 - System clock)
- Counter Direction: UP
- Waveform Generation Mode: Single-Slope PWM mode with overflow on TOP
- Requested Period [s]: 0.00005
- Duty Cycle 0 [%]: 0
- Duty Cycle 1 [%]: 0
- Duty Cycle 2 [%]: 0
- Duty Cycle 3 [%]: 0
- Waveform Output n: Check the boxes from the Enable column for Waveform Output 0, 1, 2, 3
- Scale mode: CMP values are scaled from Bottom, 50% DC (duty cycle)
- Scaled Writing to registers: Normal
- Amplitude Control Enable: Toggle the button (it turns blue if enabled)
- Amplitude Value: 1


7. To add the WEX module, go to Device Resources>Drivers>WEX>WEX0, then do the following configuration:

- Input Matrix: Direct
- Update Source: TCE (the update condition for the output signals will be dictated by TCE)
- Override Settings: Check all the boxes from the Output Enable column for the Waveform Output [0-7]
- Dead-time Insertion Channel 0 Enable: Toggle the button (it turns blue if enabled)
- Dead-time Insertion Channel 1 Enable: Toggle the button (it turns blue if enabled)
- Dead-time Insertion Channel 2 Enable: Toggle the button (it turns blue if enabled)
- Dead-time Insertion Channel 3 Enable: Toggle the button (it turns blue if enabled)
- Requested Dead-time Low Side (μs) : 0.2
- Requested Dead-time High Side (μs) : 0.2


8. In the Pin Grid View tab check if the WEX_WO [0-7] pins are locked as outputs on PORTA. When the boxes from the Enable column in the Output Settings of WEX are checked, the pins are also locked. To change the PORT simply click a pin from another PORT in Pin Grid View.

Pin Configuration
PA0 TCE and WEX WO0
PA1 TCE and WEX WO1
PA2 TCE and WEX WO2
PA3 TCE and WEX WO3
PA4 TCE and WEX WO4
PA5 TCE and WEX WO5
PA7 TCE and WEX WO6
PA7 TCE and WEX WO7



9. To add the BOD module, go to Device Resources>System>BOD, then do the following configuration:

-BOD Operation in Active Mode: Enabled in continuous mode
-BOD Level: 2.7V
-BOD Operation in Sleep Mode: Disabled


10. To add the UART module, go to Device Resources>Drivers>UART>UART0, then do the following configuration:

- Requested Baudrate: 115200
-Redirect Printf to UART Enable: Toggle the button (it turns blue if enabled)


11. In the Project Resources tab, click the Generate button so that MCC will generate all the specified drivers and configurations.


12. Add the main.c, stepper.c and stepper.h files to the project.
Back to Top

Operation


Caution:
Do not change power supply voltage during the stepper movement. The application does not implement any protection for over-current.

  1. Be sure the power supply is turned off.

  2. Adjust the voltage of the power supply according to the stepper motor specs.

  3. Adjust the current limit of the power supply according to the stepper motor specs.

  4. Connect the power supply to the MPPB.

  5. Connect the AVR16EB32 board the the MPPB Adapter.

  6. Connect the MPPB Adapter to the MPPB.

  7. Connect the AVR16EB32 board to the PC.

  8. Open the avr16eb32-stepper-full-step-half-step-mcc.X or solution in MPLAB X IDE.

  9. Right click the project and select Set as main project.


  1. Build the avr16eb32-stepper-full-step-half-step-mcc.X project by clicking Clean and Build Project.


  1. Click Make and Program Device to program the project to the board.


  1. Start the power supply.
    Back to Top

Results


On the terminal, the information about the movement of the stepper is shown.

Screen capture from Half-Step configuration.


Full-Step



Half-Step

Colours in the figures:
Yellow and blue represent the voltages at the two ends of coil A,
Green represents the current through coil A.

On all three traces a low pass filtering from the oscilloscope is applied. This removes the PWM artifacts and makes visible the short time average values.
Back to Top

Summary


This application shows how to drive in Full-Step or Half-Step a stepper motor using AVR16EB32, MPPB, MPPB Adapter and a power supply.


Back to Top
Back to Related Documentation
Back to Software Used
Back to Hardware Used
Back to Functionality
Back to Configuration
Back to Flowchart
Back to Setup
Back to Operation
Back to Results
Back to Summary