As an offseason project we are trying to read the encoder rate from a vexpro ballshifter and use it to automatically shift when a desired rate is reached.
To test the rate we are using the LV sample program “encoder and motor”. All values, but the encoder rate, show up consistantly. The encoder rate (deg/sec) values fluctuate between 50-1000+ when at full speed. How do I make the range of encoder rates more useful? The encoder is a Usdigital e4p 250-250-0-0-0-0.
At what rpm (or deg/sec) do the encoder values begin to go bad?
Have you calculated the maximum theoretical rpm that the encoder will support?
Have you compared the number of ticks per second that the encoder will produce at max rpm to the maximum ticks that the cRIO will support (~39,000/sec)?
A simple experimental test is to try running the encoder at 1x or 2x to demonstrate if 4x is attempting to sample too much , too quickly.
After verifying the wiring, another issue with that model encoder is the proper installation and spacing of the encoder disk.
If it isn’t spaced properly, using the spacer aid that should have come in the kit, then the rate will be random at all speeds.
The encoder disk also needs to be tight on the shaft rotating it, and the shaft itself cannot have very much play which would change the spacing as well.
[FONT=Arial][size=1]“Accepts +/-.020” Axial shaft play"
Finally, if you have other EP4’s be careful not to mix the encoder disks. The disks and encoder package are paired specifically to match up cycles per rev. Your model number specifies it is 360 cycles per rev., but if you happened to also own a 250 or 100, then they would not work with the 360 model and they are hard to distinguish between.
It depends on what you want Get Distance to return.
In the example code you are using it isn’t actually setup to return distance. It is setup to return an angle of rotation. In normal usage I’d prefer the Get Distance to return actual inches travelled.
If you want to use the example code as is and keep Distance as a rotation angle, then you can determine the value experimentally by setting DistancePerCount to 1, rotating the wheel 360 degrees (or some multiple to help reduce error), finally dividing 360 by the “Distance” to get DistancePerCount in degrees/count. You’ll need to add a display of the raw Distance value, so you can use it. The value can also be calculated analytically as long as you take into account any reduction, so you know what a full rotation is.
If instead you want to have the Get return actual distance travelled, then follow the (paraphrased) example given by the LV Help detail for Encoder Open:
“For example, if the wheel diameter is six inches and the encoder pulses 360 times per rotation of the wheel (at 1x), then a scaling factor of 6*pi / 360= .0524 returns the number of inches the wheel has turned. In this case, you input .0524 .”
I also recommend experimentally verifying the distance value by setting DistancePerCount=1 (that’ll output the number of ticks as the “Distance”), adding a display of the raw Distance value, then slowly push your robot a pre-measured distance using a tape measure. That’ll give you the proper value to use by dividing the measured distance by the Get Distance.
We recently noticed an interesting issue with an E4P encoder codewheel disk. It turns out that the reflective stripes on the codewheel disk from which the encoder picks up the pulses are not applied directly to the disk itself. Rather, they are applied to a plastic film disk that is attached to the codewheel, probably with an adhesive of some kind.
After removing the codewheel from the shaft for cleaning, we found that this plastic film was spinning relative to the disk. There was still a relative tight interference fit of the the plastic film disk to the hub of the codewheel, but it was easy to make it spin on the codewheel and you could easily peel up the edge.
In the past, we have cleaned the codewheel disk with rubbing alcohol & a Q-Tip and alcohol-based eyeglass cleaning wipes, and I suspect the alcohol seeped under the plastic disk and dissolved the adhesive. Probably won’t be cleaning them that way in the future.