Go to Post Not all creativity is visible or mechanical! - dtengineering [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 13-02-2008, 15:14
TerranCoder TerranCoder is offline
Registered Coder from Earth
FRC #2538 (Plaid Pillagers)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Morris, Minnesota
Posts: 5
TerranCoder is an unknown quantity at this point
Strange PWM/Motor Behavior!

A bit of prologue background: we're working on rack-and-pinion steering for our robot. As such, I've (supposedly) changed the Default Code to the point where X-axis changes should only be sent to pwm13, the steering motor.

However, it seems that with either of the joysticks sent with the KOP, the x changes are for some reason sent to the drive motors as well as the steering motor and the Y-axis changes are sent to the steering motor as well as the drive motors.

Here's the PWM setup:

pwm16: Right drive motors
pwm15: Left drive motors
pwm13: Steering motor

Here's the steering code (so far, not sure if it works yet! )

Code:
  if (p1_x >= MAXI) {	
    XDelta = MAXI-Temp;
  } 
  else if (p1_x <= MINI)
  {
    XDelta = MINI - Temp;
  }

  if (XDelta < 0 && XDelta < -4) {
    XDelta *= -1;
    for (i = 0; i<(XDelta/4); i++) {
		for (j = 0; j < 10; j++) {
			pwm13 = 0;
   		}
		pwm13 = 127;
		MAXI -= 4;
		MINI -= 4;
    }
    Temp = p1_x;
  }
  else if (XDelta > 0 && XDelta > 4)
  {
	 for (i = 0; i<(XDelta/4); i++) {

		for (j = 0; j<10; j++) {
			pwm13 = 255;
   		}
		pwm13 = 127;
		MAXI += 4;
		MINI += 4;
    }
	Temp = p1_x;
  }
Temp, MAXI, and MINI are all global variables first initialized in User_Initialization(). XDelta is a local variable unused elsewhere.

Here is the drive motor code (such as it is) :

Code:
 if (TempY > p1_y+15) 
  {
    TempTemp = p1_y/2;
    pwm15 = Exponential_Grow(TempTemp,0);
    pwm16 = Exponential_Grow(TempTemp,0);
	TempY = p1_y/2;
  } 
  else if (TempY < p1_y-15) 
  {
    TempTemp = p1_y/2;
    pwm15 = Exponential_Grow(TempTemp,0);
    pwm16 = Exponential_Grow(TempTemp,0);
    TempY = p1_y/2;
  } 
  else 
  {
    pwm15 = Exponential_Grow(p1_y,0);
    pwm16 = Exponential_Grow(p1_y,0);
	TempY = p1_y;
  }
TempY is also a global variable initialized in User_Initialization(). TempTemp is a local variable not used anywhere else.

As far as I can tell, it's displaying behavior similar to that of the basic Default code and trying to do the two-wheeled turning using pwms 13-16.

Any help would be very, very appreciated!

Last edited by TerranCoder : 13-02-2008 at 15:17. Reason: Incorrect variable name: TempT
  #2   Spotlight this post!  
Unread 13-02-2008, 15:46
Chaos in a Can Chaos in a Can is offline
Joel Spadin
FRC #1736 (Robot Casserole)
Team Role: Programmer
 
Join Date: Mar 2007
Rookie Year: 2007
Location: Peoria, IL
Posts: 58
Chaos in a Can is an unknown quantity at this point
Send a message via MSN to Chaos in a Can
Re: Strange PWM/Motor Behavior!

First, make sure the pwms are actually connected to the motors you think they are.

If you find the IFI dashboard application, you can connect your computer to the Dashboard port on the OI and look at the pwm outputs directly.

Next, I would suggest using "Find in Files" and searching for any other occurances of pwm13, pwm15, or pwm16.
Also I don't know what Exponential_Grow contains, but you could check there as well.


If all else fails, try temporarily replacing your drive code with something simpler and reintroducing parts of it until you find the problem. You could start with something as simple as this:
Code:
pwm13 = p1_x;
pwm15 = p1_y;
pwm16 = 255-p1_y;
It may also be a good idea to disconnect the motors and just watch the outputs using the dashboard until you find the problem.
__________________
2006 Xerox Creativity Award
2007 General Motors Industrial Design Award
2008 Judges' Award
2009 Chrysler Team Spirit Award

  #3   Spotlight this post!  
Unread 13-02-2008, 16:35
TerranCoder TerranCoder is offline
Registered Coder from Earth
FRC #2538 (Plaid Pillagers)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Morris, Minnesota
Posts: 5
TerranCoder is an unknown quantity at this point
Re: Strange PWM/Motor Behavior!

Find in Files returns only the initialization code (pwm* = 127) and any code that I personally have added, none of which affects two pwms at the same time.

Exponential_Grow takes a value and returns another value, no pwm code at all.

I'll give the Dashboard a try and see if that explains anything.

Is there any chance that the RC somehow isn't using the new code? The IFI Loader seems to work, but I'm not sure if there has been any actual change in behavior. I'm very positive that the compiled HEX file is the one I'm working on and not the Default.
  #4   Spotlight this post!  
Unread 13-02-2008, 16:37
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Strange PWM/Motor Behavior!

are you still calling Default_Routine() ? It could just be overwriting anything you do.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
  #5   Spotlight this post!  
Unread 13-02-2008, 16:57
TerranCoder TerranCoder is offline
Registered Coder from Earth
FRC #2538 (Plaid Pillagers)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Morris, Minnesota
Posts: 5
TerranCoder is an unknown quantity at this point
Re: Strange PWM/Motor Behavior!

Yes, I am calling Default_Routine(), but all the code and changes I've talked about where made in there, so if it is working, there shouldn't be an issue with that.
  #6   Spotlight this post!  
Unread 13-02-2008, 17:40
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,384
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Strange PWM/Motor Behavior!

If you are calling Default_Routine(), look for this bit of code:

Code:
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127); 
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
If it is still not commented out, that may be what is vexing you
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #7   Spotlight this post!  
Unread 13-02-2008, 17:44
TerranCoder TerranCoder is offline
Registered Coder from Earth
FRC #2538 (Plaid Pillagers)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Morris, Minnesota
Posts: 5
TerranCoder is an unknown quantity at this point
Re: Strange PWM/Motor Behavior!

