Go to Post If this photo doesn't tell us why a photographer is important to a team, I don't know what will. - JaneYoung [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
  #1   Spotlight this post!  
Unread 18-01-2008, 18:25
drewjones13's Avatar
drewjones13 drewjones13 is offline
Registered User
no team
Team Role: College Student
 
Join Date: Jan 2007
Rookie Year: 2006
Location: CA
Posts: 13
drewjones13 is an unknown quantity at this point
Exclamation IR Issues in Mplab

We are currently using mplab and we having trouble with the pulses of the remote. Here is an example of our coding:
Code
Code:
if (rc_dig_in10 == 1)
{
    cmd0; //Call the cmd0(forward) subroutine
}
Subroutine
Code:
unsigned char cmd0()
{
    pwm01 = pwm02 = 190; //Forward Half Speed
    return 0;
}
Basically this is saying that if rc_dig_in10(we are using digital i/o ports 10 through 13) is equal to 1 it will call the cmd0 subroutine. The cmd0 subroutine tells both wheels to go forward half speed.
But this makes it so the pulses just pulse the motors forward and do not hold them at constant forward movement. What are other teams doing to rectify/compensate for this?
  #2   Spotlight this post!  
Unread 18-01-2008, 18:40
usbcd36's Avatar
usbcd36 usbcd36 is offline
Registered User
AKA: "DOS"
FRC #2399 (The Fighting Unicorns)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Solon, OH
Posts: 151
usbcd36 is a jewel in the roughusbcd36 is a jewel in the roughusbcd36 is a jewel in the rough
Re: IR Issues in Mplab

There doesn't seem to be anything wrong with the code you posted; the error may lie elsewhere.

In the autonomous loop, are you setting the PWMs to 127 every time?
  #3   Spotlight this post!  
Unread 18-01-2008, 19:04
Laaba 80 Laaba 80 is offline
Registered User
AKA: Joey
FRC #1714 (MORE Robotics)
Team Role: Alumni
 
Join Date: Dec 2007
Rookie Year: 2001
Location: San Jose, CA
Posts: 495
Laaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond reputeLaaba 80 has a reputation beyond repute
Re: IR Issues in Mplab

Quote:
Originally Posted by drewjones13 View Post
if (rc_dig_in10 == 1)
{
cmd0; //Call the cmd0(forward) subroutine
}
[/code]
Subroutine
Code:
unsigned char cmd0()
{
    pwm01 = pwm02 = 190; //Forward Half Speed
    return 0;
}
What I think your problem is that you have nothing telling it how far to go. You may also not want to directly call the subroutine from the sensor do something to the sort of.

if (rc_dig_in10 == 1)
{
ButtonPressed = TRUE;
}
[/code]
Subroutine[code]
if (ButtonPressed == TRUE)
{
//You could also call your subroutine here if you wanted to
pwm01 = pwm02 = 190; //Forward Half Speed
return 0;
}

This will work because the way you had it written, as soon as the button lets go, it equals 0. Since the processor runs every 27 milliseconds or so, it will start, and then quickly stop if pressed once. Doing it the way I showed sets another variable that once it sees the button gets set, and if it gets let go it is still going. If you have anymore questions, let me know.
Joey


PS I'm not sure if the syntax is perfect, I just wanted to show you the concept.
__________________
Driving Record - 75-43-8
Coaching Record - 92-65
  #4   Spotlight this post!  
Unread 18-01-2008, 19:36
drewjones13's Avatar
drewjones13 drewjones13 is offline
Registered User
no team
Team Role: College Student
 
Join Date: Jan 2007
Rookie Year: 2006
Location: CA
Posts: 13
drewjones13 is an unknown quantity at this point
Re: IR Issues in Mplab

We were able to figure it out. The issue was with an else branch that we had that was setting the pwm01 and pwm02 equal to 127.
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
MpLab issues! AdmiralAllen Programming 3 15-01-2007 22:47
MPLAB Issues jcatt Programming 3 02-02-2006 17:49
Issues with MPLAB 7.30 gnirts Programming 4 25-01-2006 22:57
using the MPLAB IDE MPLAB SIM simulator WizardOfAz Programming 1 03-11-2003 01:24


All times are GMT -5. The time now is 07:53.

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