Go to Post It isnt about winning and losing (although getting the trophies and medals are nice) - Winged Wonder [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 14-02-2008, 16:22
ShotgunNinja's Avatar
ShotgunNinja ShotgunNinja is offline
Programming Mentor, FRC 4247
AKA: Nicholas Iannone
FRC #4247 (CougarBOTS)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Milwaukee, WI
Posts: 159
ShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the roughShotgunNinja is a jewel in the rough
Question Help with Hybrid code

I have been having trouble with my Hybrid mode setup. I'm not sure what exactly is the problem, but I have been led to believe it is my sometimes flawed programming. (See my other posts if you don't believe me). I am using the provided IR board, and with a regular IR remote setup, for a VCR remote. The outputs are (supposedly) wired into Digital In/Out ports #1-4, and the IR board is receiving power.

Here is my code (it's a bit un-simplified, so propagators of KISS please don't complain too much)

Code:
/* Some globals: */
unsigned char offsensor1;
unsigned char offsensor2;
unsigned char offsensor3;
unsigned char offsensor4;

/* Initialize */
void Initialize(void)
{
   InitIRSensor();
   /* ... */
}

/* InitIRSensor */
void InitIRSensor(void)
{
   offsensor1 = GetDigitalInput(1);
   offsensor2 = GetDigitalInput(2);
   offsensor3 = GetDigitalInput(3);
   offsensor4 = GetDigitalInput(4);
}

/* Autonomous */
void Autonomous(void)
{
   unsigned char irsensor1;
   unsigned char irsensor2;
   unsigned char irsensor3;
   unsigned char irsensor4;
   int action = 0;
   
   while( IsAutonomous() )
   {
      irsensor1 = GetSensorInput(1);
      irsensor2 = GetSensorInput(2);
      irsensor3 = GetSensorInput(3);
      irsensor4 = GetSensorInput(4);
      if ((irsensor1 + irsensor2 + irsensor3 + irsensor4) >= 2)
      {
         action = 0;
      }
      else if (irsensor1)
      {
         action = 1;
      }
      else if (irsensor2)
      {
         action = 2;
      }
      else if (irsensor3)
      {
         action = 3;
      }
      else if (irsensor4)
      {
         action = 4;
      }
      else
      {
         action = 0;
      }
      HybridAction(action);
   }
}

/* GetSensorInput */
unsigned char GetSensorInput(int sensorPort)
{
   unsigned char value;
   switch(sensorPort)
   {
      case 1:
      {
         value = offsignal1;
         break;
      }
      case 2:
      {
         value = offsignal2;
         break;
      }
      case 3:
      {
         value = offsignal3;
         break;
      }
      case 4:
      {
         value = offsignal4;
         break;
      }
   }
   return(GetDigitalInput(sensorPort) == value);
}
__________________
Team #2970 Alum
Team #1652 Alum
2006: School Mascot for Team 1652
2007-2008: Programmer for Team 1652 (Robot Mafia)
2009: Programmer on Team 1652 (Robot Mafia), Programmer on Team 2970 (eSchool eBots)
2010-2016: Volunteer, Wisconsin Regional
2017: Programming Mentor, FRC 4247 (CougarBOTS, Obama SCTE, Milwaukee, WI)
 


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
Help with VB code Setsanto Programming 8 08-02-2007 16:04
Help with code b-rant Programming 1 05-04-2006 13:52
Need help with code CaseyKasem_1251 Programming 3 18-02-2006 09:39
Help With Compressor Code fred Programming 6 21-01-2005 17:40
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46


All times are GMT -5. The time now is 13:37.

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