Jump to content

Recommended Posts

Posted
Hi. I want to count how many time a sensor gets activated per minute. I know how i would do it mathwise, and with a stopwatch. But im strugling to do it in the ladder. I ideas? Im using mitsubishi q03 plc and GX iec developer. Thanks Martin

Posted
Create a self-resetting timer (stopwatch). Tie the input to a counter. When the timer completes, divide the counter accumulated value by the time period of the timer and reset the counter. Repeat.
Posted
Great suggestion Jross, one improvement would be to use a free running never ending timer and when it's accumulated value gets to 1second or 5 seconds or whatever value, subtract that from the accumulated value and use the time constant agaisnt the counter. This takes out error from overhead. But yours works great for a beginner and rough estimations.
Posted
Even better, there's a function which does exactly what you want: SPD. |----------------------[sPD X0 K60000 D0]-------| This will count rising pulses of X0 for 60 seconds, then store the result in D0, then start again. The general form is [sPD <S> <n> <D>] where <S> is the input you want to count, <n> is the time period in milliseconds (16bit) and <D> (16 bit) is where you store it.
Posted (edited)
I understand how to calculate this. But i have problems programming it. I think my problem is reseting timers at the right time, because the result is incorrect. As you can see the LastTime result logged at each pulse as 510 (5,1sec). The result is incorrect as 60sec / 5sec should give 12 pulses. So i get 0,1 sec extra each log. Maybe its the time between the accumulated time and the acualt time i log it. If so how do i avoid this? The true result would be 60/5,1 = 11,76. Ofcourse i could round up this result and get 12. But i want to do this correct. Take a look at the image below. The first timer fivesecpuls simulates the sensor gets activates every 5 second. Edited by jydepower
Posted
Ok it works now. The problem was that i simulated on my labtop, and it was too slow. When loadet into plc, everything worked perfect. It did make me convert the numbers into real, for a more detailed result. I endet up with counting how much time between each sersor pulse, and devide it into 1 minute. Thats works great. Thanks all.
Posted
One important thing: When programming IEC Ladder you should divide "non-contacting" instructions into more networks. Even if you draw the instructions in a specific order you never know what the compiler does, hence you might get strange behaviour in your program... Divide into networks like this.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...