Ladder Logic 404: VFD Encoder Control/Siemens

Speed vs. Position with Preset Speed

Today’s post doubles as a Ladder Logic series post and an introduction to the last videos in the Siemens Step 7 Odyssey series on my YouTube channel. Last week I covered a bit about how a Variable Frequency Drive interfaces with a PLC for control, this week I am going into a bit more depth on the code behind the control.

After last week’s post, Moussa gave me further information about his application via Facebook Messenger. Here is the information he gave me: He has 2 motors, each with an encoder. He is using ABB drives to control the motors. The message continues (edited):

“When I set a distance in the HMI ex: x =100 cm and y=20 , then press Ok , the motor Y goes up to 20 cm and stop 2 s. After that: MOTOR X starts and turn a conveyor belt 6 cm and stop 2s. Next step: Motor y goes down to 0 position and stop . This is the cycle. We repeat the cycle til 100 cm end . Means 100 / 6 cm Thank you in advance.”

Now this is actually a full integration job when it comes down to it. There are several questions that would still need to be answered, and the brand of PLC and HMI were not specified. Other things that need to be considered; scaling the speeds and encoder counts, creating DBs (Data Blocks) with tables for move positions and speeds, Mode Control, and other topics already discussed in previous videos and posts.

I did the following videos in Siemens since that is what most of the people in my Facebook group use.

First video, setup of UDT and Interface
Second video, simulation Function Block and testing
Third Video, Drive control with presets

In addition to these three videos, I would encourage anyone to understand the Ladder Logic 204: Auto Sequences post under the PLC tab, along with some of the other organizational posts. The technique used for the X Axis in these three videos can be copied to the Y axis code (a new independent sequence), then the two movement routines can be triggered in a new sequence that triggers the moves as in the following example:

Step 10: Move positions for X and Y to destination registers (CmdPosition in the videos)
Step 20: Trigger Moves and wait for completion
Step 30: Do whatever you needed to do after moving (Glue, Grip, or whatever)
Step 40: Move next positions for X and Y to destination registers
Step 50: Trigger Moves and wait for completion
Step 60: Do whatever…

And repeat as necessary. One of the biggest breakthroughs I had in my programming career was somewhere around 1998 when I figured out how to sequence sequences. This made me feel like I could program anything! Of course I kept finding new challenges and bigger projects, and you never stop learning.

I don’t mind answering questions like Moussa’s occasionally, especially if I can use the answer in something like this. But the reality is it takes a lot of time to make videos and write stuff up, and I usually charge for integration. And with the Covid-19 situation most of my traveling teaching classes are done for a while. So I am pivoting my focus to an online approach, creating a membership site where I will continue to publish material, teaching classes online and in person when I can, coaching and collaborating. It’s a tough time everywhere, but I hope we can all get through this. Spend the time you are stuck at home learning new stuff, and let me know if I can help!


Electrical Engineer and business owner from the Nashville, Tennessee area. I also play music, Chess and Go.