Go to Post The JVN/Karthik segment should have more than enough spontaneity for everyone - Matt Krass [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 05-12-2007, 23:38
tommytalks tommytalks is offline
Registered User
no team
 
Join Date: Dec 2007
Location: Los Angeles
Posts: 1
tommytalks is an unknown quantity at this point
EasyC Vex Programming help in RC Mode

My son and I are quite new to Easy C, so your help is greatly appreciated.

We are now programming our vex bot for the FIRST Quad Quandary competition. Our basic setup works fine, but one of our functions works poorly if the motor goes too fast. We don't have room to gear it down any more than it is, so we're wondering if there is a way to program a speed limit into RC mode. As it is, it's a little too easy to overdo it with the joystick.

Also, is there a way to have the vex controller initiate a preprogramed sequence similar to autonomous mode?

thanks,

Nathan's Dad
  #2   Spotlight this post!  
Unread 06-12-2007, 07:14
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,854
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: EasyC Vex Programming help in RC Mode

This thread addresses making a motor respond more slowly:
http://www.chiefdelphi.com/forums/sh...ad.php?t=53643

You can use the buttons on the back of the transmitter to signal your code to start a sequence of commands.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #3   Spotlight this post!  
Unread 06-12-2007, 09:06
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: EasyC Vex Programming help in RC Mode

Quote:
Originally Posted by tommytalks View Post
...We don't have room to gear it down any more than it is,...
Dad,

Did you check out the worm gear in the advanced gear kit? it provides a 24:1 reduction in a very small package.

If you decide that you must slow down the motor in software, keep in mind that a DC motor reduces speed linearly with voltage but the power is reduced by the square of the voltage. In other words, you will also be reducing torque...

Depending on your application, the mechanical option may be best.

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...

Last edited by Mike Betts : 06-12-2007 at 09:13.
  #4   Spotlight this post!  
Unread 06-12-2007, 12:54
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: EasyC Vex Programming help in RC Mode

If your mechanism does not need a lot of power (see Mike's post), then you can limit the speed in software. First you would map the Rx Input to a variable. Since the values coming back from the transmitter range from 0 to 255, with 127 neutral, we subtract 127 so our values are now centered around 0. (Don't declare your variable as an unsigned char, use int here!)

The next step is to multiply our new value times a coefficient between 0 and 1. But since the controller only likes to play well with integers, if we want the motor to only go 60% of max speed, we can multiply ourVariable = ourVariable * 6 / 10; with replacing ourVariable with whatever you declared your variable as.

Then we add 127 back into this, and set this value to the motors. By adjusting the coefficient, you can narrow down or widen how much available speed you want to send to a motor.
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.
  #5   Spotlight this post!  
Unread 06-12-2007, 16:30
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: EasyC Vex Programming help in RC Mode

First of all, instead of just setting 60 in the code, wouldn't it be easier to #define it at the start of the code? That way if you want to change it, you can just change it there and don't have to fish for it in the rest of the code.

Code:
#define Percent_Speed 60 //defines the percent of max speed you want to go
The #define sets the value of Percent_Speed (the percentage of max speed you want). Since in this case it is set to 60, Percent_Speed is equal to 60 throughout the code.

Quote:
Originally Posted by artdutra04 View Post
(Don't declare your variable as an unsigned char, use int here!)
I'm assuming you're saying this to prevent overflow when you multiply the value by 6, and also so that you can go into negative numbers when you subtract 127

Instead of declaring an int and wasting memory, why wouldn't you just declare the variable as an unsigned short and typecast the variable during the operation?

Code:
unsigned short ourVariable;
declare the variable as an unsigned short
Assign it to your input(not shown here).

Code:
ourVariable = (((int)ourVariable - 127) * Percent_Speed / 10) + 127; //calculations
motor = ourVariable; //output ourVariable to motor.
If you change motor to whatever the motor you want to output to, the code will take ourVariable, which you have mapped to your input earlier in the code and typecast it into an integer for that operation only (see below). It will then multiply ourVariable by the percentage of your speed and divide by 10 to reduce the power to the percent you set in #define Percent_Speed, add your 127 back to get the value within the accepted range again, and set it to your motor. And yes, I realize I have a pair of unneeded parenthesis in the line, but I like grouping things that way.

Inserting (int) in front of ourVariable makes the program treat ourVariable as an integer for that operation (to give it room to perform the operation), but once the operation is done, ourVariable will return to a nice little unsigned char that doesn't hog memory.
__________________

Last edited by slavik262 : 06-12-2007 at 18:46. Reason: revisions
  #6   Spotlight this post!  
Unread 06-12-2007, 17:20
Chief Samwize Chief Samwize is offline
Registered User
AKA: Sam
FRC #0051 (Wings of Fire)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Pontiac, MI
Posts: 171
Chief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud of
Re: EasyC Vex Programming help in RC Mode

How sensitive is it to a joystick?

If you are working where you only want it to react to the joystick to a point then what you could do is the following ...

If GetRxInput (1,1) > Max Forward (you define)
SetMotor (1,Max Forward) - If joystick is pushed farther than desired position do not let motor go any faster

If GetRxInput (1,1) < Max Backwards (you define)
SetMotor (1,Max Backwards) - Same as above only backwards

Else
MotorRcControl (0,1,1,0) - Respond to joystick value to value (180 on Joystick= 180 to motor)


If you are Not using most of the joysticks movement before it gets out of hand then you could do the following ...

If GetRxInput (1,1) > 135 -Allow play in joystick
SetMotor (1,speed desired forward) - you define

If GetRxInput (1,1) < 120 -Allow play in joystick
SetMotor (1,speed desired backwards) - you define

Else
SetMotor (1,127)

This gives the motor only two speeds that it is allowed to run.

Hope that helps. If you have any questions about this feel free to PM me.

-Sam
  #7   Spotlight this post!  
Unread 06-12-2007, 17:29
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: EasyC Vex Programming help in RC Mode

That code is much easier to manage as well. The code for that would be:

Code:
#define Motor_Max (put your maximum value here)
#define Motor_Min (put your minimum value here)
#define statements go at the top of your code

Code:
if (GetRxInput(1,1) > Motor_Max)
SetMotor(1, Motor_Max); //Don't go any faster than your max

else if (GetRxInput(1,1) < Motor_Min)
SetMotor(1, Motor_Min); //Likewise, don't let the motor go slower than the min, regardless of what the joystick says.

else
SetMotor(1, GetRxInput(1,1)); //If the joystick is not above the max or below the minimum, assign it directly to the input.
Feel free to PM me as well.
__________________

Last edited by slavik262 : 06-12-2007 at 17:41.
  #8   Spotlight this post!  
Unread 06-12-2007, 17:36
Chief Samwize Chief Samwize is offline
Registered User
AKA: Sam
FRC #0051 (Wings of Fire)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Pontiac, MI
Posts: 171
Chief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud ofChief Samwize has much to be proud of
Re: EasyC Vex Programming help in RC Mode

Exactly

-Sam
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
Programming help. EasyC Vex Robot. OneCoolDude Programming 2 02-12-2007 17:54
Need help with ramping in VEX EasyC T. Maty Programming 4 03-11-2006 12:17
Arrays in Vex Programming Kit EasyC? gblake FIRST Tech Challenge 9 12-09-2006 17:05
EasyC-Vex Rx/motor frustrations- please help! Steve0100 Programming 10 08-07-2006 02:18
White Paper Discuss: VEX / intelitek easyC programming document dez250 Extra Discussion 3 15-09-2005 15:20


All times are GMT -5. The time now is 19:47.

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