FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Where do I put the Encoder reset in the Robot Main?

Sorry if this is a bit confusing but I've been spending this off-season trying to find out more about encoders and just had a quick question about where to put the code for Resetting the encoder back to 0 at in the RobotMain.vi? I've found some information on programming them and just haven't been able to come across where to actually put it.

0 Kudos
Message 1 of 5
(3,376 Views)

@5411 wrote:

Sorry if this is a bit confusing but I've been spending this off-season trying to find out more about encoders and just had a quick question about where to put the code for Resetting the encoder back to 0 at in the RobotMain.vi.


I recommend putting it about 2" down and slightly to the left of the center.  [I realize this "answer" might not be too helpful, but for everyone except your team-mates who will recognize your Forum name and will have the exact VIs in front of them for reference, there is not much to go on in your question.  Too bad that "RobotMain" is not a Standard VI that we would all recognize ...].

 

Bob Schor

0 Kudos
Message 2 of 5
(3,353 Views)

The RobotMain.vi is a standard vi when creating an frc robotics project. This is where all the scheduling is and framework of the project is located.

0 Kudos
Message 3 of 5
(3,346 Views)

There is an NI Forum here called First Robotics Competition Discussions -- you might get more viewers who "understand the question" (and possibly have sufficient experience to post a useful answer) there.

 

Bob Schor

0 Kudos
Message 4 of 5
(3,334 Views)

Can you explain your desired result?

 

Generally, encoders used in Robot Main are those used for PID loops to bring something to a specific location.

Encoders that you'd reset are more typically used for something along the lines of "drive for distance" where you want to go x" independent of where you currently are.  

 

For the first, you wouldn't reset the encoders.  You'd aim towards the known value.  With this, you'd want to do something along the lines of resetting the encoder the moment autonomous starts and then leave that value in place.  For the second, you'd hide the reset behind a case structure that runs when you hit the button to handle that task.  Keep in mind, you'll want to do something with your code to ensure this runs for a period of time following the reset without holding up the loop.  This can be a bit tricky to do well.  Have you considered looking at Command and Control and moving the encoder logic out of robot main and into one of the subsystems?

0 Kudos
Message 5 of 5
(3,315 Views)