Go to Post Go with what you know will work, and try a little less if you are feeling brave. That is my rule of thumb. - sanddrag [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-2006, 21:46
DanDon's Avatar
DanDon DanDon is offline
ohhh MY god
AKA: Dan Hoizner
FRC #0375 (The Robotic Plague)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Staten Island, NY
Posts: 1,432
DanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond reputeDanDon has a reputation beyond repute
Send a message via ICQ to DanDon Send a message via AIM to DanDon Send a message via MSN to DanDon
Re: A few simple programming questions;

Code:
  if(p3_sw_top == 1)
   { 
   pwm09 = 127;
   pwm10 = 127;
   }
   else
   {
   pwm09 = 254;
   pwm10 = 254;
   }
This might be your intention, but with this code, the pwm's will only be at 127 when the button is held down, when the button is not held down, they will be at 254.


Quote:
2. We are using spikes this year, and I am not sure how to program them, I'm sure I have to program it somehow but I am at a lost of how to.
With spikes, you would basically program them using two variables. If your spike was hooked up to relay1, then your two variables would be:
relay1_fwd and relay1_rev. If you wanted to fire the spike in one direction, you would set:

Code:
relay1_fwd=1;
relay1_rev=0;
The other direction would be:

Quote:
relay1_fwd=0;
relay1_rev=1;
And neutral would be:
Code:
relay1_fwd = relay1_rev = 0;
Quote:
else (p3_sw_trig == 0);
{
pwm09 = 254;
pwm10 = 254;
}
If you were to have the condition after the else, despite the fact that it's not needed, since the button can only be at 1 or 0, and if it isn't at 1, then a value of 0 is implied, the statement would have to be an

Code:
else if(p3_sw_trig==0)
You also should not have a semi-colon right after an if or else statement.

Quote:
think you only need one = when referring to the value of the button, not ==.
This is not true. The '==' operator is the equality operator in C, '=' is the assignment operator, which would set the variable equal to what you are comparing it with, and the condition would always be true.

Regarding the syntax error, from a brief glance at the code, it looks like you might be missing a brace or two. Try adding them one by one to the end of your code, and see if that helps.

Hope this helps,
__________________
  #2   Spotlight this post!  
Unread 14-02-2006, 22:15
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: A few simple programming questions;

in the printf statement put in the end ...%d\r",

You can also change the stuff in the quotes to print what every you want.
  #3   Spotlight this post!  
Unread 14-02-2006, 22:55
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: A few simple programming questions;

Quote:
and
is that a line of code or only a comment in your post?

Im almost certain there is no IF AND ELSE statement ?
  #4   Spotlight this post!  
Unread 15-02-2006, 00:13
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: A few simple programming questions;

Quote:
Originally Posted by KenWittlief
is that a line of code or only a comment in your post?

Im almost certain there is no IF AND ELSE statement ?
You are correct. A search shows that syntax was not used in his code.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #5   Spotlight this post!  
Unread 15-02-2006, 09:45
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,906
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: A few simple programming questions;

I see you have an unmatched bracket here that will give you the syntax error.
Code:
if(p3_sw_trig)
	 {
My main suggestion would be to change how you are commenting out lines and blocks of code.
Switch over to the // form rather than use the /* */ form.
Your blocks are ending in random places.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-02-2006 at 09:52.
  #6   Spotlight this post!  
Unread 15-02-2006, 10:50
aaeamdar's Avatar
aaeamdar aaeamdar is offline
Post-A-Holic
AKA: Paul Dennis
FRC #1719 (The Umbrella Corp)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baltimore, MD
Posts: 231
aaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant futureaaeamdar has a brilliant future
Re: A few simple programming questions;

Quote:
Originally Posted by Mark McLeod
I see you have an unmatched bracket here that will give you the syntax error.
Code:
if(p3_sw_trig)
	 {
My main suggestion would be to change how you are commenting out lines and blocks of code.
Switch over to the // form rather than use the /* */ form.
Your blocks are ending in random places.
You're absolutely right, Mark. The problem is that the code is poorly written. IE, the original code that they gave us. Whoever writes the code apparently hasn't come to the realization that C++ style comments (//like this) are available in C now. It used to be that /*this*/ was all there was. However, it's bad coding practice to write one liners like this:
Code:
complicatedMethod(); /*Some comment here*/
Because if you want to block comment that line and a bunch of other like it, you will not be able to easily because the */ at the end will also end yours! The easiest way I have found around this without bothering to change the code (i.e. change /**/ to //) is to use this:

Code:
#if 0
complicatedMethod1(); /*Some comment here*/
complicatedMethod2(); /*Some comment here*/
complicatedMethod3(); /*Some comment here*/
#endif
Alright, that's all for now folks. I think cruella wants to make a coat out of my posts.

Paul Dennis
  #7   Spotlight this post!  
Unread 15-02-2006, 11:49
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,906
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: A few simple programming questions;

Quote:
Originally Posted by KenWittlief
Im almost certain there is no IF AND ELSE statement ?
I agree, it should be no IF, AND, or BUT statements.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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
How To Ask Questions the Smart Way Brandon Martus General Forum 8 27-03-2013 15:52
Programming laptops [527]phil Programming 24 22-08-2005 12:28
#1 The Journey of a FIRST Graduate: Questions Ken Leung General Forum 12 27-07-2005 18:24
Suggestion for Delphi Programming Posts Chris Hibner CD Forum Support 1 27-07-2005 10:02
Can You help us??? (programming questions) HuskieRobotics Programming 1 24-02-2004 21:19


All times are GMT -5. The time now is 02:12.

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