How to Use Stepper Motor As Rotary Encoder and OLED Display for Steps

by RonFrtek in Circuits > Arduino

3571 Views, 3 Favorites, 0 Comments

How to Use Stepper Motor As Rotary Encoder and OLED Display for Steps

Use Stepper Motor As Rotary Encoder and OLED Display for Steps

In this tutorial we will learn how to track the stepper motor steps on the OLED Display. Watch a demonstration video.

Credit for the Original tutorial goes to youtube user "sky4fly".

What You Will Need

oled.png
jumper-wires.jpg
5mm_Red_LED.jpg
Arduino Uno.jpg
FICL0HPK36U3RSN.LARGE.jpg
158c4b38-d974-468a-84ef-b6bce57d7b34.png
300-ohm.jpg
31ucUXjqUsL.jpg
120k-ohm-resistor.jpg
download (2).jpg

  • Arduino UNO (or any other Arduino)
  • LED
  • LM358 dual operational amplifier
  • 4X 4.7K ohm resistor
  • 2X 120K ohm resistor
  • 300 ohm resistor
  • Bipolar Stepper motor (4 wires)
  • Jumper wires
  • OLED Display
  • Visuino program: Download Visuino

The Circuit

2020-01-23_13-34-50.jpg
F1MF69CJIYU5PQE.LARGE.jpg

Start Visuino, and Select the Arduino UNO Board Type

FBL8FPKK5H5EPPI.LARGE.jpg
FL8QFGAK5H5EPPK.LARGE.jpg

To start programming the Arduino, you will need to have the Arduino IDE installed from here: https://www.arduino.cc/.

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work! If you have not done follow the steps in this Instructable to setup the Arduino IDE to program Arduino UNO! The Visuino: https://www.visuino.eu also needs to be installed. 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 & Connect Components

2020-01-23_10-00-51.jpg
2020-01-23_9-58-42.jpg
2020-01-23_13-53-00.jpg
2020-01-23_13-52-40.jpg
2020-01-23_13-54-18.jpg
2020-01-23_13-54-31.jpg
  • Add "OLED display I2C"
    Double click on the DisplayOLED1 component -In the element window expand "Text" and drag "Text Field" to the left side
    -Select "Text Field1" on the left side and in the properties window set size to: 2
  • Add "Counter" component and in the properties window set Min>Value to 0
  • Add 2X "Detect Edge" component
  • Connect Arduino Digital [7]Out to "DetectEdge1" pin[In]
  • Connect Arduino Digital [8]Out to "DetectEdge2" pin[In]
  • Connect "DetectEdge1" pin[Out] and "DetectEdge2" pin[Out] to "Counter1" pin [In]
  • Connect "Counter1" pin [Out] to "DisplayOLED1" > Text Field1 pin[In]
  • Connect "DisplayOLED1" pin[Out] to Arduino I2C pin[In]

Generate, Compile, and Upload the Arduino Code

FVS3Y85JJ4ZYH0Q.LARGE.jpg
F314C8EJJ4ZYH0D.LARGE.jpg

In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE

In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Play

If you power the Arduino UNO module the LED will shine, and if you change the stepper motor position the number of steps will be visible on the OLED display.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu