Go to Post Given the time Banebots has already cost us, what's a little snow? - pfreivald [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-01-2008, 18:48
Neurovirus Neurovirus is offline
Registered User
FRC #0224
 
Join Date: Jan 2008
Location: Piscataway
Posts: 13
Neurovirus is an unknown quantity at this point
Exclamation Operator Control Help

I'm a total newbie at programming,

so I want to know how to give motors different speed based on the position of the analog sticks on the xbox 360 Controller (in Mode 1)

and how to use the Right Trigger on the controller(which I mapped to "trigger"), to extend a pneumatic arm when pressed, and retract it when released.

Also how to control a motor using buttons on the controller (one for up, another for down)

Thanks in advance
  #2   Spotlight this post!  
Unread 12-01-2008, 18:55
rhoads2234's Avatar
rhoads2234 rhoads2234 is offline
Registered User
AKA: Erin
FRC #2234
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: PA
Posts: 80
rhoads2234 will become famous soon enough
Re: Operator Control Help

for the the trigger have an if statement that checks the trigger and the else would release it

use the IFI dachboard to see what the analog sticks on the joystick are and then pull that value into the motors
the code would look like
pwm01=p1_y;
/* this grabs the y axis value of the port 1 joystick and makes the pwm # 1 equal to it
__________________
ALWAYS a mechanical problem!
  #3   Spotlight this post!  
Unread 12-01-2008, 18:57
JohnC's Avatar
JohnC JohnC is offline
my other name is nigel
FRC #0360 (360 Revolution)
Team Role: Programmer
 
Join Date: Mar 2005
Rookie Year: 2005
Location: user_routines.c
Posts: 100
JohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the rough
Send a message via AIM to JohnC
Re: Operator Control Help

Check out this for now.

http://www.chiefdelphi.com/forums/sh...ad.php?t=33473

I'm in the lab working right now, but if when I get home nobody has answered this in detail, I will address all of your questions
__________________
What place are we at? ... TODAI!
  #4   Spotlight this post!  
Unread 12-01-2008, 20:35
i_am_samus's Avatar
i_am_samus i_am_samus is offline
Why? Why not.
AKA: Rida
FRC #2590 (Nemesis)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Robbisnville, NJ
Posts: 93
i_am_samus has a spectacular aura abouti_am_samus has a spectacular aura abouti_am_samus has a spectacular aura about
Re: Operator Control Help

You also want to make sure that you are using analog values and that neutral is at 127, meaning nothing is moving, the joysticks are in their normal position. 255 should be max (or at least near it), so going full speed forward. 0 should be your full speed reverse, make sure to calibrate your controller for that.

After that, you can use loops (like while, for, or switch) or conditionals like if, else statements.

Like:

if(pwm01 == 255)
full speed ahead;

of course that's pseudo code. At www.ifirobotics.com you can find default code for the controller, that already defines all that for you, so you don't have to worry about doing all that.
  #5   Spotlight this post!  
Unread 12-01-2008, 20:51
jee7s jee7s is offline
Texan FIRSTer, ex-frc2789, ex-frc41
AKA: Jeffrey Erickson
FRC #6357
 
Join Date: Nov 2007
Rookie Year: 1997
Location: Dripping Springs, TX
Posts: 319
jee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond reputejee7s has a reputation beyond repute
Re: Operator Control Help

Everything that has been said here so far is good advice. A couple extra points:

1. While 127 is "true" neutral for a PWM, there is a dead band where the motors won't respond. This depends on the motor attached to that PWM and the load attached to the motor, so you have to test your code on the completed mechanisms.

2. As for your "press to extend, release to retract" idea, you need to monitor the trigger for a state change. For example, this snippet should work for what you suggest:

if(trigger == 1){
if(last_trigger == 1){
//remain extended
}
else{
//extend
}
}
else{
if(last_trigger == 1){
//retract
}
else{
//remain retracted
}
}

Something along those lines would work for your trigger. Keep in mind that the user becomes involved too. If that finger slips, even for an instant, the retraction will occur. It may be possible to stop and reverse that action, but if it is absolutely necessary to keep the pneumatic extended, a switch is the way to go.

-JEE
  #6   Spotlight this post!  
Unread 12-01-2008, 23:21
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Mentor, LRI, MN RPC
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,815
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Arrow Re: Operator Control Help

The simple answer is, it depends But i'll try to lay things out for you in a way that you can figure out from your situation.

First, a brief overview of the controller. If you're using a 360 controller, then i assume you're using the USB chicklet from IFI? if so, then this document will help:
http://www.ifirobotics.com/docs/usbc...ual-rev1-2.pdf

The controller is plugged into one of your joystick ports (lets say 1, for the sake of argument). That port has a number of variables associated with it:

p1_x
p1_y
p1_aux
p1_wheel
p1_trig
p1_top
pt_aux1
p1_aux2

Now, if you look at the mappings on page 5 of the document above, you'll see what actions map to which variables. for example, button 1 maps to p1_trig. So, if you press on button 1 (which ever button that's assigned to), the value for p1_trig will change to 1. when you release, it'll go back to 0. That gives you a very easy way to tell when a button is pressed and released. Note that if you have in your code something like:
if (p1_trig == 1)
{
//do something
}
then you'll do that multiple times per button press, because each press is so long that the code loops through several times. This may or may not be a problem for your situation (but it's easily solvable).

Now, the joysticks are similar. You read those in from their variables. They'll have a value of 0-255, with 127 indicating the dead center, 255 the extreme positive end, and 0 the extreme negative end.

All of these variables are updated very often (as high as 40 times a second, i believe), so you don't have to worry about that!


So, once you get your inputs, you need to be able to output them. This is also pretty easy. Your motors will be plugged into one of the PWM ports on the RC. For the sake of argument, we'll assume they're in port 01. Conveniently, that maps in the code to a variable called pwm_01. All you have to do is set that variable to whatever speed you want (or even to the joystick input!) It follows the same conventions as the joysticks, with 127 being stop, 0 being full speed reverse, and 255 being full speed forward.

If you're using KoP materials for your pneumatics, then your piston should be connected through one of the relay ports. Again, i'll assume it's port 1. This port actually has two variables associated with it - relay1_fwd and relay1_rev. The tricky thing with working with pneumatics is knowing how the solenoids work. Basically, You can apply power to two sides of it. When you provide power to one side, it opens up the valve in that direction, letting the air flow through that port, and closing the other. provide power to the other side, and the same thing happens over there. provide power to both sides, and you can't be sure what will happen - they'll both try to open their side and close the other. Provide power to neither side, and you have the same situation where you don't know what will happen.

For that reason, whenever you're working with pneumatics in this fashion, you always want to set the variables together as a pair. To move the piston in one direction, you'll set relay1_fwd = 1 and relay1_rev = 0. For the other direction, relay1_fwd = 0 and relay1_rev = 1.

As for the motor up and down, it depends on how it's wired up - those can be wired to either victors or spikes. Luckily for you, those are both controlled the same way as I described above.

So, some very simple code to do what you described (but maybe not exactly what you want, your questions were a little generic) might be:
Code:
pwm_01 = p1_x;
pwm_02=p1_y;
//control the piston
if (p1_trig == 1)
{
    relay1_fwd = 1;
    relay1_rev = 0;
}
else
{
    relay1_fwd = 0;
    relay1_rev = 1;
}
//control the motor
//I'm leaving this portion up to you to figure out :)
  #7   Spotlight this post!  
Unread 12-01-2008, 23:44
Neurovirus Neurovirus is offline
Registered User
FRC #0224
 
Join Date: Jan 2008
Location: Piscataway
Posts: 13
Neurovirus is an unknown quantity at this point
Re: Operator Control Help

Thanks Everyone for the help!

First time using these forums, and it has been the most helpful.

Thanks again!
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
pic: Portable Operator Control falconmaster Extra Discussion 1 15-02-2007 13:36
[OCCRA]: Size limit of Operator Control Station Alex Golec OCCRA Q&A 1 11-10-2005 05:33
Operator interface/Driver Control board sgsdragons Robot Showcase 4 07-03-2005 08:58
Operator Interface Control Panel wmurphy Control System 4 30-01-2005 23:57
Operator Interface, Need help. Jordan A. Technical Discussion 13 22-01-2002 16:57


All times are GMT -5. The time now is 18:42.

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