Calculating Stepper Motor RPM from Encoder Pulses in TwinCAT Beckhoff - Helpful Tips

Question:

Hello everyone, I'm new to posting here so please bear with me if I miss anything. I am currently working on fine-tuning a PID controller by testing it on a stepper motor before implementing it on a real system. The real system I will be working on involves controlling a loading rate, measured in N/min, rather than velocity. Given the delicate nature of the real system and my beginner status, I want to ensure the PID controller performs well when decoupled. To provide feedback, I am converting encoder A input pulses to RPM. Since the real system operates at speeds under 1 RPM, I have decided to use a pulse timing method instead of attempting to measure position changes. Interrupt-based methods were deemed inaccurate at low speeds. The stepper motor I am using is an AS2023-0J10 model with an EL7047 driver card. The motor's incremental encoder can provide 1024 increments per revolution, but as it works in quadrature mode, this effectively means 4096 increments per revolution. However, tracking the A input pulse only yields 1024 increments, as it represents just one of the four states in quadrature mode. I would appreciate any advice on how to calculate RPM from encoder pulses in TwinCAT3.

Top Replies

Welcome to the forum, GRANDMAST3R5! If you have the EL7047 and AS2023 properly wired according to the documentation, setting up the NC Axis stuff (found in el70x7en.pdf) will allow you to control the motion of the motor using TwinCAT. By ensuring your scaling parameter is set correctly, you can directly monitor the position and velocity of the motor. The NC motion components offer a more precise RPM value compared to calculating velocity in PLC code. The default scaling for an Axis is typically Rev/s, as shown in the manual on page 151. However, when spinning the motor at speeds less than 1 rev/min and considering the encoder's limitation of only 4096 post quadrature pulses, deriving accurate velocity can be challenging. Additionally, the ability of the drive to manage the cogging torque of a stepper design may impact velocity readings, especially at low speeds. For further guidance on using the NC system, refer to the el70x7en.pdf. Good luck with your project! Regards, Patrick.

Welcome to the forum, GRANDMAST3R5! If you have the EL7047 and AS2023 set up correctly as per the documentation, the next step is to configure the NC Axis settings (found in el70x7en.pdf) in TwinCAT. This will allow you to easily control the motor's motion and accurately read position and velocity. The default scaling for an Axis is typically in Rev/s, but you can adjust it for Degrees of rotation as shown on page 151 of the manual. However, when it comes to spinning the motor at speeds lower than 1 rev/min and considering the encoder's limited 4096 post quadrature pulses, there may be challenges in achieving precise velocity readings. Factors like cogging torque in stepper designs can also impact accuracy at low speeds. If you decide to explore the NC system further, you can refer to the el70x7en.pdf for guidance. And to address any licensing requirements for using an NC motion system in the runtime, feel free to inquire. Thank you for considering this approach!

GRANDMAST3R5 inquired about the licensing requirements for using an NC motion system during runtime. When deploying the system for end customers or on the production floor, a license for the NC PTP component is necessary, similar to licensing the PLC component for running PLC code. For bench testing and initial development, you can utilize the unlimited 7-Day trial licenses for most features. Licensing is only required upon system deployment. The TC1250 package includes the TwinCAT3 PLC/NC PTP 10 combined package, comprising both TC1200 PLC and TF5000 - 10 Axis NC PTP functions. If you already have the TC1200 license, you can simply order the TF5000 to add the NC PTP functionality. Adding this license to an actual Beckhoff Controller running TwinCAT 3 is reasonably priced and more cost-effective than purchasing licenses for 3rd Party industrial PCs. Regards, Patrick.

In order to deploy the NC PTP component on the production floor or for end-customers, licensing is required, similar to needing the PLC component for running plc code. During bench testing and initial development, the unlimited 7-Day trial licenses can be used for most features. Licensing is only necessary when the system is deployed. The TC1250 package includes both the TC1200 PLC and TF5000 - 10 Axis NC PTP functions. If already licensed for TC1200, the TF5000 can be ordered to add the NC PTP functionality. Adding this license to an existing Beckhoff Controller running TwinCAT 3 is cost-effective compared to purchasing licenses for 3rd Party industrial PCs. However, in my specific case, I am integrating this controller into an existing system with a salvaged stepper motor and drive, and the end-user is reluctant to invest in additional licenses. Therefore, I must find a way to determine motor RPM without additional spending. Thank you for the valuable advice provided.

GRANDMAST3R5 mentioned the need to find a way to determine motor RPM without additional expenses. One possible solution is to set a specific update frequency for RPM calculations. By running a task every second and calculating the difference in pulse counts since the last update, you can accurately determine RPM. This method involves dividing the elapsed counts by the task time (1 second) and then multiplying it by 60 (seconds per minute). It's important to monitor the count values to prevent rollover, especially for tags with limited sizes like 16 or 32 bits. As long as you stay within the proper count range, this approach will provide accurate RPM measurements.

