Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Motor Encoder code. LabVIEW (http://www.chiefdelphi.com/forums/showthread.php?t=90760)

JohnFogarty 02-02-2011 11:38

Motor Encoder code. LabVIEW
 
So this year for FRC we are using an arm system with motors that are geared down so much they are non-back drivable meaning when there is no power applied to them the won't move. What I want to accomplish in LabVIEW is to be able to push a button and have a motor go to a certain position. and in reality a button would be able to move several motors simultaneously to certain predefined positions. I've been told that the encoders we use are relative encoders and so that changes how this can be accomplished a bit. Any help would be appreciated.

John Fogarty

apalrd 02-02-2011 11:45

Re: Motor Encoder code. LabVIEW
 
1. Potentiometers are better than encoders because the are absolute, so you don't loose your position when you reboot (and if you happen to die during a match, you won't have to return to home before using your robot)

2. You would probably want to use P or PID control. Wikipedia has a great article about it - http://en.wikipedia.org/wiki/PID_controller.

3. Start with P. If it has issues (which generally only happens if it moves very fast, which yours dosen't seem like it does), then you can add D. I might be necessary, but probably not.

4. You would probably have a controller for each joint, and feed the setpoints from an array.

Here's how I would write the code:
1. Create an enumerated type to define the state. In LabVIEW, create an enum and edit the items in the list.
2. Create a cluster (in C++, it's a structure), defining the setpoints for all controllers. For example, you would have a Dbl for each joint, then hit the "align horizontal" button for LabVIEW to make them all nice and neat
3. Create an array of the clusters. Each line in the array will represent one item in the state.
4. Since an enumerated type can be used as a uint8, find the numeric representation of each and label each item in the list. Then, use the Index Array block (just index in C, with an array[item]) and get the item in the array that goes with the state.
5. Drive the arm with the newly aquired cluster of positions
6. Set the state whenever a button is pressed.
Make sense?

Mark McLeod 02-02-2011 12:42

Re: Motor Encoder code. LabVIEW
 
1 Attachment(s)
Here's a generic example of using PID to drive a motor to a desired position.

Wicked 03-02-2011 15:59

Re: Motor Encoder code. LabVIEW
 
Quote:

Originally Posted by apalrd (Post 1014083)
1. Potentiometers are better than encoders because the are absolute, so you don't loose your position when you reboot (and if you happen to die during a match, you won't have to return to home before using your robot)

Couldn't you just use the absolute encoder to get around this?

JohnFogarty 03-02-2011 17:34

Re: Motor Encoder code. LabVIEW
 
Quote:

Originally Posted by Wicked (Post 1015027)
Couldn't you just use the absolute encoder to get around this?

expensiveeeeeeeee.

Wicked 03-02-2011 17:46

Re: Motor Encoder code. LabVIEW
 
...It's included in the KOP, what other expenses are there?

Dkt01 03-02-2011 18:13

Re: Motor Encoder code. LabVIEW
 
We're using 3 potentiometers on our robot this year and they work great. We'll also have encoders, but so far they don't work as easily. Plus, it's really easy to convert a potentiometer's voltage to an angle or distance (even changing where your base position is).

JohnFogarty 04-02-2011 12:41

Re: Motor Encoder code. LabVIEW
 
Soo It sounds like Pots are alot more common and easier to use, and the only encoders we found in the KOP are a optical disk type of encoder that are relative encoders. There are small boards for rotary and linear encoders but the encoders themselves aren't included. We plan on going to radioshack and getting some pots to use.

Alan Anderson 04-02-2011 13:38

Re: Motor Encoder code. LabVIEW
 
Quote:

Originally Posted by John_1102 (Post 1015543)
There are small boards for rotary and linear encoders but the encoders themselves aren't included.

"The encoders themselves" are embedded in the larger black integrated circuit devices on those boards. The two magnetic rotary encoders came with the small round magnets that are used with them. The magnetic linear encoder came with the thin flexible magnetic strip that is used with it.

Look at the Kit of Parts web page to find the Parts Data Sheets for the AS5030 - Rotary Magnetic Encoder and AS5304 - Linear Magnetic Encoder devices.

Dustin Shadbolt 05-02-2011 09:55

Re: Motor Encoder code. LabVIEW
 
Hey guys I had a quick question, where do we hook up the Potentiometers? I'm begining to branch out and learn some electronics to help some freshmen but the example vi on lv didn't help much.

Mark McLeod 05-02-2011 10:01

Re: Motor Encoder code. LabVIEW
 
They are analog inputs, so use the Analog Breakout.

Dustin Shadbolt 05-02-2011 10:15

Re: Motor Encoder code. LabVIEW
 
Thanks Mark!


All times are GMT -5. The time now is 03:47.

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