Stepper Motor Speed Control in LabVIEW

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how to make a simple Virtual Instrument (VI) for Stepper Motor Speed Control in LabVIEW. In my previous tutorials, I have worked on Stepper Motor Speed Control using Arduino in which I have shown how to control the stepper motor speed using Arduino. Today, I am going to share a new tutorial in which I am gonna do the Stepper Motor Speed Control in LabVIEW. Moreover, you should also have a look at Stepper Motor Speed Control in Matlab, where I am sending stepper motor speed control commands from MATLAB. In this tutorial, I am going to work on the program for Stepper Motor speed Control using NI LabVIEW. So, before going into the details of this tutorial, you must go through my previous tutorials because I am going to use the same hardware setup and same Arduino source code as well. I will made a simple GUI (Graphical User Interface) for Stepper Motor Speed Control in LabVIEW. There will be five different buttons on the GUI for clockwise rotation, counter clockwise rotation, stopping  the stepper motor, accelerating and deaccelerating the stepper motor respectively.

Stepper Motor Speed Control in LabVIEW

In the tutorial Stepper Motor Speed Control in LabVIEW, I will explain you a complete step by step procedure to control the clockwise and counter clockwise direction of the stepper motor as well as accelerating and decelerating it with the help of the buttons on the GUI created in NI LabVIEW using serial communication between Arduino and NI LabVIEW.
  • You can download the complete simulation for Stepper Motor Speed Control in LabVIEW by clicking below button:

 Download LabVIEW Simulation

  • Download .rar file, extract the files from the folder and enjoy the complete simulation for Stepper Motor Speed Control in LabVIEW.
Block Diagram
  • First of all I would like to explain you the algorithm for Stepper Motor Speed Control in LabVIEW with the help of block diagram.
  • Block diagram for this project is shown in the figure below.
  • We send commands from the NI LabVIEW through the serial port i.e. NI LabVIEW serially communicates with the Arduino to control the speed of the stepper motor.
  • Arduino sends commands to the L298 motor controller and it decides what to do after manipulating the different commands from Arduino.
  • Executed commands are also printed on LCD (Liquid Crystal Diode).
Vitual Instrument's (VI's) Description
  • First of all open NI LabVIEW software on your laptop or PC.
  • Go to the Block Diagram window and Right Click on it.
  • Go to Functions-> Instrument I/O-> Serial and you can see different serial blocks like VISA Write, VISA Read, VISA Serial etc.
  • Choose the encircled VISA Configure Serial Port and place it on the Block Diagram window.
  • VISA Configure Serial Port block will help us to open the Serial Port before executing the algorithm.
  • The screen shot of the Block Diagram is shown in the figure below.
  • Go to the first input terminal of the VISA Configure Serial Port block and go to Create-> Control.
  • Above step will be helpful to select the COM port of the Arduino board in order to run the program properly.
  • Updated Block Diagram window is shown in the figure below.
  • Now go to Functions-> Instrument I/O-> Serial, you can see there different serial blocks.
  • Choose the encircled VISA Close block and place it on the Block Diagram window.
  • The VISA Close block is shown in the figure below and it will be help in closing the Serial Port if needed.
  • Now, go to the Functions-> Programming-> Structures and you can see the different structures there like For Loop, While Loop, Case Structure etc.
  • Choose the encircled block as shown i the figure below.
  • Place all the above blocks in a way shown in the figure below.
  • Now, go to the Functions-> Programming-> Structures-> Flat Sequence.
  • Flat sequence block is encircled and is shown in the figure below.
  • Put your cursor and go to Add Frame After.
  • Similarly ad another case after this as shown in the figures below.
  • Newly added frame is shown in the figure below.
  • Now, go to Functions-> Instrument I/O-> Serial, you can see different serial blocks there.
  • Choose the encircled VISA Write Block and place it on the Block diagram window.
  • The figure shown below elaborates the above steps.
  • Make the connections as shown in the figure below.
  • Now, go the Functions-> Programming-> Structures and you can see different types of structures like for loop, while loop, flat sequence etc.
  • Choose he encircled block as shown in the figure below.
  • Select the Case Structure block and place it on the block diagram window.
  • The figure shown below displays the above step.
  • Now, go to the input terminal of the write block and go to Create-> Control.
  • Change the name of this  block to Command box as shown in the figure below.
  • The block diagram window is shown in the figure below.
  • Now, go to Functions-> Programming-> Structures and you can see different structures blocks there.
  • Choose the encircled block as shown in the figure below.
  • Select the Local Variable Block and place it on the Front Panel.
  • Right click on it and select Command box as shown in the figure below.
  • Go to the input terminal of this local variable and go to Create-> Constant.
  • Place inside that constant.
  • The figure below elaborates the above step.
  • The above case structure is for the clock wise rotation of the stepper motor.
  • Similarly make four further case structures for counter clockwise rotation, accelerating, de-accelerating and stopping the rotation of the stepper motor.
  • All the three case structures are shown in the figure below.
  • You can see three different case structures in above figure.
  • The command box variable having command will rotate the stepper motor in clockwise direction.
  • A command box variable having command will rotate the stepper motor in counter clockwise direction.
  • The command box variable having command will rotate the stepper motor at higher and higher speed if it is rotating with a lower speed.
  • A command box variable having command will rotate the stepper motor with slower and slower speed if it is rotating at a higher speed.
  • .
  • The command box variable having command will stop the rotation of the stepper motor.
  • Now, go to the Front Panel and Right Click on it.
  • Go to Controls-> Modern-> Boolean and you can see there different Boolean blocks.
  • Choose the encircled block as shown in the figure below.
  • Select the Round LED block and place it on the front panel.
  • Similarly select two more round LED blocks and place them on the front panel as well.
  • Change their names from default to Clockwise, Anti clockwise and  Stop Motor.
  • All of the above steps are explained visually in the figure shown below.
  • The LED shown in the above figure will control the stepper motor on clock wise, counter clock wise direction and will stop the motor as well.
  • Now go to the block diagram window and connect these blocks as shown in the figure below.
  • At the end, after sending all the commands we must need to close the serial port so that unnecessary exchange of commands could be avoided.
  • So I have cleared the all the commands in third frame of the case structure i.e I am sending no commands through the serial port.
  • This will be helpful in closing the serial port.
  • The figure show below explains all of the above steps visually.
  • Now add another case structure to start the program when you want so.
  • The figure below shows the newly added case structure.
  • Now, go to the Front Panel, the button encircled in the figure shown below is used to start the program when needed.
  • Now add a Stop button in order to terminate the program whenever you want so.
  • The complete output of the program is shown in the figure below.
  • A complete NI LabVIEW Virtual Instrument (VI) is shown in the figure below.
  • I have decorated the front panel to make it attractive for the users.
  • The final look of the Front panel is shown in the figure below.
  • Go to Controls, Modern-> Decorations you can see different decoration blocks there.
  • All these blocks are shown in the figure displayed below.
  • I have used three decoration blocks encircled with the blue color, to decorate my program.
  • Red boundary shows all of the decoration blocks to make your program attractive.
  • You can also decorate your programs using this amazing tool.
