Encoder Problems

Hey, we’re having some troubles with the Digital Encoder

I believe we have it wired right as the light is coming on, but whenever we run the program, I’m not getting any values for either rate or distance.

I’ve checked the code and we have the right DIO ports assigned to A and B.

Any ideas?

Not without some details from you, no.

“I believe we have it wired right” doesn’t let us know if what you believe is true. Tell us how you have it wired and let us decide if there’s something amiss.

“I’ve checked the code” doesn’t let us know if the code is correct. Show us the program and let us see if it’s doing what you think it should be doing. We can also tell you if what you think it should be doing is actually what it needs to do.

Wiring:
5v -> power on dio 4
gnd -> gnd on dio 4
A - signal on dio 4
B -> signal on dio 5

Programming in the pictures

I have DIOs set to 4 for A and 5 for B


encoder begin.JPG



encoder begin.JPG

don’t call the encoder config timer and start in telop. It will get called 50 times a second. Put them in begin, instead.

Using controls instead of constants for the channel numbers will work if you’re going to run Robot Main. Make sure to use the popup menu to set the current value as the default before you build the project. But I think it’s simpler to use constants instead.

We changed the controls to constants and moved the timer configure to the begin VI, but it still doesn’t work.

On the dashboard, when you spin the encoder, do you see the DIO change states?

We see nothing change on the dashboard, but we are using the dashboard on my personal computer, not the classmate





Does your code now resemble this example?

Take a look and get the encoder example working first. Then integrate that code into your robot code. Here are a few steps:

  1. From the LabVIEW Getting Started Window, click on “Find FRC Examples”.
  2. in the Sensors folder of the Example Finder, open the encoder example and get that to work.
  3. Back at the Getting Started Window (View>>Getting Started Window if you have VIs open), check out Tutorial 7 - Integrating Examples into Robot Code.