Go to Post It seems ironic to me that a robotics competition would come down to human error, which is precisely what the field of robotics attempts to prevent. - David8696 [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 14-02-2008, 08:50
programmr's Avatar
programmr programmr is offline
Registered User
AKA: Face
FRC #0522
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Staten Island, NY
Posts: 83
programmr is a jewel in the roughprogrammr is a jewel in the roughprogrammr is a jewel in the rough
Send a message via AIM to programmr
Servo Programming Again.....

i have a question about servos used for shifting...... This si the code i came up with and i need some verification.... will the servo stay in the position if the top switch is hit will it stay at 255? what if the trigger is hit, how can i make it stay at either 255 or 0? DO ALL I NEED TO DO IS CHANGE THE FIRST 2 127'S TO 255 AND THE SECOND 127'S TO 0? I want the servos to stay in the position relating to what button was pushed?

if ((p1_sw_top == 1)) // If Top Button on Joystick 1 is hit
{ // Make the two servos.......
pwm15 = 255;
pwm16 = 255;
}
else
{
pwm15 = 127;
pwm16 = 127;
}
if ((p1_sw_trig == 1)) // If Trigger is pushed on Joystick 1
{ // Make the two servos.......
pwm15 = 0;
pwm16 = 0;
}
else
{
pwm15 = 127;
pwm16 = 127;
}

Any help would be appreciated. Thank You
  #2   Spotlight this post!  
Unread 14-02-2008, 09:31
Rapt0r9's Avatar
Rapt0r9 Rapt0r9 is offline
Mentor
AKA: Tyler
FRC #0747 (Flight Crew)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2005
Location: Middlesex, NJ
Posts: 59
Rapt0r9 will become famous soon enoughRapt0r9 will become famous soon enough
Re: Servo Programming Again.....

I can see a potential run time error in your code. You want to set up one conditional block which handles everything instead of the two. With the two blocks, the output of the first block will always be overwritten by the second.

Something like

if (Trigger == 1)
pwm15 = 255
else if (Top == 1)
pwm15 = 0
else
pwm15 = 127

Thats really pseudo code, so you need to replace the variables with your own. The logics behind it is what is important.

To answer your question, no. The servo will not remain in that position if the the trigger is released. You need to set up a variable that is set to a value when the trigger is pressed and that variable will then be checked in the conditionals.

Two years ago, I set up an auto targeting system that was engaged by the trigger on the joystick. We set a variable to a number then multiplied it by -1 if the trigger was depressed. The conditional would then check to see if the variable was greater or less than 0 which would determine the status of the system (On or Off). Similarly, you could try something for your problem. Feel free to PM for more info.
__________________
Mentor
BS Information Technology - NJIT (2009 - )
Team 869 (2004 - 2008, 2011 -), Team 1811 (2010), Team 869 (2009), Team 613 (2009 - 2010)
"Nothing in this life worth having comes easy."
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
Programming in Python and Explaination of Programming roboxking Programming 22 07-01-2008 16:08
HS-322D servo programming question JimHull Programming 12 10-02-2007 15:14
programming motors with programming kit BorisTheBlade FIRST Tech Challenge 4 01-11-2005 19:03
Servo behavior question / advanced servo/PIC programming question DanL Electrical 12 18-10-2005 18:33
Servo MASherry General Forum 6 04-10-2004 22:46


All times are GMT -5. The time now is 09:38.

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