Go to Post Team newb: To expect any average group of high schoolers to build and develop a robot in less than six weeks is...madness! Me: Madness? THIS IS FIRST! Newb: Yeah, I just walked into the Pit of Death with that one. - MishraArtificer [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-10-2012, 21:09
Just_In_Time Just_In_Time is offline
Registered User
no team
 
Join Date: Jul 2012
Rookie Year: 2010
Location: United States
Posts: 18
Just_In_Time is an unknown quantity at this point
IR Code RobotC

Hello. I am a student on a FTC team with a question regarding IR sensor coding in RobotC. I was recently working on a program that uses the IR Beacon for this year's FTC Game. I started off with a more basic and conventional IR Code as follows:

task main()
{
while(1 == 1)
{
if(SensorValue[IRSeeker2] == 5)
{
motor[motorD] = 50;
motor[motorE] = 50;
motor[motorF] = -50;
motor[motorG] = -50;
}

if(SensorValue[IRSeeker2] > 5)
{
motor[motorD] = 50;
motor[motorE] = 50;
motor[motorF] = 50;
motor[motorG] = 50;
}

if(SensorValue[IRSeeker2] < 5)
{
motor[motorD] = -50;
motor[motorE] = -50;
motor[motorF] = -50;
motor[motorG] = -50;
}
}
}

This worked very well and did exactly what it was intended to do; follow the IR beacon infinitely. However, when looking at the code and testing it with the IR beacon on the ring dispenser I realized I needed something that stopped a just slightly before reaching the ring rack so that we could place the ring instead of the code going on infinitely. Below is the code that I came up with.

task main()
{
if(SensorValue[IRSeeker2] == 5)
{
motor[motorD] = 50;
motor[motorE] = 50;
motor[motorF] = -50;
motor[motorG] = -50;
wait1Msec(5000);
}

if(SensorValue[IRSeeker2] > 5)
{
motor[motorD] = 50;
motor[motorE] = 50;
motor[motorF] = 50;
motor[motorG] = 50;
wait1Msec(5000);
}

if(SensorValue[IRSeeker2] < 5)
{
motor[motorD] = -50;
motor[motorE] = -50;
motor[motorF] = -50;
motor[motorG] = -50;
wait1Msec(5000);
}
}

However, this didn't work as intended. Instead of doing the desired task when the IR beacon was at different positions, each time it defaulted to the third section which is what it is supposed to do only when the sensor value is < 5. I made sure that it wasn't a physical problem with the bot by running our previous code and it still worked as well as it did before. Therefore, I am a tad stuck as to why it isn't changing when the beacon is in different positions. Any help with this would be very much appreciated. Thanks.

JIT
 


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


All times are GMT -5. The time now is 09:39.

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