Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   C Programming Question (http://www.chiefdelphi.com/forums/showthread.php?t=25285)

tophq 14-02-2004 14:39

C Programming Question
 
Ok, before I begin let me start off by saying that I have checked around to find the answer ot my question and I have not found a suitable answer, this may be due to the lack of my attention span though...lol. Ok my problem is I'm trying to use the trim wheel on the joystick to set the robot into autonomous mode. Now I first added the
Code:

unsigned char wheel_right
to the user_routines.h header file and I still keep getting errors. It says "wheel_right is not defined" when I try to build it. I also tried adding the code directly before the function but when I do that it says I have multiple definitions and it still won't build. Where and how do I need to define and declare my variables. Any help would be greatly appreciated.

Mark McLeod 14-02-2004 14:52

Re: C Programming Question
 
Quote:

Originally Posted by tophq
Ok, before I begin let me start off by saying that I have checked around to find the answer ot my question and I have not found a suitable answer, this may be due to the lack of my attention span though...lol. Ok my problem is I'm trying to use the trim wheel on the joystick to set the robot into autonomous mode. Now I first added the
Code:

unsigned char wheel_right
to the user_routines.h header file and I still keep getting errors. It says "wheel_right is not defined" when I try to build it. I also tried adding the code directly before the function but when I do that it says I have multiple definitions and it still won't build. Where and how do I need to define and declare my variables. Any help would be greatly appreciated.

The trim wheels are only used to trim the joystick neutral point. The robot controller cannot see the trim values.
Use one of the joystick buttons instead, say p1_sw_top, like:
Code:

if (p1_sw_top)  User_Autonomous_Code

tophq 14-02-2004 14:57

Re: C Programming Question
 
Thanx

tophq 15-02-2004 13:44

Re: C Programming Question
 
just one more more question (maybe more depending on the answer...lol). im trying to write a practice autonomous code for the robot. my plan is to use the 'p1_sw_trig' button to enable a set of actions (in this case just to move the motor forward, then stop, then backward, then stop again using the counter function. im getting really weird syntax errors that i have no idea what's happening.

Code:


int counter = 0;
short end_program =  0;

void Process_Data_From_Local_IO(void)
{

if (end_program != 1)
        {
        counter++;

        if ((p1_sw_trig == 1) && (counter <= 120))
        {
        pwm01 = 127;
        }
        else if ((p1_sw_trig == 1) && (counter > 120))
        {
        pwm01 = 255;
        }
        else if ((p1_sw_trig == 1) && (counter > 240))
        {
        pwm01 = 127;
        }
        else if ((p1_sw_trig == 1) && (counter > 360))
        {
        pwm01 = 0;
        }
        else if ((p1_sw_trig == 1) && (counter > 480))
        {
        pwm01 = 127;
        end_program = 1;
        }
}


/********************************************************/
/********************************************************/
/********************************************************/
  <-------------------

the arrow points to the line that the syntax error was shown at. i put the code under the 'Process_Data_From_Local_IO' code because when i'd put it in the 'User_Autonomous_Code' it would give me an error at the 'Process_Data_From_Local_IO' line. let me know if im doing something wrong (obviously i am...lol). im pretty much a beginning programmer (HTML and TI-83...lol). any help you can give will help greatly.

blindguyinanorg 15-02-2004 13:53

Re: C Programming Question
 
to your first post....if you need a variable in two classes than in the second you declare it:

code:
extern vartype variable;


in the second you forgot to close the IF statement with a }

add id bfore the comments if you want to maintain pretty code


the error is at that line bcause its either the end of the class or right before another method

tophq 15-02-2004 13:59

Re: C Programming Question
 
yeah im using 2 different computers so i couldn't copy and paste it. i just typed it up at warp speed because i need to get this figured out before 4 today. there aren't any mistyped statements in the real code. and as for the answer you gave me for the first problem...thanks but i didn't need it anymore.

tophq 15-02-2004 14:43

Re: C Programming Question
 
does anyone else have any suggestions for a solution? like i said, i MUST get this down by 4 today. i've spent all yesterday (6+ hours) and now today (another 6+ hours) on this thing. our robot will be up and running very soon and i want to try to tweak the autonomous as much as possible and as of now, i can't even figure out how to create an autonomous mode. :(

tophq 16-02-2004 12:56

Re: C Programming Question
 
man...nm...i forgot to post it but i got the solution. pay no head to this thread now.


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

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi