Go to Post you should see my scout sheet its the bomb diggity - Mirza95vx [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 18-04-2005, 17:52
Orborde Orborde is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Apr 2004
Rookie Year: 2003
Location: Indianapolis, IN
Posts: 44
Orborde has a spectacular aura aboutOrborde has a spectacular aura about
Send a message via AIM to Orborde
Question Weird Disappearing Commands

That's the best description I could think of to describe this problem. I have the following code:

Code:
void Elbow_Targetize_PID(void) {
     unsigned int current;
     signed int error, output;

     current = Get_Analog_Value(elbow_pot);    // measure the elbow potentiometer

     elbow_motor = 127;   // just to be safe

     // (elbow_target_abs is a global variable describing the goal state of the
     // potentiometer. It is set up this way to make the elbow's usage roughly
     // in line with that of the PWMs and such

     error = ((signed int) elbow_target_abs) - ((signed int) current);
     //yes, I know I'm cast-crazy...

     output = (error >> 3);   // quickly divide by 8
     output = output * 2;    // and multiply by two (I have no idea why I did this)


     // kick the output out of the deadband
     if (output < 0) output -= 7;
     if (output > 0) output += 7;


     // finally, assign the end result to the motor (it's backwards)
     elbow_motor = (unsigned char) (127 - output);

     // the output gets limited later by a safety function, though it occurs
     // to me that I should do it in here to avoid problems
}
First, yes, I know it's just a P, not a PID, controller. Sue me.

At any rate, the problem is in the bolded lines. They don't seem to be getting executed at all. I've checked it several times and it still doesn't seem to do it. Now, the elbow control works fine despite this, but it still worries me. I can only guess that those few lines are being "optimized" away for some reason by mcc18. I even put the same function into another development environment and tested it, and it worked as expected. What gives?

I'm using Master Software 10 and mcc18 2.40 with MPLAB 7.00.

Maybe I'm crazy. Could someone else try this function to see if the problem shows its hairy face?

Last edited by Orborde : 18-04-2005 at 17:58.
 


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
Can anyone create new commands? Jakenan Programming 5 22-01-2005 21:38
Autonomous Commands Promised in Kickoff schenkin Programming 11 16-01-2005 08:58
Weird Al MattK Chit-Chat 7 10-11-2002 00:33
Voice Activated commands Amber H. Technical Discussion 40 03-11-2002 12:40
the weird feeling.. archiver 2000 3 23-06-2002 23:08


All times are GMT -5. The time now is 09:39.

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