Hello! Calculating RPM in TwinCAT3 from encoder pulses requires an understanding of the relationship between revolutions, encoder pulses, and time. Given that your motor provides 4096 increments per revolution, you'll want to track the number of these increments within a specific time period, then convert this to RPM. For example, say you count 8192 pulses within ten seconds. Taking into account that 4096 pulses comprise one full revolution, you have essentially completed two revolutions in ten seconds. To convert this into revolutions per minute (RPM), simply multiply by six (since there are 60 seconds in a minute). In this case, this would yield 12 RPM. Just substitute your actual counted pulses and time sample into this equation to achieve your result.

Hey there, welcome to the forum! Your project sounds interesting and you're on the right track. Calculating RPM using encoder pulses might take a little effort but it's definitely doable. To calculate it, you'll want to first determine how many pulses you're getting in a specific time period. This would be counted by your control software in TwinCAT3. Once you have that, divide it by the number of pulses per revolution (in your case, 1024 if following A channel only) and that should give you the revolutions per that time period. To convert this into RPM (revolutions per minute), you need to adjust your time base, multiply by 60 if your time base was a second, divide by 60 if it was a minute. Just make sure to keep track of your time period for accurate results. Keep up the good work!

Hello and welcome to the forum! It's great to see you're taking a careful approach to controlling your system. As to your question, in calculating RPM from encoder pulses, you would need to first calculate the number of revolutions your motor makes for every set of encoder pulses. Given that your encoder provides 4096 increments per revolution in quadrature mode, you would divide the total number of pulses by 4096 to get the number of revolutions. You could then multiply by 60 to convert from revolutions per second (rps) to RPM. Remember to consider the time period over which you are counting these encoder pulses as it can significantly impact your RPM calculation. TwinCAT3 should be capable of providing the time stamps necessary for this calculation. Good luck on your project!

Hey there! Welcome to the forum. I think you're moving in the right direction. Just remember, RPM calculation involves counting total pulses within a given time frame. If you're using TwinCAT3, check their encoder interface, I believe, there should be a function where you can calculate the RPM easily. The formula is typically (Number of Pulses/No. of pulses per revolution) * 60sec/Elapsed time. And with regards to your quadrature mode, it's correct that you get 4096 counts per revolution but if you're just using one phase (A Phase) you'll get 1024 counts per revolution. Hope that helps, and keep us posted on your progress!

Welcome to the forum! It's great that you’re diving into PID control with a stepper motor; that's a solid way to gain experience. For calculating RPM from your encoder pulses in TwinCAT3, you’ll want to set up a pulsation counting mechanism that tracks the number of pulses over a defined time interval. Since you’re focused on low speeds, make sure to choose an appropriate time interval to avoid inaccuracies, perhaps around 1 second. Given that you're using quadrature encoding, and since the A channel gives you one out of four states, you'll need to factor that into your calculations. Specifically, count the pulses from the A channel, multiply by 4 for the full quadrature count, and divide by the time interval in seconds to get your RPM. It might also help to smooth out your RPM readings by averaging over several intervals, especially at those low speeds. Good luck with your project!

Welcome to the forum! It sounds like you're diving into some interesting but complex work. For calculating RPM from your encoder pulses in TwinCAT3, you could start by setting up a timer that counts the number of pulses over a fixed time period (like one second). Given that you're only tracking one channel of the quadrature encoder, remember to multiply your pulse count by four to get the effective increments per revolution. Then, you can calculate RPM using the formula: `(pulseCount * 60) / 4096`. This takes care of the conversion from increments to revolutions per minute. It's also worth considering using a low-pass filter on your RPM readings to smooth out any noise, which can be crucial for fine-tuning your PID controller. Good luck with your project!

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: 1. How can I calculate RPM from encoder pulses in TwinCAT3 when working with a stepper motor like the AS2023-0J10 model?

Answer: - To calculate RPM from encoder pulses in TwinCAT3, you can utilize the pulse timing method to accurately measure the speed at low RPMs. Given the quadrature mode of the encoder on the AS2023-0J10 model, where 1024 increments are tracked for each revolution, you effectively have 4096 increments per revolution to work with. By tracking the A input pulse, which represents one of the four states in quadrature mode, you can derive the RPM of the stepper motor.

FAQ: 2. Why is it recommended to use a pulse timing method instead of interrupt-based methods for measuring RPM at low speeds with a stepper motor?

Answer: - Interrupt-based methods may be deemed inaccurate at low speeds when working with stepper motors. Utilizing a pulse timing method allows for more precise measurement and calculation of RPM, especially for systems operating at speeds under 1 RPM. By tracking the A input pulse and considering the quadrature mode of the encoder, you can achieve more accurate results in TwinCAT3.

FAQ: 3. What considerations should be taken into account when fine-tuning a PID controller for a stepper motor before implementation on a real system?

Answer: - When fine-tuning a PID controller for a stepper motor, it is crucial to consider the nature of the real system, especially if it involves controlling parameters like loading

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  â†’