Go Back   VEX Forum > Official Technical Support > UNOFFICIAL Tech Support - Ask the Community!

UNOFFICIAL Tech Support - Ask the Community! Community Members can provide UNOFFICIAL answers to Tech Support Questions.

Reply
 
Thread Tools
  #1  
Old 06-14-2007, 06:57 PM
MarkO's Avatar
MarkO MarkO is offline
Senior Member
 
Join Date: Aug 2006
Location: Albany, Oregon, USA, North Western Hemisphere, Planet Tera
Posts: 2,341
Images: 10
Responding to "torsi" on Thread " In Work: mlab / mcc variable usage problems."

Quote:
Originally Posted by torsi View Post

Ricky,

If you look down at the comment with your name on it you will get a description of the problem. Basically if I attempt to update the s_elapsed
or s_loop variables the initial value do not seem to be zero when loop starts

Thanks,
-Tom-

Code:
void User_Autonomous_Code(void)
{
    /* Initialize all PWMs and Relays when entering Autonomous mode, or else it
    will be stuck with the last values mapped from the joysticks. Remember,
    even when Disabled it is reading inputs from the Operator Interface.
    */
    pwm01 = pwm02 = pwm03 = pwm04 = 127;
    pwm05 = pwm06 = pwm07 = pwm08 = 127;
    pwm09 = pwm10 = pwm11 = pwm12 = 127;
    
    s_elapsed = 0UL;
    s_loop = 0UL;
    s_elapsed_start = 0UL;
    
    #ifdef ZI_MAIN_LOOP_LOGGING
    printf("entering autonomous mode loop(%04X): %d elapsed(%04X): %d\r", (char*)&s_loop, s_loop, (char*)&s_elapsed, s_elapsed);
    #endif
    
    while (autonomous_mode) /* DO NOT CHANGE! */
    {
        if (statusflag.NEW_SPI_DATA) /* 18.5ms loop area */
        {
            Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
            
            #ifdef ZI_MAIN_LOOP_LOGGING
            printf("completed getdata loop(%06X): %d elapsed(%06X): %d\r", (char*)&s_loop, s_loop, (char*)&s_elapsed, s_elapsed);
            #endif
            
            #ifndef ZI_HANDLE_ENCODER_TICKS
            HandleEncoderTicks();
            #endif
            
            #ifdef ZI_MAIN_LOOP_LOGGING
            printf("prior to putdata loop(%06X): %d elapsed(%06X): %d\r", (char*)&s_loop, s_loop, (char*)&s_elapsed, s_elapsed);
            #endif
            
            Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
            
            #ifdef ZI_MAIN_LOOP_LOGGING
            printf("completed putdata loop(%06X): %d elapsed(%06X): %d\r",(char*)&s_loop, s_loop, (char*)&s_elapsed, s_elapsed);
            #endif
            
            PrintWord(s_loop);
            PrintWord(s_elapsed);
            
            // Ricky: If I include these line in the code the initial values of
            // of s_elapsed and s_loop do not seem to be zero from the
            // logging. But if I comment these lines out compile and run the
            // values do seem to be zero from the logging output.
            s_elapsed = s_elapsed + 18UL;
            s_loop++;
        }
    }
}
First: The printf() support on the Vex is limited it what it can handle for data values.. Float and Double (Float) are not supported.

Second: IIRC you would need to modify your
printf() formatting for long ints, by adding the 'l' to your '%x' format.

Third: printf() does not expect the '&' in front of each variable. You are going to be "passing" the Memory Location of each of your variables to the printf() function, not the Value of each of your variables.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 01:01 AM.


VEX and VEX Robotics are trademarks or service marks of Innovation First International, Inc.
Copyright © 2002-2013. All Rights Reserved. VEX Robotics, Inc. is a subsidiary of Innovation First International, Inc.
All other product names/marks of others are the property of their respective owners.