Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Labview Autonomous Help! (http://www.chiefdelphi.com/forums/showthread.php?t=124527)

alexander.h 12-01-2014 15:11

Labview Autonomous Help!
 
1 Attachment(s)
Hello!

I have a question concerning the autonomous code in Labview :

Let's say I put the code in for the robot to advance 5 meters during autonomous and I'm sure that with a battery charged at 100%, it should take 2.5 seconds. With the same code, but with a battery charged at 70%, will it still advance 5 meters? If not, should I use the battery voltage as a control (see the thumbnail below) and stick that into a mathematical calculation which gives me the same distance each time, but a different time allowed, according to the battery voltage?

Thanks

Owen Makin 12-01-2014 16:45

Re: Labview Autonomous Help!
 
On this website it shows how to run your drive train at a certain amount of volts . You could try using that, just search for the word voltage. http://team358.org/files/programming...2009-/LabVIEW/

alexander.h 12-01-2014 17:11

Re: Labview Autonomous Help!
 
Quote:

Originally Posted by Owen Makin (Post 1326042)
On this website it shows how to run your drive train at a certain amount of volts . You could try using that, just search for the word voltage. http://team358.org/files/programming...2009-/LabVIEW/

Thanks!

Pault 12-01-2014 17:21

Re: Labview Autonomous Help!
 
If you try to run your drivetrain using timing, even if you take battery voltage into account, you aren't going to get very accurate results. If you are trying to drive a certain distance, the best way to do it is to use the encoders that come attached to most drivetrain gearboxes to calculate distance. Then use PID to control how far you go. That's going to give much more accurate results than what your trying to do with battery voltage, and from a coding standpoint is probably much easier to implement.

alexander.h 12-01-2014 18:17

Re: Labview Autonomous Help!
 
Quote:

Originally Posted by Pault (Post 1326054)
If you try to run your drivetrain using timing, even if you take battery voltage into account, you aren't going to get very accurate results. If you are trying to drive a certain distance, the best way to do it is to use the encoders that come attached to most drivetrain gearboxes to calculate distance. Then use PID to control how far you go. That's going to give much more accurate results than what your trying to do with battery voltage, and from a coding standpoint is probably much easier to implement.

Thanks! Could you maybe attach a pic of the type of code I would need?
I've never used PID. What is it?

Aaron.Graeve 12-01-2014 21:21

Re: Labview Autonomous Help!
 
PID is a general control loop for getting a physical action to a particular point. By using a sensor on the moving part, the code compares the current position of the part to where it is supposed to be (the error), how long the part is taking to get there (the cumulative sum of the error), and how quickly the part is moving (the derivative of the error with respect to time) and uses these to calculate a new value for the controlling motor to be powered. For an closed-loop autonomous drivetrain, you would almost certainly need to use an encoder on the wheels (two really, one for each side so the robot goes relatively straight). There are many papers published here on Chief Delphi and all over the net about this. Since the loop is updating many times a second, it can very quickly adjust to changing conditions or resistance. Control loops are, in my opinion, the biggest difference programming-wise between good and great teams. You may find them useful even in teleop if there is a mechanism that needs to be held at a particular angle.

Message me if you have any more questions.

Pault 14-01-2014 19:05

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.


All times are GMT -5. The time now is 09:46.

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