Go to Post This place is much brighter than most institutions I have seen. It also seems to be lacking straight jackets which I think is a mistake for many of us. - Andrew Schreiber [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 02-11-2006, 11:07
T. Maty T. Maty is offline
Registered User
#1611 (Mustangs)
Team Role: Webmaster
 
Join Date: Mar 2005
Rookie Year: 2003
Location: Guyton, Ga.
Posts: 3
T. Maty is an unknown quantity at this point
Need help with ramping in VEX EasyC

We're trying a "For" loop and are having problems having both wheels to begin ramping. Can we insert both motors in the same "For" loop or do we have to use two "For" loops to have both motors ramp. After writing the program and trying to compile, we get an error[yy] message. This is our "For" loop statement below, and the line we receive our error in. Is this close or are we way off? Our goal is to use incrementing ramping to have the robot move in a straight line. Are we using the correct loop for using both wheels?

for ( step1 = 0 && step2 = 255 ; step1 < 127 && step2 > 127 ; step1 += 5 && step2 += 5 )

Team1611
South Effingham High School
Georgia
  #2   Spotlight this post!  
Unread 02-11-2006, 17:27
divergentdave divergentdave is offline
Registered User
FRC #1816 (Green Machine)
 
Join Date: Jun 2006
Rookie Year: 2007
Location: MN
Posts: 35
divergentdave is a jewel in the roughdivergentdave is a jewel in the roughdivergentdave is a jewel in the rough
Send a message via AIM to divergentdave
Re: Need help with ramping in VEX EasyC

Try this
Code:
 for ( step1 = 0, step2 = 255 ; step1 < 127 && step2 > 127 ; step1 += 5, step2 += 5 )
I may have my languages confused, but that should work. Earlier you were trying to use a short circuit logic operator, which doesn't always evaluate the right hand side. For example, assigning 0 to step1 also returns a 0, and the 0 gets passed to the && operator, which then interprets 0 as false, and thus doesn't even execute step2 = 255. Separating your two statements with commas explicitly tells the compiler to run both.
__________________
Team 1816 - The Green Machine
  #3   Spotlight this post!  
Unread 03-11-2006, 09:20
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Need help with ramping in VEX EasyC

The last example will solve the compile problem, but now I think you need to fix your logic.

for ( step1 = 0, step2 = 255 ; step1 < 127 && step2 > 127 ; step1 += 5, step2 += 5 )


If you want the motors to ramp from stopped to maximum speed in steps of 5, the statement would need to change to:

for ( step1 = 127, step2 = 127 ; step1 < 255 && step2 > 0 ; step1 += 5, step2 -= 5 )

You also need to consider that the system (the robot and motors) will not respond instantaneously to changes in pwm values. There needs to be some kind of delay between each new set values that are sent to the motors.


If step1 and step2 are unsigned char variables, there is also an issue with the increment/decrement by 5. The variables will wrap when the increment takes the value beyond 255 or the decrement takes the value beyond 0. It will take three passes before the for loop will end. Run the example below to see the problem:

#include "Main.h"

void main ( void )
{
unsigned char step1 = 127;
unsigned char step2 = 127;

PrintToScreen ( "Starting\n" ) ;
for ( step1 = 127, step2 = 127 ; step1 < 255 && step2 > 0 ; step1 += 5, step2 -= 5 )
{
PrintToScreen ( "Value of step1 is: %d\n" , (int)step1 ) ;
PrintToScreen ( "Value of step2 is: %d\n" , (int)step2 ) ;
}
PrintToScreen ( "Finished\n" ) ;
}


To address this problem:
Change increment/decrement to 1 or
use signed short instead of unsigned char and make sure that the value sent to the motors is within the range of 0 to 255.
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010

Last edited by charrisTTI : 03-11-2006 at 12:15.
  #4   Spotlight this post!  
Unread 03-11-2006, 11:30
T. Maty T. Maty is offline
Registered User
#1611 (Mustangs)
Team Role: Webmaster
 
Join Date: Mar 2005
Rookie Year: 2003
Location: Guyton, Ga.
Posts: 3
T. Maty is an unknown quantity at this point
Thumbs up Re: Need help with ramping in VEX EasyC

Thank you for your help, it worked great.

Team 1611

Quote:
Originally Posted by charrisTTI
The last example will solve the compile problem, but now I think you need to fix your logic.

for ( step1 = 0, step2 = 255 ; step1 < 127 && step2 > 127 ; step1 += 5, step2 += 5 )


If you want the motors to ramp from stopped to maximum speed in steps of 5, the statement would need to change to:

for ( step1 = 127, step2 = 127 ; step1 < 255 && step2 > 0 ; step1 += 5, step2 -= 5 )

You also need to consider that the system (the robot and motors) will not respond instantaneously to changes in pwm values. There needs to be some kind of delay between each new set values that are sent to the motors.
  #5   Spotlight this post!  
Unread 03-11-2006, 12:17
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: Need help with ramping in VEX EasyC

Quote:
Originally Posted by T. Maty
Thank you for your help, it worked great.

Team 1611

See the addtional information in my edit of the original post. I added the information earlier, but the update was lost.
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
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
Help needed with coding simultaneous movement (EasyC/VEX) bodaciousllama Programming 7 14-08-2006 17:35
EasyC-Vex Rx/motor frustrations- please help! Steve0100 Programming 10 08-07-2006 02:18
Speed Ramping with Deadzone Dan894 Programming 11 20-01-2006 14:04
Kickoff easyC workshop integrated into EasyC help file Dan Larochelle Programming 0 11-01-2006 06:12
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46


All times are GMT -5. The time now is 20:46.

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