RS Logix 5000 rpm from digital input

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi
I need to count up a digital input into a PLC and generate rpm

I will generate a one shot from the DI and use the oneshot to add 1 to a DINT, and reset it after 1 minute. The issue is a average rpm over time...... I assume i need a FIFO style instruction and move the counts into that and maybe average the last 3 or 4 to get a average

Any beter ideas welcome... i was thinking of counting over a lower time base and multiplying up ie every 20 seconds and multiply by 3 to get minutes value
 
First, figure out if the I/O will handle the frequency.

What's the duration of the pulses ? What's the maximum frequency of the pulses ? What's the Input module ?
 
Hi Ken

The PLC is a L18 and it is an onboard Input

The frequency.. i dont know but the motor will be 1450 rpm and i need to count shaft pulses so about 25Hz.

As for duration i dont know but lets assume a square wave at 25Hz

It is only for displaying a value on the HMI, not mission critical

Cheers
 
Don't forget about RPI settings if you are using some type of remote rack.

Just because the input might be able to work in your frequency range, if the RPI isn't fast enough you'll miss counts. Same applies to your scan time.
 
For this type of counting, I normally calculate on the rising edge of every pulse a number of minutes per RPM and invert it. Then for smoothing out the reading for human consumption, average the last 'n' values. In your case this value 'n' might be a pretty large number. Alternatively, you can apply a simple filter pretty easily without having to store a bunch of values. The point being that you don't usually want to wait a full minute to get the information.

A trick to build a FIFO without the overhead is to use a COP instruction to do the shifting and put the newest value in the highest array element:

COP
Source ms_rev[1]
Dest ms_rev9[0]
Length n

MOV ms_rev_latest
ms_rev[n]
 
Last edited:
First you need to test and see if the hardware's sample rate is fast enough, if so then you can worry about how to average, etc.
 
I am counting RPM and calculating to distance a drag chain moves using a high speed counter card in AB I have a 100 res. encoder coupled to the motor shaft.
 
Pulse Frequency

1450 rpm \ 60 seconds = 24.16667 rps

1000ms \ 24.16667 rps = 41.379 ms per revolution

Using a 180 degree cam on the shaft would put your pulse wave around 20.6895 ms.

Given these numbers you processor needs to complete a scan cycle every 10ms. to see each pulse transition.
 
I just started up RSLogix 5000 to check and found something I didn't know before: the embedded Inputs for a 1769-L18 controller can be configured for Change-Of-State updates and appear to be eligible to trigger an Event Task in the controller operating system.

That makes them more similar to 1756 series inputs than to 1734 series POINT I/O.

If this were my system, I would configure the rotation sensor input for a rising-edge Change-of State and set it up as the trigger for an Event Task.

In that task, create a program that grabs the Coordinated System Time using a GSV on the first pulse.

Then count 100 pulses, and grab the CST again. The difference between those values will give you a number of microseconds for 100 revolutions, and you can calculate RPM from that value.

EDIT: Something like this:

If (PulseCount = 1) then GSV(CST,,CurrentValue,CST1[0]) ;

PulseCount := PulseCount + 1;

If (PulseCount = 100) then ;
GSV(CST,,CurrentValue,CST2[0]) ;
Pulse100Time := CST2[0] - CST1[0] ;
PulseCount := 0 ;
end_if ;
 
Last edited:
RET's answer is really the best one.

This sort of function is exactly what the 1734-IJ (5V) and 1734-IK (24V) counter modules are designed to do. All the load will be taken off the backplane and CPU and done by the module.
 
Could you just feed the counts every few second into the Moving Average (MAVE) instruction? I have never used this instruction but it seems like it would eliminate a lot of code.
 
Hi
thanks for advice

I am due to goto the startup next week... my customer (who is a automation guy at the end users factory) has already agreed the io list/drawing etc... he emailed me and said he wanted to use DI xxx as the input to display rpm. I don't know the motor rpm or if the motor has a gearbox etc

I was thinking of doing some upfront coding but I have decided to wait and discuss.. a HSC maybe the answer.

Cheers
 

Similar Topics

Hello, I'm trying to understand a servo motion system. I want to know the motor speed in RPM at a given speed setpoint entered in a MAJ...
Replies
4
Views
2,228
How do I measure rpm of a single pickup of a shaft with a prox How would the ladder logic look like Can i use a function blok
Replies
4
Views
2,297
Dear Sir, We have one reactor on its shaft we have 3 bolts and we had inserted one proximity switch. Now we want to calculate RPM of that...
Replies
1
Views
5,494
I am completely stuck on building a ladder program that requires a start button to be pressed 3 times to turn on motor 1. Then motor 2 starts...
Replies
20
Views
522
Back
Top Bottom