|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Labview Autonomous Help!
Sorry it took me a while to get back to you. It's build season
Unfortunately I don't have any existing example code to show you (this is my team's first year using LabVIEW), and I definitely don't have the time to make it for you (again, it's build season), but I can help point you in the right direction. To learn about encoders, my best recommendation would be to look it up in the LabVIEW example finder. They are a bit more complex than other sensors, but you should be able to manage it. PID is a form of closed loop programming; in other words, it allows you to take in feedback from a sensor and use it to achieve a certain goal. In this case, you will be using it to move your drivetrain motors (the output) until the average value of your 2 encoders (the input) reaches a certain distance (the set point). It does this using a fairly simple set of equations, labeled: Proportional Integral Differential The is an equation to determine each of these values using the input, set point, occasionally time, and the P/I/D gains. The proportional gain is represented by kP, integral gain by kI, and differential gain by kD. These numbers are simply used as a weight; the final product of each equation is multiplied by its respective gain in order to make it more or less powerful. Once you have calculated your P, I, and D values, you add them together, and send the sum to the output (in this case, you would run each of your drivetrain motors at (P+I+D)% power. So you might find yourself asking what these 3 equations that I have been talking about are. But I don't have the time to explain all of them, and you probably wouldn't have the time to fully understand my explanation. So instead, I am only going to describe P. In most cases, you actually don't even need to use I and D; just set their gains equal to 0 and pretend they don't exist. That is what I recommend you do for your drivetrain. If you are interested in learning about I and D, there are tons of resources out on the internet for you. So, the equation for P is: P = (setpoint - input) * kP It's a pretty basic equation. Essentially what this means is that the further away you are from the setpoint, the faster you will go. That's really all there is too it. There are no secret fancy tricks or anything like that. The final thing you need to know is how do you determine your kP value. And this answer is guess and check. If your robot starts violently oscillating back and forth, your kP is too high. If it moves to slowly and/or never actually reaches the setpoint, your kP is too low. Once you figure out an acceptable value, you are good to go. By the way, don't think that you have to go off and code all this math by yourself. There is a PID function built into LabVIEW. Just wire in your setpoint, input, and PID gains, and wire the output to each of your drivetrain motor controllers. All the math will happen in the background so you don't have to worry about it. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|