Go to Post I can't wait to be one of those old kids who can say "Yeah, I remember the days before districts." and then watch the kid's eyes widen when I explain the days of regionals.. - rachelholladay [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-02-2011, 15:28
dmitch's Avatar
dmitch dmitch is offline
Chief Head Electrical Guy
AKA: Daniel Mitchell
FRC #1997 (Stag Robotics)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Bishop Miege High School
Posts: 142
dmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the rough
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.
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2011, 17:48
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
Re: Programming Motors for Arm

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.
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	247
Size:	55.8 KB
ID:	10020  
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #3   Spotlight this post!  
Unread 07-02-2011, 23:31
dmitch's Avatar
dmitch dmitch is offline
Chief Head Electrical Guy
AKA: Daniel Mitchell
FRC #1997 (Stag Robotics)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Bishop Miege High School
Posts: 142
dmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the rough
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!
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 08-02-2011, 01:20
Dustin Shadbolt's Avatar
Dustin Shadbolt Dustin Shadbolt is offline
In a server room somewhere...
AKA: Dustin Shadbolt
FRC #1555 (Team PULSE)
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Monticello,Indiana
Posts: 320
Dustin Shadbolt is on a distinguished road
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 08-02-2011, 08:35
JamesBrown JamesBrown is online now
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,280
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Programming Motors for Arm

Quote:
Originally Posted by dmitch View Post
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)

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:
Originally Posted by dmitch View Post

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!
Quote:
Originally Posted by dShad View Post
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.
You can do this but it will not work well. As battery voltage changes the distance travelled in that time will vary greatly. Also errors will compound, if you travel too far in one direction, then not far enough while returning then try to travel back in the original direction and go too far again you could be off by a significant amount. Repeat for an entire match and you could have the motors trying to overrun the physical capabilities of the joints.

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.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
Reply With Quote
  #6   Spotlight this post!  
Unread 08-02-2011, 15:41
dmitch's Avatar
dmitch dmitch is offline
Chief Head Electrical Guy
AKA: Daniel Mitchell
FRC #1997 (Stag Robotics)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Bishop Miege High School
Posts: 142
dmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the rough
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?
__________________

Last edited by dmitch : 08-02-2011 at 15:44. Reason: Addition to Post
Reply With Quote
  #7   Spotlight this post!  
Unread 08-02-2011, 16:13
JamesBrown JamesBrown is online now
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,280
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Programming Motors for Arm

Quote:
Originally Posted by dmitch View Post
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?
You can go to radio shack and pick up your choice of potentiometers, make sure they have a linear taper, and look at 10k pots.

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.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
Reply With Quote
  #8   Spotlight this post!  
Unread 08-02-2011, 21:35
dmitch's Avatar
dmitch dmitch is offline
Chief Head Electrical Guy
AKA: Daniel Mitchell
FRC #1997 (Stag Robotics)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Bishop Miege High School
Posts: 142
dmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the rough
Re: Programming Motors for Arm

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>
Attached Thumbnails
Click image for larger version

Name:	motordemo.PNG
Views:	109
Size:	17.3 KB
ID:	10032  
__________________

Last edited by dmitch : 08-02-2011 at 21:38.
Reply With Quote
  #9   Spotlight this post!  
Unread 08-02-2011, 22:58
j.cole j.cole is offline
Registered User
FRC #0379
 
Join Date: Jan 2010
Location: Girard
Posts: 159
j.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud ofj.cole has much to be proud of
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.
__________________

It's not normally a good idea to give a programmer a drill but rules are made to be broken.
Reply With Quote
  #10   Spotlight this post!  
Unread 08-02-2011, 23:25
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 7,011
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Programming Motors for Arm

Quote:
Originally Posted by dmitch View Post
Ok...what on earth does the PID control actually do?
It's a way for software to 'gracefully' bring some quantity to a specific value.

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.
__________________

I am N2IRZ - What's your callsign?
Reply With Quote
  #11   Spotlight this post!  
Unread 09-02-2011, 08:31
Egg 3141592654's Avatar
Egg 3141592654 Egg 3141592654 is offline
Now a mentor, always a student
FRC #0810 (Mechanical Bulls)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Long Island
Posts: 53
Egg 3141592654 is on a distinguished road
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.
__________________
"The answers to the book of life are not found in the back." Charlie Brown

Software Mentor - Team Apex Robotics 5803

Lead Programmer - Team 810 Mechanical Bulls '09-'11
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2011, 08:43
dmitch's Avatar
dmitch dmitch is offline
Chief Head Electrical Guy
AKA: Daniel Mitchell
FRC #1997 (Stag Robotics)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Bishop Miege High School
Posts: 142
dmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the roughdmitch is a jewel in the rough
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?
__________________
Reply With Quote
  #13   Spotlight this post!  
Unread 10-02-2011, 08:56
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,833
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Programming Motors for Arm

Quote:
Originally Posted by dmitch View Post
How will I determine the correct voltage when I get the arm position I want?
You physically position the arm where you want it, then measure the pot output in LabVIEW (front panel indicator or probe), or you use a multi-meter to get your voltage reading.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #14   Spotlight this post!  
Unread 10-02-2011, 09:01
MaxMax161's Avatar
MaxMax161 MaxMax161 is offline
Allegedly Useful
AKA: Max Llewellyn
FRC #2791 (Shaker Robotics), FRC #1676 (Pascack π-oneers)
Team Role: Mentor
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Montvale NJ\Troy NY
Posts: 174
MaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond repute
Re: Programming Motors for Arm

Quote:
Originally Posted by dmitch View Post
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?
Here's a quick .vi I wrote to learn about PIDs. It's not perfect but it allows you to simulate what a motor using a PID would look like. I think I did a decent job labeling everything, if not feel free to PM me and I'll explain anything you need.

I've already uploaded this in a different thread, here's the link. http://www.chiefdelphi.com/forums/sh...ad.php?t=90604
__________________
2791 Shaker Robotics (2013-present)
--Control Systems Mentor 2013-present
--Drive coach 2015-present

1676 The Pascack π-oneers (2010-2013)
--Drive coach 2011-2013
--Lead Programmer 2011-2013
Reply With Quote
  #15   Spotlight this post!  
Unread 10-02-2011, 09:21
Vikesrock's Avatar
Vikesrock Vikesrock is offline
Team 2175 Founder
AKA: Kevin O'Connor
no team
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2007
Location: Manchester, NH
Posts: 3,305
Vikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond reputeVikesrock has a reputation beyond repute
Send a message via AIM to Vikesrock Send a message via MSN to Vikesrock Send a message via Yahoo to Vikesrock
Re: Programming Motors for Arm

Quote:
Originally Posted by Mark McLeod View Post
You physically position the arm where you want it, then measure the pot output in LabVIEW (front panel indicator or probe), or you use a multi-meter to get your voltage reading.
Another option is to first convert your potentiometer voltage to an angle (The relationship should be of the form angle=m*voltage + offset). You can then use that angle to calculate the height of your arm end effector (you'll likely need to draw out the geometry to arrive at the correct equation). Your presets could then be set in inches from the floor.
__________________


2007 Wisconsin Regional Highest Rookie Seed & Regional Finalists (Thanks 930 & 2039)
2008 MN Regional Semifinalists (Thanks 2472 & 1756)
2009 Northstar Regional Semifinalists (Thanks 171 & 525)
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:32.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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