So, what I want to talk for a minute, more about rotary chapter encoder for those of you who don't know or haven't had experience with them. It's just another sensor, it can give very precise position measurements. So, encoder has power and ground coming into it and it has a pair of signals coming out of it and that's what the embedded system looks at and uses to keep track of the position. Here's this shaft that spins and on its two output signals or I got a timing diagram coming up here. We'll see as the shaft spins, it creates a set of square waves as its output. So, what goes on the end of this is usually what's called a pinion gear. So, this is pinion gear, so you can imagine that that pinion gear is mounted onto the end of that shaft and there is a set screw to hold it mechanically tight, okay. So, the pinion gear meshes with what's called a rack, so this arrangement is called a rack and pinion gear set up. It doesn't matter which one is in movement. The rack can be moving and encoder can be stationary or vice versa either way. But when the encoder is turning there's movement taking place either way, okay. I got a couple of links there for if you want to go, check out some more information about these encoders. So, it's output is a pulse train of the shaft rotates. The distance can be measured by counting of pulses. The output is referred to as a quadrature output or a quadrature signal pair, okay? The phase of these two outputs tell you what the direction or rotation is, and there's a really simple circuit you can use to figure out whether your counter, which is counting the position keeping track of the position is counting up or is counting down. In our case, is only counting up because a conveyor only moves in one direction. For things that move back-and-forth, you need to understand and be able to interpret the quadrature signal pair to know whether the devices, how far the device is moving in one direction versus the opposite direction. If the encoder is turning right, say we're holding the encoder and we're looking at the shaft, the shaft sticking out this way and write as, say right as clockwise, okay. If it's turning clockwise. There's two outputs I haven't labeled A and B. If it's turning to the right, clockwise, the square wave A will lead square wave B by 90 degrees. They're 90 degrees out of phase with each other. I was turning left then B. So, B is lagging by 90 degrees and the turning right case, if it's turning in the other direction turning left or turning counterclockwise. Then B will lead A by 90 degrees. So, B is either 90 degrees out of phase on one side or 90 degrees out of phase on the other side. That make sense? Okay. Incredibly simple circuit to determine the direction and then it doesn't matter which one you pick, just pick one A, you run and use it as a clock signal to a flip-flop and you run B into the data. As output Q here will tell you which direction you're going. So, if you think about it, if A is a clock, here we see a rising edge of clock, B is low, so we know we're turning to the right, we're going the other direction on the rising edge of the clock A signal. B is high, so we know we're going the other direction. So, your interpretation of the one and zero here tells you which direction the encoder is turning. Then, you just pick one of these, you can imagine you have an up-down counter or sitting off to the side of this and the up-down signal is controlled by the output of this flip-flop, and you just take one of these signals and use it as a count enable, it will count up or count down as the physical device moves back-and-forth.