Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plc counter code

Status
Not open for further replies.

controls2012

Electrical
Sep 10, 2008
17
Could someone give me some ideas I would like to capture the pulse time for a pulsing input to A PLC, and would like to maitain the time for evaluating untill the next pulse.Just need some help with ladder instructions.
 
Replies continue below

Recommended for you

probably not possible. Most PLC will have a scan or cycle time of several miliseconds (at least). So your resolution of time will be on the order of 10 msec or greater. In addition to that most scan times are not fixed, so will vary from one scan to another. The only good way to measure pulse time is via hardware.
 
As long as you can sample the input at 2x as compare to the scan time you should be ok.

example
input pulse change over 40msec
scan time less than 20msec
This example will work

Are you asking to check for a fault if missing pulses?
If so, then use the pulse to reset a timer over a length of time. If the timer times out you set a latch bit, flag an alarm bit.

or
start a timer on transistion of the pulse going true, when it goes true again move the accumulated time into the beginninng of an array. Copy block the array down 1 position for the whole array.

rinse repeat

what you should see is the array filing up with the time between pulses, if the plc is able to capture it.
 
If you can assign an interrupt subroutine to the input, then you can set up a timer in the ISR to reset each time the interrupt routine is called.

So the first command in your ISR would be to move the timer accumulator value into a word, the second command would be to reset the timer. The word value would contain the most recent pulse interval.
 
Thanks for all of your responses, to give you A little more insight I am trying to troubleshoot a shrink wrapper and problem is that on an intermittent bases the knife that cuts the film should only make one revolution. It is triggered by a Photo Eye. Once the film is feed via servo drive, there is a pulse generated from the drive which is feed to a module that makes the 24v out put to the mac valve pulse low. which allows the knife through a clutch to make one revolution. I jumped this 24v over to a plc input hopping I could capture the time and compare it to the time of normal operation. What is happening is instead of one revolution it will make 4 or 5. The mechanics that have been working on it have replaced and made the necessary adjustment to the mac valve, cylinder clutch ect. they are convinced that it is not mechanical and since it only happens once or twice a shift "which i cant sit there and watch it all day" i thought i would capture the output time to the mac valve and determine if it is a longer than normal negative pulse.

The code I added was like what i have in the link below. the problem is the reset does not reset the ACC of T4:10. In fact when I test that rung the count never makes it to my N7:2 file, If I AFI that rung my counter continues to count and shift the values to my two N7 files.
 
gonehunting,

Does your knife have a "home" position sensor? It should not go several revolutions, if you stop it at the home.

 
at the rto, you latch in the input with the enable of the rto.
Right before it triggers the rto during the transistion, do the reset (use a oneshot of the input), its a rung order problem. You would also break the enable on the rto with the reset right before. Also move the data at the reset rung of the rto.

You might be missing the pulse on the plc input like someone was saying, is why you think it went 4-5 revs and you did not see it. Look at the specs on the input card see if it is even capable of seeing a pulse at this speed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor