View Single Post
Old August 6th, 2022, 09:28 AM   #8
Lifetime Supporting Member
United States

drbitboy is offline
drbitboy's Avatar
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,585
Originally Posted by parky View Post
I agree with Brian,...


And I agree with @parky.

One way to deal with this, assuming the encoder rollover is a power of 2 (e.g. 8192 = 213), is to use one of the bits of the encoder that will always take at least one or two PLC scan cycles to change.

Simple calculation of encoder rate
  • 250mm per cylinder (170mm of cylinder + 80mm of gap)
  • 5 cylinders can be on the conveyor at any one time
  • 500ms for a cylinder to go from one end to the other
  • radius of conveyor is 75mm (~3")
    • so 75mm of conveyor movement is 1 radian of conveyor wheel angular rotation
  • 1 revolution per 2π radians
  • 8192 pulses per revolution
  • 3ms per scan cycle

250 mm 5 cyl 1 conveyor length 1 Radian 1 revolution 8192 counts 3 ms encoder counts
Pulse rate = ------- x --------------- x ----------------- x -------- x ------------ x ------------ x ------------ = 130+ --------------
1 cyl conveyor length 500 ms 75 mm 2π Radian 1 revolution 1 scan cycle scan cycle

Those are just sample estimates based on earlier posts and a guess at the encoder/conveyor wheel diameter, but it should be illustrative of the process.

If it is close then it means that
  • the conveyor moves 7 or 8mm per scan cycle
  • bit 8 (value 256) of the encoder count will have an edge every two cycles or so, and no more than one edge every one cycle,
    • so we could use changes (rising and falling edges) in that bit 8 as the trigger to shift the bits in the FIFOs,
    • which would represent ~15mm of conveyor movement (2π x 75 x 256 / 8192).
That 15mm should a small enough fraction of the gap between cylinders, that 1 index of padding on either side of any defect bit location will not spill over to an adjacent cylinder.

If that calculation is not close, then that only means a different bit in the encoder count would be used to trigger the bit shifts; the key is to pick a bit for which the scan cycle never fails to detect an edge.

If the encoder count rollover is not a power of two, then it gets messier, but still solvable.
Brian T. Carcich
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
iii) Measurement is hard.
iv) I solemnly swear that I am up to no good

Last edited by drbitboy; August 6th, 2022 at 09:36 AM.
  Reply With Quote