|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Explanation.
Okay so its really not needed cause im not going to be placing anything on my driver station. Could i use this to rotate a motor a certain degrees?
Last edited by mtnteam : 16-02-2012 at 12:07. |
|
#2
|
||||
|
||||
|
Re: Explanation.
Sure. What you're interested in is the Arm Raise portion of the code. This section looks at an encoder and counts how many "ticks" (lines on the encoder wheel) have passed. Depending on what the constants in the case structure are is the amount of ticks that it should count. Once it knows how many, it should then keep moving the motor until that many have been counted.
|
|
#3
|
|||
|
|||
|
Re: Explanation.
Okay cool. Is the number of the ticks the numeric values in true and false structure connected to the PIDs?
Last edited by mtnteam : 16-02-2012 at 14:20. |
|
#4
|
||||
|
||||
|
Re: Explanation.
I believe so. I'm not sure what that PID block's inputs are since I don't have LabVIEW open right now, but it makes sense.
|
|
#5
|
|||
|
|||
|
Re: Explanation.
I do appreciate you helping me out. I have one more question if you don't mind. If i were to tweak the distance out a bit to give me the degrees, would i be able to use that instead of the ticks?
|
|
#6
|
||||
|
||||
|
Re: Explanation.
You could, but you would have to find some sort of "ticks vs degrees" relationship via experimentation. Maybe have the robot move 20 ticks and check how many degrees have been moved on your motor.
|
|
#7
|
|||
|
|||
|
Re: Explanation.
okay thank you. I think this example would help out a lot of teams. Thank you very much for your help. If i have anymore questions, would you mind if i messaged you about it?
|
|
#8
|
||||
|
||||
|
Re: Explanation.
Don't mind at all, although if it's something that other teams should know feel free to start a topic and message me the link, that way more people benefit!
|
|
#9
|
|||
|
|||
|
Re: Explanation.
Alright sounds good. I just been reading other topics in the past couple days. Most of them were asking how to have a motor controlled with a push of a button using an encoder.
|
|
#10
|
|||
|
|||
|
Re: Explanation.
assuming that this is in the teleop, which is inside the robot main loop which executes aprox every 20 ms. ok so if you walk through the code, it feeds the 4 buttons into an array, then it uses a boolean to number conversion to return the array index of the button that was pressed, then it checks to see if the array index of the button pressed was greater than 1(which i assume zero is the default case). it also writes the index value of any button that was pressed to a global variable called arm binary. then it feeds the results of "was button pressed" >1 to a select function, where it compares the index value of button pressed>1 to the global variable arm binary. now if a new button was pressed, and was greater than one, it moves to the case that corresponds with the index array of that button (ie.. top row, middle row, ect). and feeds the appropriate values to the pid controllers for the desired position. if the loop iterates and a button was not pressed then it executes the value read from global variable arm binary and stays at whatever the last position was (ie.. top row, middle row, ect).
|
|
#11
|
||||
|
||||
|
Re: Explanation.
I think a single case statement with a bunch of different cases would've been a more efficient way to write this, but oh well...
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|