Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Reading Encoder Values from Net Console (http://www.chiefdelphi.com/forums/showthread.php?t=123056)

ArzaanK 12-12-2013 14:16

Reading Encoder Values from Net Console
 
Hello,

Earlier, my team wired up some encoders on our drive train for testing. I then wrote some code to bring up the number of encoder clicks. However, every time I open up Net Console, I get the output "Clicks: 0"

I'm wondering if this is a programming, or an electrical, or mechanical issue. My code is as follows. (I'm only going to include the code that relates to the encoders)


Code:

#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
       
        Encoder *rightEncoder;
       
public:
 RobotDemo()
 {
        //Encoders
        rightEncoder = new Encoder (3,4);
        rightEncoder->Start();
}
 
void OperatorControl()
 {
    while (IsOperatorControl()){
                  //Encoders
                  printf("Clicks: %d\n", rightEncoder->GetRaw());
                Wait(0.05);
    }
 }

The "rightEncoder" is the encoder on the right side of our drivetrain. I didn't include the drivetrain code, but when I move the right side of the robot, the printout is still "Clicks:0"

Are there any flaws with my code, or could it possibly be an electrical or a mechanical issue?

Any help is greatly appreciated.


All times are GMT -5. The time now is 12:53.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi