Go to Post As usual, I mistakenly look for a technical solution to a social problem. - MrForbes [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
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 29-01-2013, 21:28
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
[FTC]: IR Code With Two Sensors

Hello. I recently finished creating a very simple IR code that basically tells the robot to drive parallel to the ring rack until the IR beacon mounted to the side of the robot detects that the beacon is directly in front of the sensor. The robot then turns so the ring rack is in front of it, then it drives forward and places the ring. However, the wood platform in the middle that holds the ring rack causes a variation so that the turn the robot takes to face the dispenser after it detects the IR becomes inconsistent depending on which peg the IR is on. To fix that, we added another IR beacon mounted to the front of the robot, which is ideally supposed to cause the robot to stop when it is perfectly straight with the dispenser to make sure the turn aligns the robot to score perfectly every time. However, I was having an issue with having two "if" statements. When I tested the code I created, the robot did not stop directly in front of the dispenser when the second IR beacon reached the middle value, it instead went forward. I believe this to be because the other beacon is attempting to move the robot according to its commands when the robot changed position. Is there any way to make it so that the first "if" statement is temporarily nullified while the second "if" statement is occurring? Below is my code, and any help would be greatly appreciated in determining how to nullify the first "if" statement while the second one is taking place, or if I should just restructure the code entirely. Thanks again!

JIT

Code:
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Sensor, S3, IRSeeker2, sensorHiTechnicIRSeeker1200)
#pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, motorF, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C2_2, motorG, tmotorTetrix, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
motor[motorD] = 100;
motor[motorE] = 100;
motor[motorF] = 100;
motor[motorG] = 100;
wait1Msec(400);

motor[motorD] = 0;
motor[motorE] = 0;
motor[motorF] = 0;
motor[motorG] = 0;

motor[motorD] = 100;
motor[motorE] = 100;
motor[motorF] = -100;
motor[motorG] = -100;
wait1Msec(500);

motor[motorD] = 0;
motor[motorE] = 0;
motor[motorF] = 0;
motor[motorG] = 0;

while(1 == 1)
{
if(SensorValue[IRSeeker2] == 5)
{
motor[motorD] = 0;
motor[motorE] = 0;
motor[motorF] = 0;
motor[motorG] = 0;
}
if(SensorValue[IRSeeker2] > 5)
{
if(SensorValue[IRSeeker] == 5;
{
motor[motorD] = 0;
motor[motorE] = 0;
motor[motorF] = 0;
motor[motorG] = 0;
}
else
{
motor[motorD] = 100;
motor[motorE] = 100;
motor[motorF] = -100;
motor[motorG] = -100;
}
}

if(SensorValue[IRSeeker2] < 5)
{
motor[motorD] = 100;
motor[motorE] = 100;
motor[motorF] = 100;
motor[motorG] = 100;
}
}
}
Reply With Quote
 


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 18:26.

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