Go to Post I think the GDC should force us to use steam engines, but the electrically-inclined folks on my team might stop whining if they're given more to work with. - Madison [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-04-2010, 06:18
krudeboy51's Avatar
krudeboy51 krudeboy51 is offline
Only Programmer
AKA: kory
FRC #0369 (369)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: brooklyn
Posts: 151
krudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of light
Send a message via AIM to krudeboy51
INFRARED SENSORS

can any one please assist me on how to program an infrared sensor in autonomous mode, and give a sample code for it in windriver c++?? (i never learned how to program any)


Quote:
is it possible to use an if statement in void autonomous??
should the infrared sensor be wired to the digital sidecar as a digital input, or a pwm port?

Last edited by krudeboy51 : 08-04-2010 at 06:33.
Reply With Quote
  #2   Spotlight this post!  
Unread 08-04-2010, 08:33
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: INFRARED SENSORS

"Programming" an input is just a matter of reading its value and testing it to decide what the program should do. What do you want the program to do?

What output does the sensor provide? If it's the equivalent of a switch, it goes to a digital input. If it's a varying voltage related to the distance from the sensor to the target, it goes to an analog input.

You can do anything in the autonomous routine that you would do in teleoperated mode.

PWM pins on the Digital Sidecar are outputs only. They can't read sensors.
Reply With Quote
  #3   Spotlight this post!  
Unread 08-04-2010, 15:15
krudeboy51's Avatar
krudeboy51 krudeboy51 is offline
Only Programmer
AKA: kory
FRC #0369 (369)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: brooklyn
Posts: 151
krudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of light
Send a message via AIM to krudeboy51
Re: INFRARED SENSORS

Quote:
Originally Posted by Alan Anderson View Post
"Programming" an input is just a matter of reading its value and testing it to decide what the program should do. What do you want the program to do?
i want when the infrared sensor is interrupted the robot stops, i declared in class and in public as a digital input, but i dont know how to write a code for it, all i have is:

Quote:
class:
DigitalInput *InfraredSensor;
public:
InfraredSensor = new DigitalInput(1);
void Autonomous:
if (InfraredSensor->????())
{
myRobot->Set(0.0);
but i dont know what to put where the question marks are.
Reply With Quote
  #4   Spotlight this post!  
Unread 08-04-2010, 15:42
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: INFRARED SENSORS

InfraredSensor->Get() will return the state of the input. This method is featured prominently in the documentation for the DigitalInput class, isn't it?
Reply With Quote
  #5   Spotlight this post!  
Unread 08-04-2010, 18:02
krudeboy51's Avatar
krudeboy51 krudeboy51 is offline
Only Programmer
AKA: kory
FRC #0369 (369)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: brooklyn
Posts: 151
krudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of light
Send a message via AIM to krudeboy51
Re: INFRARED SENSORS

Quote:
Originally Posted by Alan Anderson View Post
InfraredSensor->Get() will return the state of the input. This method is featured prominently in the documentation for the DigitalInput class, isn't it?
one more question, what values should i set for the sensor?

Quote:
InfraredSensor->Get(?????))
or
InfraredSensor->Get()?????)
which one, and what should i put in the places where the question mark are?? should i put a number or true or false??

Last edited by krudeboy51 : 08-04-2010 at 19:34.
Reply With Quote
  #6   Spotlight this post!  
Unread 08-04-2010, 21:18
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: INFRARED SENSORS

Quote:
Originally Posted by krudeboy51 View Post
one more question, what values should i set for the sensor?
It will return a boolean value. Typically true means the signal on the DIO pin is a high voltage (5v) and false means it is a low voltage (0v). Since there is a pullup resistor on the input, an open circuit will read true and a switch closure to ground will read false.

I don't really understand the rest of your question, but the documentation should answer anything you need to know.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-04-2010, 01:59
Al3+'s Avatar
Al3+ Al3+ is offline
ARTist
AKA: Anthony
FRC #0840 (Aragon Robotics Team)
Team Role: Programmer
 
Join Date: Oct 2009
Rookie Year: 2008
Location: San Mateo, CA
Posts: 58
Al3+ is a jewel in the roughAl3+ is a jewel in the roughAl3+ is a jewel in the rough
Re: INFRARED SENSORS

InfraredSensor->Get() has no parameters, so nothing needs to go inside the parentheses. I think that was the question.

You want something like
Code:
if (InfraredSensor->Get())
  myRobot->Set(0.0);
This will set myRobot to 0 when the infrared beam is interrupted, assuming Get() returns true when interrupted. If it returns false, you'll have to flip it.
__________________
cout << "Hello, robotics. Goodbye, world." << endl;

"The two-axis accelerometer provided in the kit of parts (shown in the picture below) is a two-axis accelerometer." - WPILib User's Guide
Reply With Quote
  #8   Spotlight this post!  
Unread 09-04-2010, 18:14
krudeboy51's Avatar
krudeboy51 krudeboy51 is offline
Only Programmer
AKA: kory
FRC #0369 (369)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: brooklyn
Posts: 151
krudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of lightkrudeboy51 is a glorious beacon of light
Send a message via AIM to krudeboy51
Re: INFRARED SENSORS

Thanks alot!!
Reply With Quote
Reply


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
InfraRed Problem tbd Sensors 10 27-01-2008 02:01
where can we buy hall effect sensors or gear tooth sensors amirjpl Electrical 3 13-02-2006 11:02
IR (infrared) sensors Chris.Steimel Electrical 5 11-02-2005 18:46
IR (infrared) sensors Chris.Steimel Programming 0 09-02-2005 18:04
InfraRed = gps ? nzj1 General Forum 17 11-01-2004 16:58


All times are GMT -5. The time now is 15:18.

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