OHH MAN! Well I guess that solves all my problems! I thought it was the frequency of the whole wave NOT just changing states. WOW! So that finally solves my issue with the code.
Just to clarify to close this once and for all. Your frequency is state change and not full cycle AND the fact that you have 2 times the state change for the encoder counts is because you count 2 encoder counts per pin. So for 2 pins (2 waves) you count every change from high to low or from low to high (falling and rising edges). Is that correct?
Now to understand why my encoder is doing this to me.
I’m basically rotating the output part of the shaft (wheel) 360. There’s a screw to hold the wheel hub to shaft, and I’m using that as my reference.
I’ll tell you my issue in full. I’ve been assigned this project from someone before me. I have the encoder which I’m 100% sure of because I have the receipt email from robot shop. I have this rover that I also inherited, however, I don’t really trust the info on the website. I’m essentially trying to write a code on both arduino and raspberry pi to work with that encoder and motor combination.
The issue is that I’m not sure of the readings from the encoder. So I thought I’d make a simulation (with your code) so I can test MY code on both arduino and raspberry pi. Once they’re good and are giving me the same results, I can integrate them into the project.
Right now I’m getting stable results on arduino from the simulator (yours) and the encoder (230 transitions). I’m not sure why I’m getting 230 but that’s what I’m getting. I’m using the same code that I’ve included before.
What I’ll be doing next is writing code for the raspberry pi!
Hope that explains what I’m doing exactly.