Progamming Encoder

Hi.
I’m going to program an encoder for traction for both sides run at the same speed, we never did that. We have an idea how it could be done, but we don’t know how to program it on labview.

1 motor =10 pwm out
2 motor = 9 pwm

1 encoder = 14 and 13 pwm in
2 encoder = 12 and 11 pwm

we heard that PID could be used to that.

if you guys could give us a example we would appreciated!

There are several good resources for this on ni.com/frc.
There is example code performing PID using an encoder available here:https://decibel.ni.com/content/docs/DOC-26316 and a PID tutorial available here:https://decibel.ni.com/content/docs/DOC-26317

Start by connecting the encoder to DIO pins, not to PWM outputs.

There are a couple of LabVIEW examples for reading encoders. They should give you enough information to work with.

Here is an example of the code for initializing and reading from a quadrature encoder(a quadrature encoder provides support for lowering the encoder count if the motor spins “backwards” from the encoder positive). If you were to initialize in begin.vi (as you should) you would use an Encoder RefNum Set in begin.vi and then feed a RefNum Get through the Dig Src to the Encoder Open and then to the Encoder Get. Keep in mind that without the DistancePerCount parameter (the double constant wired to the Encoder Open) the encoder will read in counts, not distance. The constant attached to the DecodingType input is dependent on the encoder you are using, as is the DistancePerCount.

-Ti00

QuadratureEncoder.png


QuadratureEncoder.png