Go to Post "Why yes, actually I AM a rocket scientist" - Gary Dillard [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 09-02-2008, 13:39
Lilor Lilor is offline
Registered User
FRC #2595
 
Join Date: Feb 2008
Location: Los Angeles, Ca
Posts: 5
Lilor is an unknown quantity at this point
define irswitch?

how do you define the ir board commands in the program.

this is what we have but we don't know if it is right

#define IRswitch1
#define IRswitch2
#define IRswitch3
#define IRswitch4

or can someone post how they defined the IRswitch?
  #2   Spotlight this post!  
Unread 09-02-2008, 13:44
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: define irswitch?

You need to use #define to assign a value to the IRswtich things. They are only placeholders, the compiler will go through and replace all "IRswitch1" with whatever you put after it. So it would like:

Code:
#define IRswitch1 rc_dig_in01
#define IRswitch2 rc_dig_in02
#define IRswitch3 rc_dig_in03
#define IRswitch4 rc_dig_in04
Assuming you used those four for your IR wiring. And then to use them:

Code:
if (!IRswitch1)    //If the IR has been pressed
auto_routine_1();         //Do whatever when switch is down
}
Just as an example, here's how we defined it:

Code:
// IR Inputs
#define IR_DIG_1 						rc_dig_in07
#define IR_DIG_2 						rc_dig_in08
#define IR_DIG_3 						rc_dig_in09
#define IR_DIG_4 						rc_dig_in10

// IR Values
#define IR_DISCONNECTED				(IR_DIG_1 && IR_DIG_2 && IR_DIG_3 && IR_DIG_4)
#define IR_1 						(IR_DIG_1 && !IR_DISCONNECTED)
#define IR_2 						(IR_DIG_2 && !IR_DISCONNECTED)
#define IR_3 						(IR_DIG_3 && !IR_DISCONNECTED)
#define IR_4 						(IR_DIG_4 && !IR_DISCONNECTED)
That way you won't get confused when the IR board is out.
  #3   Spotlight this post!  
Unread 10-02-2008, 12:49
whitetiger0990's Avatar
whitetiger0990 whitetiger0990 is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Earth
Posts: 157
whitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of light
Re: define irswitch?

We NOT our digital ins right there at the macro. Like what psy_wombats said, but I think that it reads better in the if statements. Digital inputs become false when the circuit is closed. =)

Code:
#define IRswitch1 !rc_dig_in01
__________________
print$q=chr(ord($q)+$1)while("7443-0201-8465130105-12-03135-82482113-06-7672-070208-0613-70"=~/(-?\d\d)/g);
  #4   Spotlight this post!  
Unread 10-02-2008, 19:21
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: define irswitch?

Quote:
Originally Posted by whitetiger0990 View Post
Digital inputs become false when the circuit is closed.
That's correct for switches or "open-collector output" sensors that complete a connection to ground. But the IR sensor is not that kind of circuit. It provides a logic level output, with the digital input resting at zero and going to one when the signal is recognized.
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
Define Happiness Elgin Clock Chit-Chat 17 30-04-2007 21:59
Define A Wedge T3_1565 Rules/Strategy 18 11-01-2007 21:22
Define FIRST slickguy2007 General Forum 24 13-10-2006 08:24
#define creation NASAbound1636 Programming 3 02-02-2006 23:40
Conditional #define Statements Ian W. Programming 3 14-02-2004 18:14


All times are GMT -5. The time now is 03:19.

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