View Single Post
  #1   Spotlight this post!  
Unread 11-01-2008, 16:40
taggartbg taggartbg is offline
Registered User
FRC #1712 (Dawgma)
Team Role: Electrical
 
Join Date: May 2005
Rookie Year: 2006
Location: Lower Merion, PA
Posts: 38
taggartbg will become famous soon enoughtaggartbg will become famous soon enough
Send a message via AIM to taggartbg Send a message via MSN to taggartbg Send a message via Yahoo to taggartbg
SetPWM and our IR controls

Hey everybody,

So I got the IR board programmed, got it all wired up to interface with the bot, coded it all out, and nothing happens. I currently only have one of the pins on the board (pin 5) running into the Digital In/Out (signal pin 1). I'm trying to get this working on a two-motor tank-drive bot with the '07 microcontroller. Here is my IR code:

Quote:
void OperatorController (void )
{
unsigned char ir1;
unsigned char ir2;
unsigned char ir3;
unsigned char ir4;

while ( 1 ) //I'm pretty sure I need this while loop, yes?
{
Tank2 ( 1 , 2 , 2 , 2 , 1 , 2 , 0 , 1);
ir1 = GetDigitalInput ( 1 ); //this should return "1" if it is getting signal, yes?
ir2 = GetDigitalInput ( 2 );
ir3 = GetDigitalInput ( 3 );
ir4 = GetDigitalInput ( 4 );

if ( ir1 == 1) //turn left at half speed
{
SetPWM ( 1 , 65 );
SetPWM ( 2 , 192 );
continue; //do I need this?
}

else if ( ir2 == 1) //straight at half speed
{
SetPWM ( 1 , 192 );
SetPWM ( 2 , 192 );
continue; //do I need this?
}

else if ( ir3 == 1) //turn right at half speed
{
SetPWM ( 1 , 192 );
SetPWM ( 2 , 65 );
continue; //do I need this?
}

else if ( ir4 == 1) //backwards at half speed
{
SetPWM ( 1 , 65 );
SetPWM ( 2 , 65 );
continue; //do I need this?
}

else //all stop
{
SetPWM ( 1 , 127 );
SetPWM ( 2 , 127 );
continue; //again, do I need this?
}
}
}
After a few attempts and nothing happing on the bot, I decided to try this simple code to start picking peice by peice what works and what doesn't:

Quote:
void OperatorController (void )
{
while ( 1 )
{
SetPWM ( 1 , 192 );
SetPWM ( 2 , 192 );
}
}
In theory, that should make the motors start moving forward at half speed yes? Well it just sits there doing nothing.


I was hoping someone could identify what exactly I'm doing wrong, as I am getting zero results from my bot.

Thanks,
/Taggart, team 1712