![]() |
Programming Motors for Arm
I am a rookie programmer this year. Our team is using motors on each arm joint to control the arm position. How do I set it up so that a joystick axis or a joystick button can control a motor? Also, I want to have several "presets" for the arm position so that it will minimize the amount of work our driver has to do. How can I set it up so that, for example, button 1 will align the arm with the top middle peg. I just need to set up something that will say "when button 1 is pressed: run both window motors in their correct directions x degrees and run the second joints motor y degrees at the same time.
Our arm setup is: one arm coming up from chassis, bolted to chassis; at the top of that there is a joint that is controlled by 2 window motors facing opposite directions(that is they need to be run at the same time, one clockwise, one counterclockwise to work the joint); then that arm joint proceeds about 2 feet out and there is another joint there that is run by only 1 motor. then the arm ends in the claw. Thank You for All Help in Advance, and I prefer pictures but anything will work as long as it explains clearly. |
Re: Programming Motors for Arm
1 Attachment(s)
Uh this is a bit complex because of the number of motors but Ill try.
The two things that I need to know are what is controlling the motors (if at all possible use speed controllers (we use victors so I don't know the can system on jags if you need can). Also do you have encoders/potentiometers attached (the only way this will be possible)? (will only work with speed controllers) Now to have set positions (you will need 6) what I did is to have a toggle between middle and outside columns and then 3 buttons to designate which row. Then make a case statement decided by a Boolean array with what values you want (it will come out in binary into the case). now wire a PID (wiki it its kinda complicated) VI outside of the case with your encoder values going to the process variable and some numerical value inside going to the setpoint. Then the output to a motor set vi. You will need to do this 3 separate times i think. (I know im forgetting something but Ill post a pic of my 2 motor system code for you to look at) If you just want a manual control with speed controllers (which since your new to this is suggested). You just wire whatever axis you want to control the motors to the input on the motor set. If you need further help I'm willing to post pictures. I guarantee I left something important out. |
Re: Programming Motors for Arm
I am going to be using Jaguars to control the arm motors. And by encoders do you mean I need to attach the US digital encoders to the motor axles?
If so, how do I wire these?(I'll look at the sensor manual but I'm hopeless with technical diagrams) Is there not a way to have a case structure that holds a set motor vi and I can set the motor to run EITHER at x speed for y seconds OR for x degrees?? It seems to me that this would be quite a bit easier. I'm going to look over your code tonight and try to make sense of what everything does. I'll probably be able to post tomorrow to ask questions and clarify some stuff. Thank You! |
Re: Programming Motors for Arm
Yes you could use a timer to run the motor for X number of seconds. It's a quick and easy way of doing some preset height work.
|
Re: Programming Motors for Arm
Quote:
You will need some kind of sensor to get position feedback. You could use the US digital encoders, but that may not be the easiest way. I recommend using a potentiometer for any joint that does not rotate more than 360 degrees. There are also absolute position magnetic encoders that you could use if you want the joint angle but the arm rotates more than 360 degrees. There is information for wiring all of these in their data sheets. For a pot you are going to connect one side to power, the other to ground, and the wiper to signal. If you can't figure out how to wire the sensors I recommend asking a mentor. It is better for him to teach you how to read a data sheet than it is for us to tell you how to wire a specific component. Quote:
Quote:
In general you don't want to use timers. It is not difficult to add a potentiometer to a joint and the benefits of having closed loop control on your arm far outweigh the effort. |
Re: Programming Motors for Arm
Ok, In your experience what are the best potentiometers for this kind of use?
And then I just need to set the code to run motor A until the potentiometer gives me angle x? Also, are potentiometers accessed via the generic DIO vi on LabView? And then how is this coded? I will write some code today at the shop to try and get this done and I will post it tonight if I can. Just be warned: Its bound to have quite a few errors in it. All I learned how to do last year(from our less-than-great-teacher programmer) was how to set up mecanums and how to wire solenoids. And does the potentiometer read degrees? So can I just do the thing from paragraph 2 up above? Or will I have to do something else? |
Re: Programming Motors for Arm
Quote:
Potentiometers are conected to the analog inputs on the controller. If you just turn on the motor until you get to the desired angle you will overshoot it every time, and not by a predictable amount. You should look into PID control. |
Re: Programming Motors for Arm
1 Attachment(s)
Ok...what on earth does the PID control actually do?
And I set up some quick code on a blank VI that I think will do what I want it to do which is basically take 1/4th the speed of the joystick and set the motors to run at that speed. This is for fine-tuning of the arm position if we have the presets working. The image is attached. And when I wire the potentiometer is the signal wire supposed to go to the analog card on the ccRIO> |
Re: Programming Motors for Arm
Looking up the wiring diagrams for everything is just going to put you in circles.
For Pots you wire 3 cables (pwm cable) into an analog port on the cRIO, one to the power one to the ground and one to the wiper (the wiper is your signal). For encoders you wire The voltage, a signal, and ground to one female pwm end and the b signal and ground to another pwm. Both of these pwm's go into the dsidecar LabView wise for pots you read the driver station analog input (1-4) reference example "Potentiometer with Driver Station". If you want the degrees you will have to do some math which involves your potentiometer size (10K or whatever it is) and the voltage given from the analog input port on the cRIO (i think its 5v not sure though). For encoders you need to open 2 DIO's in the begin (dsidecar ports) and put them into a couple encoder vi's (in the WPI library) which I don't know the whole row so follow the "Encoder Example" example to know for sure. PID is a mildly complex control system (wiki it thats how I learned it a few weeks ago actually) that will slow down the motor output until it hits the correct values (or goes over in which case it will reverse). Fun stuff and yet again with such a big post I probably forgot something. |
Re: Programming Motors for Arm
Quote:
OK, some examples: You are riding a bicycle. You want to stop right at a fire hydrant by the curb. You wouldn't go at full speed, and then slam on the brakes at the right moment - too much chance for missing the spot. Instead you slow down gradually, stopping exactly where you want. This is PID control, the quantity being the exact spot where you will stop. Another example: A Cruise control in a car. You set the system to maintain a certain speed, and it does. A good system does not apply full throttle when the speed drops one or 2 MPH because of a hill, it applies a little throttle, only adding more if the hill is too steep to maintain the 'set' speed. This is PID control, the quantity being the set speed. PID stands for Proportional, Integral, Derivative. Proportional means that you apply a corrective signal (like a car's throttle) in proportion to the difference ("error") between the actual value and the desired value. A car going 2 MPH slower than the set speed needs only a little throttle, but one going 30 MPH too slow needs a lot of throttle. Integral helps keep a steady value when the P "error" is very small. It adds up the error over time, so that even a small error gets compensated for after several seconds. Derivative keeps you from making changes too rapidly, but allows you to make big changes when necessary. You don't want the cruise control at full throttle until 1 MPH below the setpoint - you'll "overshoot" the set speed and have to slow down. Instead this works with P do gradually hit the set speed. In robotics, PID can be used to move an arm to a set position. Depending on the mechanism, P may be enough, or possibly PI. Full PID is often overkill and unnecessary in a typical FRC design. |
Re: Programming Motors for Arm
There are two schools of thought to this, but personally I prefer PID control because I have seen/done it before effectively. If you want pre set positions, I would say that the potentiometer + PID to be the best control system for your robot. Not only will the values stay consistant, the arm will almost always go into the same position (assuming that you don't move the potentiometer (or pot)). The PID function is found under the analog tab. Basically, the set point determines what voltage the pot should read at the desired position, the process variable is the raw instantanious pot reading, the array of 3 values that are used to tune the loop (bottom always 0, mid is 0 or really small, top is the tuning number >0). The top output is the value you set your motors to. It is a bit confusing, pm me if you need examples/extra explination.
|
Re: Programming Motors for Arm
How will I determine the correct voltage when I get the arm position I want? And then for the process variable, which I understand to be the actual position of the pot, you mentioned an array; is this preset in the PID or will I have to do something extra for that?
|
Re: Programming Motors for Arm
Quote:
|
Re: Programming Motors for Arm
Quote:
I've already uploaded this in a different thread, here's the link. http://www.chiefdelphi.com/forums/sh...ad.php?t=90604 |
Re: Programming Motors for Arm
Quote:
|
| All times are GMT -5. The time now is 09:16. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi