Go to Post I am definitely as much a student as any one of the kids on the team. - Hieb [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
  #16   Spotlight this post!  
Unread 31-03-2004, 14:18
omega's Avatar
omega omega is offline
Registered User
#1352
 
Join Date: Mar 2004
Location: Stratford Northwestern
Posts: 11
omega is an unknown quantity at this point
Re: heres the code. y this not working

ya uh we need more help then that

thz anymore
  #17   Spotlight this post!  
Unread 31-03-2004, 15:18
DKolberg DKolberg is offline
Mentor Iron Giants
AKA: David Kolberg
FRC #5069 (Iron Giants)
Team Role: Mentor
 
Join Date: May 2002
Rookie Year: 2000
Location: South Bend
Posts: 44
DKolberg has a spectacular aura aboutDKolberg has a spectacular aura about
Re: heres the code. y this not working

/* Add your own autonomous code here. */

Navigate();

if(rc_dig_in01 ==1 )
{
pwm13 = 137;
pwm14=100;
}
else
{
pwm13 = pwm14 = 140;
}
if(rc_dig_in02 == 1)
{
pwm13 = 100;
pwm14 = 137;
}
else
{
pwm13 = pwm14 = 140;
}



This code will ignore the rc_dig_in01 as the if(rc_dig_in02 == 1) overwrites the values. You need to create 4 states for this or at least determine what you want to happen for each of the 4 states that can happen with two digital inputs:

rc_dig_in01 == 0, rc_dig_in02 == 0
rc_dig_in01 == 0, rc_dig_in02 == 1
rc_dig_in01 == 1, rc_dig_in02 == 0
rc_dig_in01 == 1, rc_dig_in02 == 1

I assume here that these are the inputs from a light sensor that indicates which light is seeing the tape, depending on how far away each sensor is it may not be possible to get both on at the same time. Then you are down to only 3 states. For simplicity lets define

Left == (rc_dig_in01 == 1);
Right == (rc_dig_in02 ==1);

Now:
if (Left)
{
turn right
}
else if (right)
{
turn left
}
else
{
go straight
}

if both left and right can be on at the same time then check for that first
if (Left && Right)
{
}
else if (Left)
{
}
else if (Right)
{
}
else
{
}


Hope this helps,

Dave
SBotz
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
What is your most prefered programming language? Hailfire Programming 156 19-01-2005 21:42
Speed limiting code from last year in C? Josh Siegel Programming 6 01-04-2004 22:27
Interrupt timer, executing code asap? SeanCassidy Programming 10 07-03-2004 01:47
Inserting Naviagation code into Default code? actorindp Programming 3 28-01-2004 18:12
Does your team use the Default code. Jeff McCune General Forum 2 09-01-2003 14:46


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

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