View Single Post
  #9   Spotlight this post!  
Unread 09-02-2009, 20:59
MBernstein MBernstein is offline
Registered User
FRC #2888
 
Join Date: Jan 2009
Location: Beaver Country Day School
Posts: 2
MBernstein is an unknown quantity at this point
Thumbs up Re: Optical encoder not returning values

Quote:
Originally Posted by TheOtherGuy View Post
Have you wired it correctly? There should be a +5, A, G, and B on the encoder.
PWM 1 - black to G, red to +5, white to A
PWM 2 - black to G, red to +5, white to B

The second PWM cable doesn't really need the ground and power connected. Since you didn't provide enough information, are you sure you connected both the A and B channels and selected the right ones in LabView? (are you using LabView or C++?)
I believe we do have it wired correctly, as it matches what you state above (we don't use the ground and power on the second PWM cable). Originally we connected it to the analog i/o but then realized it needed to connect to the digital i/o.

We are using C++ and have test code like the following, just to verify the encoder is working correctly:

Encoder encoder(1, 2, true);
while (1) {
count = encoder.Get();
cout << count;
}

We then rotate the middle of the encoder, but the count stays at 0. How should we be using the Encoder class to read values from the encoder?