Logix 500 Vines Per minute

ErikG

Member
Join Date
Apr 2014
Location
Washington State
Posts
23
I have a machine that pulls vines into it and they hit a limit switch to count them. I also would like to figure out how many vines per hour are coming through. I started off using a timer and watching the ACC and comparing that to how many vines I have counted, but then when the timer runs out I lose track of my count. Anyone know how to do this?
 
I have a machine that pulls vines into it and they hit a limit switch to count them. I also would like to figure out how many vines per hour are coming through. I started off using a timer and watching the ACC and comparing that to how many vines I have counted, but then when the timer runs out I lose track of my count. Anyone know how to do this?


please post a PDF of your code.


roughly how many vines per second, or seconds per vine?
 
To keep a rolling average, you'll need to use a FIFO queue. Have a read up on the FFL/FFU instructions, and then read on for the approach I'd take:

1. Set up an array of DINT's. Let's call it Interval_Array, and give it a length of 10
2. Set up a timer that times the interval between limit switch activations
3. Each time the limit switch is triggered, MOV the timer ACC value into a "Last_Interval" tag and reset the timer
4. If Last_Interval is less than, e.g., 30 seconds, perform steps 5-8*
5. If your FIFO queue is full (.DN bit set), FFU the queue to make space for your new entry
6. FFL Last_Interval into your Interval_Array
7. Use the AVE instruction to calculate your average interval between vines**
8. Once you have an average interval between vines (in milliseconds), Vines_Per_Hour = 3,600,000 / Average_Interval

This will give you a nice steady "vines per hour" figure that doesn't jump around too much, but is still relatively real-time.

*The sanity check in Step 4 is important because otherwise when you shut the machine down, or if there is a legitimate break in product flow, you'll get a huge interval value, which you don't want to include in your averaging calculation or it'll throw things way out. I have no idea how long an actual interval is, so that "30 seconds" figure is a total guesstimate - you'll need to work out what a sensible value is to distinguish between "longer gap than usual but still normal product flow" versus "there's a problem and the vines have stopped coming".

**When calculating the average, you have a few options:
- Don't calculate an average until your FIFO queue is full, to make sure you always have a valid range of intervals to be averaging (i.e. you're not including a bunch of zeroes in your average)
- Dynamically check how many values are in your FIFO (check the .POS value) and adjust the AVE instruction (.LEN) value to suit
- Just average all 10 values regardless of what's in them because it's purely indication and not important enough to worry complicating it like this

The final piece of the puzzle is what you do when there is a break in product flow. As your value only updates when a new vine hits the limit switch, it could sit there with no vines for hours and still show a "vines per hour" figure of whatever they were running at leading up to the break. Perhaps you could use that same interval figure to determine "OK, if I have no vines for more than X seconds, I not only ignore this interval when I do get another one, but I also set my vines per hour value to zero"

Edit: just saw you're using Logix 500, not 5000, but you should still be able to take the same approach. You'll just have to use registers rather than creating arrays.
 
is there a plc involved? if so, what brand and model?
i would let the limit switch trigger a counter, count to 1000.
a slc 500 can count to 32767 before faulting. a compact logix can do a 32 bit integer.
it all depends on what you are using.
james
 
RsLogix 500, so no array of Dints.
Also no AVE instruction.

For parts per time unit tasks, I usually calculate time units per part and invert it. Use a oneshot from the rising edge of the input that detects work completion to capture the accumulator of a free running timer and then reset the timer.

Divide that value into the number of timer units per overall time unit you want to display.

Store a few of these calculations in a FIFO (I typically just use a COP with the newest at the top rather than the full blow FFU/FFL pair of instructions) and if the values are erratic, average a number of them if you desire.

Is this for a SLC or a Micrologix? There are different timebases available in different model.
 
Yeah, caught that but it can still be done using N registers and a timebase in seconds rather than ms.

I didn't know there wasn't an AVE instruction in Logix 500, but averaging is trivial to do with standard math instructions anyway.

Sounds like OkiePC and I are taking much the same approach, with a few variations here and there :D
 
A rolling average of a series of differences placed into a FIFO is the same as the difference between the last and first FIFO elements, which are the absolute values from which those differences would be take, divided by the number of elements in the FIFO less one.

Using a bit of the free-running clock (FRC) is sometimes a simpler, and more accurate, way to keep track of time.

The rest is bookkeeping. Three rungs:

  • one to count periods triggered by a bit in the FRC counter;
  • one to move period counts through the FIFO;
  • one to perform the calculation.
A bit messy because so much happens on each rung, but in the end easier to read and understand (IMNSHO;)) than other shenanigans.
 
I have a working solution. It needs packing peanuts:

  • start/stop logic
  • connection to your process' inputs
    • It has an input buffer that includes an option to simulate input data
  • the rate update calculation is triggered by the rising edge of the vine detection limit switch, so it needs the sanity check that @ASF mentioned i.e. it needs some way of dealing with inactivity i.e. no vines over some set timespan
    • it does have a bit that changes after a period of inactivity
    • But I have thought of one way to have the published rate follow a reasonable path for extended inactivity
  • Integrate with the rest of the process
    • E.g. reassign file conflicts
Do you want it, or is this a homework assignment?
 
It's (;)) parameters are

  • Number of elements in file N255 and Length parameters in FFU and FFL instructions on Rung 0002
    • Currently 33
      • for 1000 vines/h, this will give a moving average over the past ~two minutes
  • Bit number of S:4 in XIC on Rung 0001, and constant scaling factor in first DIVide on Rung 0003
    • Currently /11 and 146.4844; time sample is 409.6ms
    • For bit /N, constant is EITHER
      • 300000 * (2**(-N)) = 3e5 * (2^(-N)
    • OR
      • (30000 ÷ (2**N)) = 3e5 ÷ (2*N)
  • TOF T4:0.PREset on Rung 0002
 
Last edited:

Similar Topics

Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
85
I have been working on this for a while now and I can't seem to get it. I was finally able to view the 1500 on the PanelView under the serial...
Replies
1
Views
82
I have a little bit of experience with Allen-Bradley. I have a Micrologix 1500 (RSLogix 500) and a PanelView Plus 7 (FactoryTalk View Studio ME)...
Replies
3
Views
164
buen dia. tengo una falla al pasar los tags de mi plc SLC 5 0/4 a mi panel me aparece un error Problem writing value " " to item <tag name>...
Replies
1
Views
81
Hello, I have a 1764 1500 LSP Series A that keeps failing with DTL_E_FAIL I/O error. Searching around it seems there's a weird issue specifically...
Replies
2
Views
106
Back
Top Bottom