Go to Post Many people read ChiefDelphi, not just members of FRC teams. - JaneYoung [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
  #16   Spotlight this post!  
Unread 17-03-2004, 21:18
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

startup meaning when i turn the robot on?.... nope they dont move
__________________
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
  #17   Spotlight this post!  
Unread 17-03-2004, 21:22
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

if you push it in reverse and let go does it keep going in reverse? or go forward?

[EDIT] I also think it is a switch wiring problem [/EDIT]
__________________
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"

Last edited by The Lucas : 17-03-2004 at 21:24.
  #18   Spotlight this post!  
Unread 17-03-2004, 21:28
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

the thing is that....the SAME EXACT thing happens when i hooked up a joystick to it...so i doubt its an electrical problem.

*EDIT - using the triggers from a joystick
__________________
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

Last edited by AsimC : 17-03-2004 at 21:31.
  #19   Spotlight this post!  
Unread 17-03-2004, 21:33
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

Could you post the file then? The algorithms on this thread are good so the problem is somewhere else. I am sure with all the CD programmers someone will find it real quick.
__________________
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"
  #20   Spotlight this post!  
Unread 17-03-2004, 22:16
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

Quote:
Originally Posted by AsimC
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;
}

the reason why your motors keep running is because there is no path in your code where you tell them to be = 127 and stop running

the way your code is written if neither switch is closed then the pwm outputs will still be what they were the last time the loop ran, and the time before that... your code leaves them at 175 or 90.

you could put

pwm07=127;
pwm08=127;

above your if statement - have them = 127 by default, then if either switch is closed they will be something else instead

this is a common mistake

Last edited by KenWittlief : 17-03-2004 at 22:19.
  #21   Spotlight this post!  
Unread 17-03-2004, 22:48
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

try this its the code i use to run my claw modified for your application
Code:
pwm07=127;
pwm08=127;

if (p3_sw_top)
{ pwm07 = 90;
   pwm08 = 90; }

else if (p3_sw_trig)
{ pwm07 = 175;
   pwm08 = 175;}
__________________


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
  #22   Spotlight this post!  
Unread 17-03-2004, 23:00
adventrx327's Avatar
adventrx327 adventrx327 is offline
Registered User
no team
 
Join Date: Mar 2004
Rookie Year: 2003
Location: ""
Posts: 19
adventrx327 is on a distinguished road
Send a message via AIM to adventrx327
Re: Help! Programming question with triggers

Here is how i would write it if i were you guys....

if ( 0 != p3_sw_trig)
{
pwm07 = 175;
pwm08 = 175;
}
else if (0 != p3_sw_top)
{
pwm07 = 90;
pwm08 = 90;
}
else
{ pwm07 = 127;
pwm08 = 127;
}


When writing my code i didnt do p3_sw_top == 1, my mentor sez its better to do 0 !=, and i have no idea why.

try this, if it works yay! if not sorry i couldnt be of more help
  #23   Spotlight this post!  
Unread 17-03-2004, 23:07
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,602
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Help! Programming question with triggers

Quote:
Originally Posted by adventrx327
When writing my code i didnt do p3_sw_top == 1, my mentor sez its better to do 0 !=, and i have no idea why.
Here is the reason: http://www.chiefdelphi.com/forums/sh...34&postcount=3 However, in the future don't be afraid to ask your mentor to explain things like that you don't understand.
  #24   Spotlight this post!  
Unread 17-03-2004, 23:20
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Re: Help! Programming question with triggers

Code:
pwm07 = pwm08 = 127 + ((p3_sw_trig - p3_sw_top) * 40);
One line. I found it very useful this year. You can changew the numher at the end (40) to whatever scale you want. trig will make it go forward, top will make it go back, and either both or none will make it just sit there.

-Kesich
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year
  #25   Spotlight this post!  
Unread 18-03-2004, 00:30
adventrx327's Avatar
adventrx327 adventrx327 is offline
Registered User
no team
 
Join Date: Mar 2004
Rookie Year: 2003
Location: ""
Posts: 19
adventrx327 is on a distinguished road
Send a message via AIM to adventrx327
Re: Help! Programming question with triggers

Oh my god!

So concise, so effective, so 1337!

I salute you Anthony, you truly embody the spirit of first.
  #26   Spotlight this post!  
Unread 18-03-2004, 07:01
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

it is concise in C - but unless the CPU has a HW multiplyer then multiplyer that one line of code might compile into something that will take hundreds of machine cycles to execute in assembler

when you only need an '=' getting clever to make your C look concise is usually a big mistake.
  #27   Spotlight this post!  
Unread 18-03-2004, 11:00
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 KenWittlief
it is concise in C - but unless the CPU has a HW multiplyer then multiplyer that one line of code might compile into something that will take hundreds of machine cycles to execute in assembler

when you only need an '=' getting clever to make your C look concise is usually a big mistake.
Actually both routines, Anthony Kesich's one-liner and Xufer's selection structure, take exactly 22 bytes of program space, just check the list file (FrcCode.lst) after compiling both. Xufers routine was the most program space efficient of the selection structures I saw because it involved the least branching (i.e. no else to set neutral which only takes 2 bytes). Anthony’s routine could probably be optimized in assembler since only the sign bit and least significant bit of one of the factors is relevant (I don't program in assembler so I am not sure). One-liners are much better for relays because it is simply addition no multiplication.

Processor speed is a different story and depends on the processor architecture.
__________________
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"

Last edited by The Lucas : 18-03-2004 at 11:10.
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 13:16.

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