Actually, those were the first two lines of code that I removed from the Default_Routine() code when I changed it. However, I did double check that to make sure and indeed, they are gone from my code.

In fact, I've removed the entire limit mix function.
  #8   Spotlight this post!  
Unread 13-02-2008, 17:49
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,384
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Strange PWM/Motor Behavior!

Does your system use interrupts, as in, are you using encoders to sample your wheel revolutions?
If so, PWM's 13-15 can get really squirly!
If that is the case, look into Kevin Watson's PWM replacement code. It uses the CCP hardware and no interrupts will bother it.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #9   Spotlight this post!  
Unread 13-02-2008, 17:53
TerranCoder TerranCoder is offline
Registered Coder from Earth
FRC #2538 (Plaid Pillagers)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Morris, Minnesota
Posts: 5
TerranCoder is an unknown quantity at this point
Re: Strange PWM/Motor Behavior!

No interrupts, but I believe I am already using Kevin's code. And that's another strange thing. One would think that the behavior of the robot would change with the change of pwm code, and yet I didn't notice any visible difference.
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
Serial PWM motor controller smartkid Technical Discussion 18 30-12-2007 12:35
GTS strange behavior iwdu15 Programming 6 01-02-2007 18:46
vEx PWM Motor Response yoyodyne Control System 9 16-10-2006 00:37
my behavior lil_longo General Forum 1 24-02-2006 13:53
Strange Behavior Gary Bonner Control System 17 09-11-2005 19:01


All times are GMT -5. The time now is 01:48.

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