View Single Post
  #14   Spotlight this post!  
Unread 15-01-2008, 08:48
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Getting constant motor power with IR board

Check your remote to see if it's the repeating type. That means when you hold down a button on the remote, the output on the IR board will pulse every 100ms until you release the button.

If that's not the case, I'd highly recommend finding a remote that does this. The first Sony remote we picked up worked nicely for us in this manner.

The code below hasn't been tested or compiled since we've just been "pulsing" our motors, and our chassis isn't ready to go full-speed yet.

The code below should sets a timer to run the motors for 150ms after it receives a pulse from the IR board. If you have a signal pulsing every 100ms, that means that the timer will keep resetting before it ever expires = constant power.

Your robot WILL continue to run for 150ms after you've released the button on the remote, but I'll leave it up to you whether you feel that is acceptable.

-Shawn T. Lim...

Code:
// set your timer's limit
// see JBot's post, 7 ticks is a little more than 150ms
static char variable = 8;

// ...other code goes here...

// whenever you receive a signal from your IR board, reset your timer
if (rc_dig_in01)
{
    variable = 0;
}
// whenever there is no signal, run your timer until it expires
else
{
     if (variable < 8)
     {
          variable++;
     }
}

// run your motors if the timer is running
if (variable < 8)
{
     pwm03 = pwm04 = 1;
     pwm07 = pwm08 = 255;
}
else
// stop motors when timer expires
{
     pwm03 = pwm04 = 128;
     pwm07 = pwm08 = 128;
}

Last edited by Mr. Lim : 15-01-2008 at 08:51.