Stepper Motor 28BYJ-48 - Smooth Speed Ramping With Arduino & Visuino
by RonFrtek in Circuits > Arduino
49 Views, 1 Favorites, 0 Comments
Stepper Motor 28BYJ-48 - Smooth Speed Ramping With Arduino & Visuino
In this tutorial, we will explore two examples of controlling the Stepper Motor 28BYJ-48 using Visuino and Arduino.
- The first example demonstrates how to ramp up the motor's speed smoothly.
- The second example adds a ramp-down phase, creating a complete speed control cycle.
Watch a demonstration video to see both examples in action!
What You Will Need
- Arduino UNO (or any other board)
- Stepper motor 28byj-48 & stepper motor driver board
- Jumper wires
- Visuino program: Download Visuino
The Circuit
- Connect Arduino pin [5V] to Driver Board1 pin [VCC]
- Connect Arduino pin [GND] to Driver Board1 1pin [GND]
- Connect Arduino digital pin [2] to Driver Board1 pin [IN1]
- Connect Arduino digital pin [3] to Driver Board1 pin [IN2]
- Connect Arduino digital pin [4] to Driver Board1 pin [IN3]
- Connect Arduino digital pin [5] to Driver Board1 pin [IN4]
Start Visuino, and Select the Arduino UNO Board Type
Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2
In Visuino Add Components
- Add "Analog Value" component
- Add "Ramp To Analog Value" component
- Add "Clock Generator" component
- Add "4 Wire Stepper Motor" component
In Visuino Set Components
We are going to use "AnalogValue1" to set the final speed
- Select "AnalogValue1" and in the properties window set "Value" to 800
With "RampToValue1" we are going to ramp up the speed from 0 to final 800
- Select "RampToValue1" and in the properties window set "Slope (Sec)" to 50, this means that we will increase the speed every second for 50
- Select "ClockGenerator1" and in the properties window select "Frequency" and click on the pin icon and select "Float SinkPin"
In Visuino Connect Components
- Connect "AnalogValue1" pin [Out] to "RampToValue1" pin [In]
- Connect "RampToValue1" pin [Out] to "ClockGenerator1" pin [Frequency]
- Connect "ClockGenerator1" pin [Out] to "Stepper1" pin [Step]
- Connect "Stepper1" pin [0] to Arduino digital pin [2]
- Connect "Stepper1" pin [1] to Arduino digital pin [3]
- Connect "Stepper1" pin [2] to Arduino digital pin [4]
- Connect "Stepper1" pin [3] to Arduino digital pin [5]
Generate, Compile, and Upload the Arduino Code
In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.
Play
If you power the Arduino module the Stepper Motor will start to rotate and ramp up its speed.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Project, you can download it here and open it in Visuino: https://www.visuino.eu
Ramp-Up and Ramp-down Example
In this example we are going to ramp-up the speed and after a certain period ramp-down the speed to zero.
We are going to add 2 new components:
Add "Start" component, this component gets activated on the start of Arduino
Add "Sequence" component
In Visuino Set Components
- Double click on the "Sequence1" and in the Elements window drag 2x "Period" to the left side
- For the second period set in the properties window "Delay" to 15000, this means that it will be activated after 15s from the start
- Close the Elements window
- Double click on the "AnalogValue1" and in the Elements window drag 2x "Set Value" to the left side, for the first one in the properties window set "Value" to 800, for the second one just leave it at 0
- Close the Elements window
- Select "RampToValue1" and in the properties window set "Slope (Sec)" to 100
In Visuino Connect Components
- Connect "Start1" pin [Out] to "Sequence1" pin [Start]
- Connect "Sequence1" > "Period1" pin[Out] to "AnalogValue1" > "Set Value1" pin [In]
- Connect "Sequence1" > "Period2" pin[Out] to "AnalogValue1" > "Set Value2" pin [In]
- Connect "AnalogValue1" pin [Out] to "RampToValue1" pin [Out] to "ClockGenerator1" pin [Frequency]
- Connect "ClockGenerator1" pin [Out] to "Stepper1" pin [Step]
- Connect "Stepper1" pin [0] to Arduino digital pin [2]
- Connect "Stepper1" pin [1] to Arduino digital pin [3]
- Connect "Stepper1" pin [2] to Arduino digital pin [4]
- Connect "Stepper1" pin [3] to Arduino digital pin [5]
Play
Upload the project as written in Step 7.
Once you turn On the Board the Stepper Motor will start to ramp up the speed and after 15s Ramp down the speed.