That is all from the tutorial Stepper Motor Speed Control in LabVIEW. I hope you enjoyed this tutorial on Stepper Motor Speed Control in LabVIEW. If you face any sort of problem you can ask me anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in some better way, if possible. I will explore NI LabVIEW, will make different projects on it and will share them with all of you as well. Till then, Take care :)

Stepper Motor Direction Control in LabVIEW

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about how to make a simple Virtual Instrument (VI) for Stepper Motor Direction Control in LabVIEW. In my previous tutorial, I have worked on Stepper Motor Direction Control using Arduino, in which I have controlled Stepper Motor Direction Control using Arduino and I am gonna use the same setup but this time I am gonna do the Stepper Motor Direction Control in LabVIEW. Moreover, you should also have a look at Stepper Motor Direction Control using Matlab. In this tutorial, I going to work on the program for Stepper Motor Direction Control in LabVIEW. So, before going into the details of this tutorial, you must go through my previous tutorials because I am going to use the same hardware setup and same Arduino source code as well. I will made a simple GUI (Graphical User Interface) for Stepper Motor Direction Control in LabVIEW. There will be three different buttons on the GUI for clockwise rotation, counter clockwise rotation and stopping  the stepper motor respectively.

Stepper Motor Direction Control in LabVIEW

In the tutorial Stepper Motor Direction Control in LabVIEW, I will explain you a complete step by step procedure to control the clockwise and counter clockwise direction of the stepper motor with the help of the buttons on the GUI created in NI LabVIEW using serial communication between Arduino and NI LabVIEW.
  • You can download the complete NI LabVIEW simulation here.
  • Download .rar file, extract the files from the folder and enjoy the complete NI LabVIEW's simulation:

 Download LabVIEW Simulation

