Go to the LabVIEW Getting Started Window, click on Support, and click on Find FRC examples. There are examples for encoders under “Robot and Motor” and “Sensors.”
The examples do show you how to read the sensor values. What you do with the results is up to you.
So what do you want to do with them? That’s the question you need to answer in detail before you can get advice on how to do it. “Set distance” and “monitor travel” are too vague. You need to give much more detail on how your robot is designed, where you plan your sensors to be, and exactly what your goal is.
First - thanks for the responses, Second - please be patient!
We have never used encoders. Our method has always been to run the motors for a specific amount of time to get where we’re trying to go. Obviously conditions change and our results can vary.
We want to use the encoders to “measure” a specific distance, so we can program the robot to move “x…feet” and then stop (or do “whatever”). We also want to use the encoder output to compare movement from left and right and correct drift. We largely got lucky last year with our “run the motor for this long” method…but were burned by drift in several matches - having our auto shot miss because the robot turned slightly.
Please understand…I agree that the examples provide information, but I have to believe that there are many users like me who have tried hard to fill in the blanks and just can’t figure it out. A simple example of one of these “blanks” is where to put the code given in the examples…begin?..periodic tasks?..The examples are not at all “beginner friendly.”
This will be a new thing for us, and I really need to understand how to do it because I feel like I need to sell the idea to others on my team who think our programming is sophisticated enough…I really thing we need to master this if we expect to grow at all.
That’s a good high-level goal. Do you have any thoughts about how you would go about doing it? The encoder value is essentially the distance measurement you’re looking for, so that part is already available to you.
Comparing the encoder outputs is a simple matter of subtracting one from the other. When the values are the same, both sides of the robot have gone the same distance. When they differ, the robot has turned. You can use the difference to control the “X” input of an Arcade Drive function, so that the robot turns toward the direction of making the values the same again.
Please understand…I agree that the examples provide information, but I have to believe that there are many users like me who have tried hard to fill in the blanks and just can’t figure it out. A simple example of one of these “blanks” is where to put the code given in the examples…begin?..periodic tasks?..The examples are not at all “beginner friendly.”
Have you looked at the LabVIEW Tutorials? You want Tutorial 7, which tells you how to integrate examples into your robot code.
It is true that the example programs tend to focus on getting the encoders connected properly and getting valid readings from them. This is fundamental, and if not done correctly, it simply won’t work. Integrating this code into the framework is pretty straightforward once you get your bearings. Hopefully the integration tutorial will help. If not, please ask additional questions.
Doing something with motors and encoders quickly gets very specific to the mechanism being controlled. It is practically impossible for the framework code or game specific code to do much in the way of control because it doesn’t know what wheels, what gear ratios, the weight, weight distribution, or anything else about the robot. But luckily many teams each year do this code, and publish their code. If you find a team that works similar to you, builds similar robots, etc. Not only will you have something to read, but someone to contact.
I did a Google search for “LabVIEW FRC Drive Straight”. The top link was Team 27, and the doc on page 17 shows how they use a “by half” adjustment in order to straighten their robot. This is simple to implement and test and sounds like a good place to start.