Go to Post I'm frustrated by the world's reluctance to bend over backwards for FIRST. - Madison [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 17-03-2004, 17:48
AsimC AsimC is offline
Registered User
#0871 (West Islip Robotechs)
 
Join Date: Feb 2003
Location: West Islip, NY
Posts: 51
AsimC will become famous soon enough
Help! Programming question with triggers

its the day before competition and i really need help on this. Our team decided to make a trigger box for our robot and one trigger controls 2 motors. What i what it to do is, when i hold the trigger forward, the motors go forward, and when i let go the motor stops. For some reason i cant get it to work. What happens is, i hold the trigger forward and the motors continuely move even if i let go. Ive tried IF loops as well as FOR loops. Any suggestions? (as quickly as possible )
__________________
WEST ISLIP ROBOTECHS - Team 871

-2004 SBPLI REGIONAL CHAIRMANS AWARD WINNERS!
-2003 SBPLI Regional Finalists with 545 and 566
-2002 SBPLI Rookie All-Star
-Former Student Team Leader and Programming Head
  #2   Spotlight this post!  
Unread 17-03-2004, 18:21
bstempi bstempi is offline
Captain
#0708 (Hardwired Hatters)
Team Role: Student
 
Join Date: Feb 2004
Location: Horsham, Pa
Posts: 23
bstempi is an unknown quantity at this point
Send a message via AIM to bstempi
Re: Help! Programming question with triggers

how do you have it wired up? From what you posted, it sounds like some sort of toggle switch you're using. Do you know what variables that coresponds to in the code?
  #3   Spotlight this post!  
Unread 17-03-2004, 18:27
JoshJ JoshJ is offline
Registered User
#0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Salem County
Posts: 44
JoshJ is on a distinguished road
Send a message via AIM to JoshJ
Re: Help! Programming question with triggers

See if u can post a copy of your code. I would stay away from FOR loops, all u should need to do is set the motors to something when ur trigger is forward, and set them to 127 when it is not. Also, see if you have any other code that assigns values to these motors.
  #4   Spotlight this post!  
Unread 17-03-2004, 18:27
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: Help! Programming question with triggers

you dont need an if statement

just something like

relay_fwd01 = p1_trig01; in your code

when the switch is on the relay is on, when its off, the relay goes off
  #5   Spotlight this post!  
Unread 17-03-2004, 18:47
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Help! Programming question with triggers

Quote:
Originally Posted by KenWittlief
you dont need an if statement

just something like

relay_fwd01 = p1_trig01; in your code

when the switch is on the relay is on, when its off, the relay goes off
If you have a victor, try this:
Code:
pwm01=p1_sw_trig*127+127;
  #6   Spotlight this post!  
Unread 17-03-2004, 18:48
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Help! Programming question with triggers

If they are on PWMs, do something like:
Code:
if(switch == 1){
    pwm01 = pwm02 = 254;
}
else{
    pwm01 = pwm02 = 127;
}
Where pwm is the motor(s) and switch is the switch.
__________________

  #7   Spotlight this post!  
Unread 17-03-2004, 19:26
Xufer's Avatar
Xufer Xufer is offline
8 Seasons and as stable as ever
AKA: Working, 2/4 degrees complete still schooling...
FRC #1740 (The Cyber Colonels)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Waterford, CT
Posts: 231
Xufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to behold
Send a message via AIM to Xufer Send a message via MSN to Xufer Send a message via Yahoo to Xufer
Re: Help! Programming question with triggers

i did mine like this
Code:
pwm03 = 127;  /*goal claw up and down*/ 
if (p2_sw_top)
{pwm03 = 195;}  /*half speed down*/
else if (p2_sw_trig)
{pwm03 = 59;} /*half speed up*/
__________________


If saftey is first and i put FIRST ahead of everything, then i must be the safest guy in the world.

Team 521 Alumni -- Team 1740 Mentor-- Go Go 1740!
Sometimes I think I've been doing this too long and other times I think I haven't done this enough... but all the times I'm sure I'm crazy
Photonics, It's Your Future
  #8   Spotlight this post!  
Unread 17-03-2004, 20:21
AsimC AsimC is offline
Registered User
#0871 (West Islip Robotechs)
 
Join Date: Feb 2003
Location: West Islip, NY
Posts: 51
AsimC will become famous soon enough
Re: Help! Programming question with triggers

hmm this is how i originally did it...but it doesnt work. What happens is when i click the trigger, its constantly going forward even when i let go.

Code:
if (p3_sw_trig==1)
{
   pwm07=175;
   pwm08=175;
}
if (p3_sw_top==1)
{
   pwm07=90;
   pwm08=90;
}
__________________
WEST ISLIP ROBOTECHS - Team 871

-2004 SBPLI REGIONAL CHAIRMANS AWARD WINNERS!
-2003 SBPLI Regional Finalists with 545 and 566
-2002 SBPLI Rookie All-Star
-Former Student Team Leader and Programming Head
  #9   Spotlight this post!  
Unread 17-03-2004, 20:26
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Help! Programming question with triggers

Code:
if (p3_sw_trig==1)
{
   pwm07=175;
   pwm08=175;
}
else if (p3_sw_top==1)
{
   pwm07=90;
   pwm08=90;
}
else
{
   pwm07=127;
   pwm08=127;
}
try this... just beware if you push both the trigger and top button at the same time, it'll still go forward.
  #10   Spotlight this post!  
Unread 17-03-2004, 20:35
AsimC AsimC is offline
Registered User
#0871 (West Islip Robotechs)
 
Join Date: Feb 2003
Location: West Islip, NY
Posts: 51
AsimC will become famous soon enough
Re: Help! Programming question with triggers

i forgot to say...it is a self centering toggle switch. Toggle forward is wired up to "trigger", and toggle back is wired up to "top" in code.

Anyways... Slimbojones when i was debugging my code, i tried something like that... and it didnt work. What happens is the 1 from p3_sw_trig is held in the code, so it never goes back to 0 and that means itll never go to neutral.
__________________
WEST ISLIP ROBOTECHS - Team 871

-2004 SBPLI REGIONAL CHAIRMANS AWARD WINNERS!
-2003 SBPLI Regional Finalists with 545 and 566
-2002 SBPLI Rookie All-Star
-Former Student Team Leader and Programming Head
  #11   Spotlight this post!  
Unread 17-03-2004, 20:44
WebWader125
 
Posts: n/a
Re: Help! Programming question with triggers

Quote:
Originally Posted by AsimC
Anyways... Slimbojones when i was debugging my code, i tried something like that... and it didnt work. What happens is the 1 from p3_sw_trig is held in the code, so it never goes back to 0 and that means itll never go to neutral.
Did you try something like that, or did you try exactly what Slimbo posted? If you had two IF's but only one ELSE, it would probably behave how you've described.

One question I have: What happens when you push the toggle switch down? Do your motors actually run in reverse then? Or is forward the only direction that's working at all for you?
  #12   Spotlight this post!  
Unread 17-03-2004, 20:44
doy's Avatar
doy doy is offline
#1208 Ex-Lead Programmer
AKA: Jesse Luehrs
#1208 (The Super Critical Axe Men)
Team Role: Alumni
 
Join Date: Jan 2004
Location: O'Fallon, IL
Posts: 27
doy is on a distinguished road
Send a message via AIM to doy
Re: Help! Programming question with triggers

Quote:
Originally Posted by AsimC
i forgot to say...it is a self centering toggle switch. Toggle forward is wired up to "trigger", and toggle back is wired up to "top" in code.

Anyways... Slimbojones when i was debugging my code, i tried something like that... and it didnt work. What happens is the 1 from p3_sw_trig is held in the code, so it never goes back to 0 and that means itll never go to neutral.
if at the rest state of the switch, both outputs are 0, then his code should work... if not, then i dont think the switch will work for what you want it to do, as there would be no way to tell whether or not the switch was being pushed in a direction or at rest.
  #13   Spotlight this post!  
Unread 17-03-2004, 20:50
AsimC AsimC is offline
Registered User
#0871 (West Islip Robotechs)
 
Join Date: Feb 2003
Location: West Islip, NY
Posts: 51
AsimC will become famous soon enough
Re: Help! Programming question with triggers

when i pull the toggle switch back...the motors do run in reverse...but again they do not stop even when i let go.
__________________
WEST ISLIP ROBOTECHS - Team 871

-2004 SBPLI REGIONAL CHAIRMANS AWARD WINNERS!
-2003 SBPLI Regional Finalists with 545 and 566
-2002 SBPLI Rookie All-Star
-Former Student Team Leader and Programming Head
  #14   Spotlight this post!  
Unread 17-03-2004, 21:09
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Help! Programming question with triggers

Quote:
Originally Posted by AsimC
when i pull the toggle switch back...the motors do run in reverse...but again they do not stop even when i let go.
Do your motors run at startup?
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
  #15   Spotlight this post!  
Unread 17-03-2004, 21:17
Greg's Avatar
Greg Greg is offline
Registered User
FRC #1075 (Sinclair Sprockets)
Team Role: College Student
 
Join Date: Nov 2002
Rookie Year: 2003
Location: Whitby, Ontario, Canada
Posts: 108
Greg is on a distinguished road
Send a message via ICQ to Greg Send a message via MSN to Greg
Re: Help! Programming question with triggers

Quote:
Originally Posted by AsimC
i forgot to say...it is a self centering toggle switch. Toggle forward is wired up to "trigger", and toggle back is wired up to "top" in code.

Anyways... Slimbojones when i was debugging my code, i tried something like that... and it didnt work. What happens is the 1 from p3_sw_trig is held in the code, so it never goes back to 0 and that means itll never go to neutral.
Then its your switch. Just because it returns to center does not mean the switch is opened

Last edited by Greg : 17-03-2004 at 21:19.
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
Digital In Question Tom Bottiglieri Control System 5 02-03-2004 17:09
Urgent!! (programming question) anupalsingh Programming 6 25-02-2004 10:53
MIM's question of the day on programming. Gene F Programming 3 24-02-2004 16:32
C Programming Question tophq Programming 7 16-02-2004 12:56
Programming question archiver 2001 6 23-06-2002 22:57


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

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