VI's Description
  • First of all open NI LabVIEW software on your laptop or PC.
  • Go to the Block Diagram window and Right Click on it.
  • Go to Functions-> Instrument I/O-> Serial and you can see different serial blocks like VISA Write, VISA Read, VISA Serial etc.
  • Choose the encircled VISA Configure Serial Port and place it on the Block Diagram window.
  • VISA Configure Serial Port block will help us to open the Serial Port before executing the algorithm.
  • The screen shot of the Block Diagram is shown in the figure below.
 
  • Go to the first input terminal of the VISA Configure Serial Port block and go to Create-> Constant.
  • Above step will be helpful to select the COM port of the Arduino board in order to run the program properly.
  • Updated Block Diagram window is shown in the figure below.
  • Now go to Functions-> Instrument I/O-> Serial, you can see there different serial blocks.
  • Choose the encircled VISA Close block and place it on the Block Diagram window.
  • The VISA Close block is shown in the figure below and it will be help in closing the Serial Port if needed.
  • Now, go to the Functions-> Programming-> Structures and you can see the different structures there like For Loop, While Loop, Case Structure etc.
  • Choose the encircled block as shown i the figure below.
  • Place all the above blocks in a way shown in the figure below.
  • Now, go to the Functions-> Programming-> Structures-> Flat Sequence.
  • Flat sequence block is encircled and is shown in the figure below.
  • Put your cursor and go to Add Frame After.
  • Similarly ad another case after this as shown in the figures below.
  • Newly added frame is shown in the figure below.
 
  • Now, go to Functions-> Instrument I/O-> Serial, you can see different serial blocks there.
  • Choose the encircled VISA Write Block and place it on the Block diagram window.
  • The figure shown below elaborates the above steps.
  • Make the connections as shown in the figure below.
  • Now, go the Functions-> Programming-> Structures and you can see different types of structures like for loop, while loop, flat sequence etc.
  • Choose he encircled block as shown in the figure below.
  • Select the Case Structure block and place it on the block diagram window.
  • The figure shown below displays the above step.
  • Now, go to the input terminal of the write block and go to Create-> Control.
  • Change the name of this  block to Command box as shown in the figure below.
  • The block diagram window is shown in the figure below.
  • Now, go to Functions-> Programming-> Structures and you can see different structures blocks there.
  • Choose the encircled block as shown in the figure below.
  • Select the Local Variable Block and place it on the Front Panel.
  • Right click on it and select Command box as shown in the figure below.
  • Go to the input terminal of this local variable and go to Create-> Constant.
  • Place inside that constant.
  • The figure below elaborates the above step.
  • The above case structure is for the clock wise rotation of the stepper motor.
  • Similarly make two further case structures for counter clockwise rotation and stopping the rotation of the stepper motor.
  • All the three case structures are shown in the figure below.
  • You can see three different case structures in above figure.
  • The command box variable having command will rotate the stepper motor in clockwise direction.
  • A command box variable having command will rotate the stepper motor in counter clockwise direction.
  • The command box variable having command will stop the rotation of the stepper motor.
  • Now, go to the Front Panel and Right Click on it.
  • Go to Controls-> Modern-> Boolean and you can see there different Boolean blocks.
  • Choose the encircled block as shown in the figure below.
  • Select the Round LED block and place it on the front panel.
  • Similarly select two more round LED blocks and place them on the front panel as well.
  • Change their names from default to Clockwise, Anti clockwise and  Stop Motor.
  • All of the above steps are explained visually in the figure shown below.
  • The LED shown in the above figure will control the stepper motor on clock wise, counter clock wise direction and will stop the motor as well.
  • Now go to the block diagram window and connect these blocks as shown in the figure below.
  • At the end, after sending all the commands we must need to close the serial port so that unnecessary exchange of commands could be avoided.
  • So I have cleared the all the commands in third frame of the case structure i.e I am sending no commands through the serial port.
  • This will be helpful in closing the serial port.
  • The figure show below explains all of the above steps visually.
  • Now add another case structure to start the program when you want so.
  • The figure below shows the newly added case structure.
  • Now, go to the Front Panel, the button encircled in the figure shown below is used to start the program when needed.
  • Now add a Stop button in order to terminate the program whenever you want so.
  • The complete output of the program is shown in the figure below.
  • A complete NI LabVIEW Virtual Instrument (VI) is shown in the figure below.
Decorated Front Panel
  • Since, I want to make the better external look of the program so I have decorated a bit.
  • The figure shown below shows the decorated Front Panel.
  • Go to Controls, Modern-> Decorations you can see different decoration blocks there.
  • All these blocks are shown in the figure displayed below.
  • I have used three decoration blocks encircled with the blue color, to decorate my program.
  • Red boundary shows all of the decoration blocks to make your program attractive.
  • You can also decorate your programs using this amazing tool.
Complete Hardware Setup
[ultimate_spacer height="10:]
  • A complete hardware setup for different commands is shown in the figure below.
  • When you send the command through the serial port from LabVIEW to the Arduino,  the statement Clockwise will be printed on the LCD as shown in the figure below.
  • When you send the command through the serial port from LabVIEW to the Arduino,  the statement No rotation will be printed on the LCD as shown in the figure below.
  • When you send the command through the serial port from LabVIEW to the Arduino, the statement Anti Clockwise will be printed on the LCD as shown in the figure below.
This is all from the tutorial Stepper Motor Direction Control in LabVIEW. I hope you all enjoyed this tutorial. If you face any sort of problem you can ask me anytime without feeling any kind of hesitation. I will try my level best to solve your issue in a better way if possible. I will explore NI LabVIEW further in my later tutorials. Till then, Take care :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir