Go to Post You can take the man out of FIRST, but you can't take FIRST out of the man. - George1902 [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 06-02-2008, 19:11
sweetie_pi sweetie_pi is offline
Registered User
AKA: Nica
FRC #2189
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: woodland, CA
Posts: 5
sweetie_pi is an unknown quantity at this point
I am going crazy

My team wants me and my other programming buddy to program the arm as a digital so that it moves up and down when you push a button and release. How the heck do I do that????They try telling me to look it up but so far I have not found it.
__________________
hi
I am a neomaxizoondweebi and dang proud of it
  #2   Spotlight this post!  
Unread 06-02-2008, 19:16
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: I am going crazy

I'm not sure I understand what your team wants you to do... Do you want to make two buttons, one that moves the arm up, and the other to move it down, or are looking for one button to do both...? What will releasing the button do, exactly? Please explain so that everyone can help better.
  #3   Spotlight this post!  
Unread 06-02-2008, 19:22
pheadxdll pheadxdll is offline
Registered User
AKA: Alex
FRC #1225 (Amperage Robotics)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: North Carolina
Posts: 168
pheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud ofpheadxdll has much to be proud of
Re: I am going crazy

Are you programming in MPLAB or easyC?
__________________
Amperage Robotics Team 1225
Site under-going revamp. :/
  #4   Spotlight this post!  
Unread 06-02-2008, 19:37
GGCO's Avatar
GGCO GGCO is offline
Registered User
AKA: Grant
FRC #3357
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2004
Location: Michigan
Posts: 406
GGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to beholdGGCO is a splendid one to behold
Send a message via AIM to GGCO
Re: I am going crazy

Um. Don't you need sensors or something? Maybe a limit switch.
__________________
"Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein
The FIRST Alliance
COMETS Robotics
Website

  #5   Spotlight this post!  
Unread 06-02-2008, 19:57
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,171
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: I am going crazy

Limit switches are the preferred way to do this. Using simple state machine code is a good way to code the behavior. Check out this simple code from last year, the RunArm function is called each time through the slow loop.

...

typedef enum
{
ARM_UNKNOWN,
ARM_EXTENDING,
ARM_RETRACTING,
ARM_EXTENDED,
ARM_RETRACTED,
ARM_LAST
} ARM_STATES;

typedef struct
{
CLAW_STATES eClawState;
ARM_STATES eArmState;
MAST_STATES eMastState;

} ARM_DATA;

#define ARM_MOTOR_EXTEND_DRIVE 192
#define ARM_MOTOR_RETRACT_DRIVE 64
#define ARM_MOTOR_OFF_DRIVE 128

#define RHS_ARMEXTEND_IN p1_sw_top
#define RHS_ARMRETRACT_IN p1_sw_top

#define RHS_ARM_MOTOR pwm04

#define RHS_ARM_EXTEND_LIMIT rc_dig_in06
#define RHS_ARM_RETRACT_LIMIT rc_dig_in07

....

static void RunArm(ARM_DATA *pData)
{
// if we are in an out of range state

if (pData->eArmState >= ARM_LAST)
{
pData->eArmState = ARM_UNKNOWN;
}

switch (pData->eArmState)
{
case ARM_UNKNOWN:
// always extend the arm if in an unknown state

pData->eArmState = ARM_EXTENDING;
break;

case ARM_EXTENDING:
if (RHS_ARM_EXTEND_LIMIT)
{
// still opening

RHS_ARM_MOTOR = ARM_MOTOR_EXTEND_DRIVE;
}
else
{
// we are open

pData->eArmState = ARM_EXTENDED;
}
break;

case ARM_RETRACTING:
if (RHS_ARM_EXTEND_LIMIT)
{
// still closing

RHS_ARM_MOTOR = ARM_MOTOR_RETRACT_DRIVE;
}
else
{
// we are closed

pData->eArmState = ARM_RETRACTED;
}
break;

case ARM_EXTENDED:
RHS_ARM_MOTOR = ARM_MOTOR_OFF_DRIVE;

if (RHS_ARMRETRACT_IN)
{
// follow command to close

pData->eArmState = ARM_RETRACTING;
}
break;

case ARM_RETRACTED:
RHS_ARM_MOTOR = ARM_MOTOR_OFF_DRIVE;

if (RHS_ARMEXTEND_IN)
{
// follow command to open

pData->eArmState = ARM_EXTENDING;
}
break;
break;

default:
RHS_ARM_MOTOR = ARM_MOTOR_OFF_DRIVE;
pData->eArmState = ARM_UNKNOWN;
break;
}
}

HTH

Last edited by wireties : 06-02-2008 at 20:00.
  #6   Spotlight this post!  
Unread 06-02-2008, 20:12
Laaba 80 Laaba 80 is offline
Registered User
AKA: Joey
FRC #1714 (MORE Robotics)
Team Role: Alumni
 
Join Date: Dec 2007
Rookie Year: 2001
Location: San Jose, CA
Posts: 495
Laaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond repute
Re: I am going crazy

Wow, yours seems kind of confusing. Another way of doing it which in my opinion is easier is

unsigned char motorup = TRUE;
unsigned char motordown = TRUE;

if (rc_dig_in01 == 1) //If the limit switch at the top is pressed
{
motorup = FALSE;
}
else
{
motorup = TRUE;
}
if (rc_dig_in02 == 1) //Limit switch at bottom
{
motordown = FALSE;
}
else
{
motordown = TRUE;
}
if (p1_sw_trig == TRUE && motorup == TRUE)
{
pwm01 = 200; //Assuming that a # higher that 127 goes up
}
if (p1_sw_top == TRUE && motordown == TRUE)
{
pwm01 = 50; //Assuming lower # goes down
}
else
{
pwm01 = 127;
}

This is how I like to do it. If you think another way is easier go for that. it is all about how you feel comfortable using code. Also I just made up the values and pwm numbers use whatever your motors and sensors are plugged into. Also im sorry about the font. I pressed a button and it changed the font and im not sure how to put it back to normal
Joey
__________________
Driving Record - 75-43-8
Coaching Record - 92-65
  #7   Spotlight this post!  
Unread 06-02-2008, 21:56
neutrino15's Avatar
neutrino15 neutrino15 is offline
plɹoʍ ollǝɥ
AKA: Jordan Perr
FRC #0694 (Stuypulse)
 
Join Date: Feb 2007
Rookie Year: 2007
Location: New York City
Posts: 162
neutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really niceneutrino15 is just really nice
Re: I am going crazy

Well, it depends on how your robot is designed, and what your program already has in it.
The button pushing part is easy, just look in dashboard to find the button you want. Something like the following will toggle up/down on press. You don't need to hold the button with this routine either:

Code:
//at the top:
#define BUTTON p3_sw_trig

//in the loop:
static char armMove;

if(BUTTON & armMove==0){
     if(the arm is down)
         armMove = 1;
     else
         armMove = 2;
}

if(armMove){//this uses the fact that both 1 and 2 will be true, while 0 will be false.
    if(moveArm(armMove))
        armMove = 0;
}

then, down the page (or in another file), you need to have a function that actually moves the arm, and returns true if the arm is done moving.

Code:
int moveArm(char way){
    char finished
    if(way == 1){
        //move the arm up, set pwms.
        //you probably want to use a PID loop.
        //return 1 if the arm is there already, and set the pwm to 127.
    } else {
        //move the arm down, set pwms.
        //you probably want to use a PID loop.
        //return 1 if the arm is there already, and set the pwm to 127.
    }

   return 0;

Thats the way I would attempt to do it. Depending on your bot, you may have to use some sort of a PID loop to get the arm to the correct position. If you use limit switches instead of a POT, you could probably do it with just a P loop.

Last edited by neutrino15 : 06-02-2008 at 22:01.
  #8   Spotlight this post!  
Unread 07-02-2008, 10:09
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,171
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: I am going crazy

"Wow, yours seems kind of confusing"

Our algorithm is a state machine. If we drew each algorithm on a white board, ours would look much simpler than yours. And ours is more efficient, each time it is called only the code in one case is executed. Yours seems just as complex. You have almost as many 'if' clauses as we have cases. I reckon the use of macros and a switch statement would make it look more complex to a less experienced programmer. But our team has a number of software mentors to help the students.

HTH

Last edited by wireties : 07-02-2008 at 13:19.
  #9   Spotlight this post!  
Unread 07-02-2008, 10:18
billbo911's Avatar
billbo911 billbo911 is online now
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,384
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: I am going crazy

We are doing exactly as you describe. It takes to simple functions, call the first one then call the second. The first one looks at the button inputs on the console, the second one sends the command to the lift function.
Code:
int Get_Oi_Switch (void)
{
	if (p1_sw_top == 1)
	{
		liftcmd = LOAD;
	}
	if (p1_sw_trig == 1)
	{
		liftcmd = HURDLE;
	}
	if (p1_sw_aux1 == 1)
	{
		liftcmd = PICK;
	}
	if (p1_sw_aux2 == 1)
	{
		liftcmd = PLACE;
	}
	return liftcmd;	
}
Code:
int Set_Lift_Height (int pos_demand)
{
  int liftdrv;
  int liftvel;
	liftpos = ((int)Get_Encoder_5_Count());
	liftposerr = (pos_demand - liftpos);
	liftvel = (liftpos - lastliftpos);
	lastliftpos = liftpos;  // Save position for next loop
	liftdrv = ((liftposerr * LIFT_KP) + (liftvel * LIFT_KD));  // Actual PD equation
	if (liftdrv > LIFT_MAX_V)
	{
		liftdrv = LIFT_MAX_V; // Limit lift speed to defined range
	}
	if (liftdrv < -LIFT_MAX_V)
	{
		liftdrv = -LIFT_MAX_V;
	}
	
	return (liftdrv + 127);
}
As you can see, there are some definitions that are set up outside of this file that define the individual heights and velocities. Also included in the Set_Lift_Height function is a PD loop. We are not using the integral function of a PID loop.


EDIT: If it helps, feel free to use this code. Just make sure you understand it and modify it to match your system. All I ask is that you let us know how it works out for you.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist

Last edited by billbo911 : 07-02-2008 at 15:29.
  #10   Spotlight this post!  
Unread 07-02-2008, 18:30
sweetie_pi sweetie_pi is offline
Registered User
AKA: Nica
FRC #2189
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: woodland, CA
Posts: 5
sweetie_pi is an unknown quantity at this point
Re: I am going crazy

WOW!!! thinks for all the help and sorry I was not to specific with the function but I think my team member and I can put something together now. So Thanks a bunch.
__________________
hi
I am a neomaxizoondweebi and dang proud of it
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
My error derivative is going crazy Nathans Programming 3 19-01-2008 17:56
crazy game Mike Ciance Fantasy FIRST 22 25-05-2004 11:37
Big for Joe! Going....Going..... archiver 2001 9 23-06-2002 23:29
crazy stuff chris144 Chit-Chat 19 08-04-2002 20:13


All times are GMT -5. The time now is 01:08.

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