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

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.

  1. The first example demonstrates how to ramp up the motor's speed smoothly.
  2. 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

  1. Arduino UNO (or any other board)
  2. Stepper motor 28byj-48 & stepper motor driver board
  3. Jumper wires
  4. Visuino program: Download Visuino


The Circuit

2025-01-17_13-17-52.jpg
  1. Connect Arduino pin [5V] to Driver Board1 pin [VCC]
  2. Connect Arduino pin [GND] to Driver Board1 1pin [GND]
  3. Connect Arduino digital pin [2] to Driver Board1 pin [IN1]
  4. Connect Arduino digital pin [3] to Driver Board1 pin [IN2]
  5. Connect Arduino digital pin [4] to Driver Board1 pin [IN3]
  6. Connect Arduino digital pin [5] to Driver Board1 pin [IN4]


Start Visuino, and Select the Arduino UNO Board Type

select-board-uno.jpg
Visuino-Select-Board-UNO.jpg

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

2025-01-17_13-21-29.jpg
2025-01-17_13-22-26.jpg
2025-01-17_13-23-14.jpg
2025-01-17_13-23-57.jpg
  1. Add "Analog Value" component
  2. Add "Ramp To Analog Value" component
  3. Add "Clock Generator" component
  4. Add "4 Wire Stepper Motor" component

In Visuino Set Components

2025-01-17_13-27-42.jpg
2025-01-17_13-28-00.jpg
2025-01-17_13-28-22.jpg

We are going to use "AnalogValue1" to set the final speed

  1. 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

  1. Select "RampToValue1" and in the properties window set "Slope (Sec)" to 50, this means that we will increase the speed every second for 50
  2. Select "ClockGenerator1" and in the properties window select "Frequency" and click on the pin icon and select "Float SinkPin"

In Visuino Connect Components

2025-01-17_13-36-35.jpg
Ramp-stepper.png
  1. Connect "AnalogValue1" pin [Out] to "RampToValue1" pin [In]
  2. Connect "RampToValue1" pin [Out] to "ClockGenerator1" pin [Frequency]
  3. Connect "ClockGenerator1" pin [Out] to "Stepper1" pin [Step]
  4. Connect "Stepper1" pin [0] to Arduino digital pin [2]
  5. Connect "Stepper1" pin [1] to Arduino digital pin [3]
  6. Connect "Stepper1" pin [2] to Arduino digital pin [4]
  7. Connect "Stepper1" pin [3] to Arduino digital pin [5]



Generate, Compile, and Upload the Arduino Code

Visuino-Compile-UNO.jpg

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

2025-01-17_13-44-33.jpg
2025-01-17_13-45-35.jpg
2025-01-17_13-46-02.jpg

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

2025-01-17_13-48-21.jpg
2025-01-17_13-49-40.jpg
2025-01-17_13-53-22.jpg
2025-01-17_13-53-39.jpg
2025-01-17_14-21-44.jpg
  1. Double click on the "Sequence1" and in the Elements window drag 2x "Period" to the left side
  2. For the second period set in the properties window "Delay" to 15000, this means that it will be activated after 15s from the start
  3. Close the Elements window


  1. 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
  2. Close the Elements window


  1. Select "RampToValue1" and in the properties window set "Slope (Sec)" to 100

In Visuino Connect Components

2025-01-17_13-44-33.jpg
  1. Connect "Start1" pin [Out] to "Sequence1" pin [Start]
  2. Connect "Sequence1" > "Period1" pin[Out] to "AnalogValue1" > "Set Value1" pin [In]
  3. Connect "Sequence1" > "Period2" pin[Out] to "AnalogValue1" > "Set Value2" pin [In]
  4. Connect "AnalogValue1" pin [Out] to "RampToValue1" pin [Out] to "ClockGenerator1" pin [Frequency]
  5. Connect "ClockGenerator1" pin [Out] to "Stepper1" pin [Step]
  6. Connect "Stepper1" pin [0] to Arduino digital pin [2]
  7. Connect "Stepper1" pin [1] to Arduino digital pin [3]
  8. Connect "Stepper1" pin [2] to Arduino digital pin [4]
  9. 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.