Store target positions of encoder feedback

Hossamhegab

Member
Join Date
Sep 2019
Location
Cairo
Posts
23
Hello all
Iam using incremental encoder to measure the distance and calculate the speed of conveyor
There is also a trigger sensor on the conveyor
And a kick off piston to reject the bottles
The problem is that there is multiple bottles between the sensor and the piston
How can I store each bottle distance away from the rejection piston to activate the piston or by any way how to reject bottles without changing the value of rejection delay (time or distance ) with different conveyor speeds
 
You don't need to calculate speed or take speed into account. Simply calculate the positions based on the encoder.

You need to have a FIFO array with as many memory positions as there can be bottles between the sensor and the piston.
When a bottle is sensed, you add an entry into the FIFO array, with the value being the distance from the sensor to the piston.
Then count down every memory position by the value from the encoder.
When one of the array positions hit zero you activate the piston.
 
There are several approaches, one of which @JesperMP already described. The all involve a FIFO array of some kind, either of bits or of integers. In some PLC brands, only the integer form is called a FIFO.

OP mentioned neither the PLC make and model nor the language (Structured Text, Function Block Diagram, Ladder Logic, etc.); some PLCs have built-in FIFO and bit-shift instructions that make this easier, but it is also possible to build those tools from atomic instructions.

A FIFO is an array, either of integers or of bits; FIFO is an acronym for First In First Out. Normally values are appended or appended at one end of the FIFO array, and removed from and/or detected at the other end of the array; on one of those operations, or on a separate (e.g. encoder) event, all values in the array may be shifted by one position in the array.

The FIFO/bit-shift operation as described can be used as a model of the conveyor with the bottles: The integers or bits shifting through the array are proxies for the bottles moving along the conveyor. The exact details depend on

  • whether FIFO instructions operating on an integer array, or bit shift instructions operating on an array of bits, are used,
  • what sensors are available,
  • what triggers the movement of the data through the FIFO.
Bit Shift Array Modeling a section of conveyor

Usually a bit shift is apropos the process when the array represents the status of increments of conveyor length, and the status of any increment is binary i.e. reject or not-reject, where not-reject could mean either no bottle is present or a good bottle is present that should not be rejected.

When the encoder signals a discrete distance move by the conveyor i.e. an edge, the bits in the array are shifted by one position, and a new bit (First In) is added at one end representing a new increment of conveyor at the upstream end of the monitored section, and the oldest bit (First Out) is removed from the other end. The value of the new bit depends on the status of the bottle: 0 for accept (either no bottle present, or a good bottle); 1 for reject (bad bottle). How that new bit's value is determined is specific to the process. Note that, in this model,

  • each bit's value models the "bottle status" of an [increment of the moving conveyor], i.e. not the bottle itself, and
  • each bit's position in the array models the location of an [increment of the moving conveyor] between the entry sensor and reject stations
Since the length of the modeled section of conveyor is known, in units of encoder events, the position in the array of the "exit" bit, which models the location of the reject station, is also known, so monitoring that exit bit, and activating the reject piston when that exit bit is 1, should be fairly simple. That exit bit could be the bit removed from by the bit shift instruction if the entire bit array length models exactly the same length as the distance between the entry and reject stations, or, if the entire bit array length models a length greater than the entry-to-reject distance, that exit bit will be at a location earlier in the bit array.

Integer FIFO modeling bottles

Usually an integer FIFO is apropos the process when the array models the individual bottles and only the entrance and exit of the conveyor, and there is a sensor at both entrance and exit of the conveyor section, and the encoder is not used. I don't think this is the case for the current thread.

When a bottle is detected by the trigger sensor at the upstream entry station end of a section of the conveyor, a new integer value (First In), representing some measured property of the bottle e.g. accept/reject status, is appended to one end of the array. When a bottle is detected by a sensor at the downstream reject station end of a section of the conveyor, the oldest integer value (First Out) is removed from the other end of the array, and the value of that array is used to extend or retract the reject piston.

Caveats

  • These approaches model conveyor/bottle movement on an edge of the the relevant input signal; typically built-in bit-shift and FIFO instructions execute only on those edges, so even if input sensors are active for multiple contiguous scans, the array will shift only one position on the first of those scans. However, if such built-in instructions are not available and the OP has to build the bit-shift or FIFO model from atomic instructions, then they would need to implement edge detection (one-shots) explicitly.
  • The bit-shift model assumes that once a bottle enters the modeled section between entry station and reject station, the bottle is not moved relative to the moving conveyor surface; if that is not the case and there is adequate space between bottles, the code could assign two or more adjacent bits to 1 in the array when a bottle to be rejected enters the modeled section, and the array location of the reject station adjusted accordingly.
  • The integer FIFO model cares less about the position of bottle relative to the conveyor, but it does assume, between the entry and reject stations, that
    • bottles are not removed
    • bottles are not added
    • bottles are not re-ordered (I think this is what @bernie carlton is referring to)
 
Last edited:
Thanks for your reply
I will try build my own FIFO,but I think there is another main point that how to capture the current the value of encoder accurately at apositive edge from the trigger and compare it with the current value to activate the rejection piston
 
how to capture the current the value of encoder accurately at a positive edge from the trigger and compare it with the current value to activate the rejection piston

Without knowing details of the PLC make and model, or of the encoder make and model, I don't think anyone here can help you capture the current value of the encoder.

There a many ways to model a conveyor system, and not all of them require knowing the current value of an encoder and/or predicting what the value of the encoder will be when it is time to activate the rejection piston. For example, assuming the distance, from the place where bad bottles are detected to the the rejection piston, is constant, that can be modeled with a fixed length array of integers (FIFO) or of bits (Bit-Shift-Left/Right). That distance can also be represented as some number of encoder steps. Again, assuming that each and every change in the encoder value is detected by the PLC, and that that each such change represents one encoder step, it may be easier to detect each time the encoder value changes, than to try to track the encoder value itself and perform arithmetic with that value. In that easier method, each time the encoder value changes, the values in the FIFO or bit array are shifted by one position, and the value of the bottle - good or bad - at the detection station is placed in the position from which the shift starts. In such a model, the rejection piston is "located" at a fixed position in the array. When a "bad bottle" value is shifted into that reject piston's fixed position, the piston is extended; when a "good bottle" value is shifted into that reject piston's fixed position, the piston is retracted. There is no need to do any arithmetic with the encoder value; the only thing to do is to check when the value changes, and to shift the values in the array on each scan when it does change.

Please describe your process, and also please describe the model of the process as you think it might be represented in the PLC. List inputs and outputs. Sketches might be helpful.
 
Create a circular que, an array to hold each item and it's current position. The array position is irrelevant, which is different than a FIFO. Each scan you update the position based on the last scan encoder counts. Then search the array for a specific window and do code based on that.
 

Similar Topics

I'm running into a problem when trying to use the RSLinx Backup Restore Utility where it throws an error when it tries to restore a backup. The...
Replies
6
Views
575
Hi y'all I have a KTP400 connected to a s7-1200. Now i have on my screen the encoder value which comes from my SEW movitrac. under there I have...
Replies
2
Views
387
This was asked in another forum and taken down due to being a 'backdoor', but this has useful info that might be useful to someone in a pinch. I'm...
Replies
6
Views
610
Hello all, I'm using a 5069-L330ER in a project and I need to essentially capture some data that will be shown as a trend on a screen. The data...
Replies
9
Views
966
Hi all, I am working with an IO link sensor (measuring current across motor)and need to read in and store the sensor values for 5 seconds, then...
Replies
13
Views
1,215
Back
Top Bottom