Go to Post The theory is we'd lose a paper list but we haven't lost a student yet. - Peter Matteson [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 09-08-2006, 19:41
bodaciousllama bodaciousllama is offline
Registered User
no team
 
Join Date: Aug 2006
Location: SoCal
Posts: 3
bodaciousllama is an unknown quantity at this point
Help needed with coding simultaneous movement (EasyC/VEX)

(I really had no idea what to title this thread, but I tried)

Hi,

I was introduced to VEX robots today in a robotics camp that I am taking at a local community college, and enjoyed myself. When school starts again, I am going to propose a FIRST Challenge team to the science/math department.

Anyway, my question lies in programming with the EasyC software. What my aim was, was to have remote control of the robot while a servomotor ran, autonomously (if thats the correct term).

Basically, I couldn't get it to work. Either the servo would run, or the remote control would work, but not both at the same time. The way I coded it was by putting both in a "while 1 == 1" loop.

So, if anyone has EasyC experience and can help, it would be appreciated. Even if you know how it's done in other programs, anything would be helpful. Even some key terms to search for would be helpful because, like I said, I have no idea what the term to search for is.

Thanks,
Ravi
  #2   Spotlight this post!  
Unread 09-08-2006, 19:46
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,671
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Help needed with coding simultaneous movement (EasyC/VEX)

It would help if you could clarify what you want the servomotor to be doing autonomously. Moving back and forth like a clock, stabbing someone's finger if they push a bumper button, etc. I've got a little experience getting EasyC to move one back and forth and I don't think it shold be too complicated getting it to do whatever you'd like it to.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #3   Spotlight this post!  
Unread 09-08-2006, 19:52
bodaciousllama bodaciousllama is offline
Registered User
no team
 
Join Date: Aug 2006
Location: SoCal
Posts: 3
bodaciousllama is an unknown quantity at this point
Re: Help needed with coding simultaneous movement (EasyC/VEX)

basically what i'm trying to do is make the servo move like a clock pendulum, back and forth through the entire range of movement

i want it to start when the vex module is turned on, but if there is any way to link it to run whenever the robot is being actively controlled (i.e., the controls are being manipulated), that would be great, although it seems like it would be very complicated

btw we're using the tank 2-motor "block" (i guess thats what you'd call it) to control the robot's movement.
  #4   Spotlight this post!  
Unread 09-08-2006, 20:08
AdamHeard's Avatar
AdamHeard AdamHeard is offline
Lead Mentor
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Atascadero
Posts: 5,506
AdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond reputeAdamHeard has a reputation beyond repute
Send a message via AIM to AdamHeard
Re: Help needed with coding simultaneous movement (EasyC/VEX)

When you mean "actively controlled" do you mean you are driving it, or wether or not the remote is on.

For back and forth you could set an integer to 1 or 0. If the integer equaled 1, it would count up to 255, and when the servo hit 255, the integer would be switched to 0 and cause it to count down back to a servo value of 0, where the integer would be set back to 1 and count up again... repeating...(use ++ and --)

If you wanted this to go just when the robot is being driven (as in currently moving), use an if statement to check the joystick values (if they aren't centered, you know its being driven)
  #5   Spotlight this post!  
Unread 09-08-2006, 20:18
bodaciousllama bodaciousllama is offline
Registered User
no team
 
Join Date: Aug 2006
Location: SoCal
Posts: 3
bodaciousllama is an unknown quantity at this point
Re: Help needed with coding simultaneous movement (EasyC/VEX)

yes, by actively controlled i mean that it is being moved around.

so basically it will just sit there, and then when someone moves the robot, the servo will start moving, and when the robot stops moving, the servo stops


so cromat, how would i check the joystick position? is it just a 1 or 0 check, or is it more complicated

EDIT - and as for

Quote:
For back and forth you could set an integer to 1 or 0. If the integer equaled 1, it would count up to 255, and when the servo hit 255, the integer would be switched to 0 and cause it to count down back to a servo value of 0, where the integer would be set back to 1 and count up again... repeating...(use ++ and --)
i really have no idea how to even do that.

the manual that came with the program, or at least the one we recieved, was way too basic.
  #6   Spotlight this post!  
Unread 09-08-2006, 20:23
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,671
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Help needed with coding simultaneous movement (EasyC/VEX)

Alrighty. First off, it should automagically not move when the RC is off or unconnected. I believe everything goes to neutral and center when the RC is off unless autonomous is enabled. At any rate, your options are to use a timer based solution or some kind of pseudo-loop.

Timer:
start a timer at the beginning of your program before the while loop.
get its value every while loop and assign it to "time" for instance.
toss in an if statement and make the condition time > ### (however many milliseconds you want between swings one side to the other)
inside that if one, preset the timer back to 0, then set the servo PWM to one way or another. use an if-else and have it based on which way the servo currently is.
This will work and is basically how I was timing the movement of my slapdash ball chambering servo. The problem I was have was that my code took forever to get through the while (1) loop. about 200 ms. so I couldn't look for time slices smaller than that. Which frustrated my attempts to shoot balls as fast as possible.

Pseudo-for loop:
have a variable called "i" put an assignment for i=(i+1)%## in your while loop. ## is the number of loops through your while loop before it rolls over, so it's the period.
put in if i == whatever statements and set the servo PWM here.
advantage of this, is you can make it move to intermediate positions at every value of i. disadvantage is I've no idea what the timing of that while(1) loop is, so you'll be sort of guessing how fast it's going.

EDIT:
Using that idea above, to modify the two loops I've suggested:
Timer: Stop the timer if the robot's not moving, start the timer if the robot is moving.
Pseudo: put an if statement around the assignment, so it only runs if the robot is running.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter

Last edited by Kevin Sevcik : 09-08-2006 at 20:30.
  #7   Spotlight this post!  
Unread 11-08-2006, 09:20
intellec7's Avatar
intellec7 intellec7 is offline
108 programmer
AKA: Gustavo
FRC #0108 (SigmaC@ts)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2006
Location: Hollywood, Florida
Posts: 65
intellec7 is on a distinguished road
Send a message via AIM to intellec7 Send a message via MSN to intellec7
Re: Help needed with coding simultaneous movement (EasyC/VEX)

I have attached code that *should* work. You will probably need to modify all of the Rx inputs and PWM outputs.
If any one sees a problem with this code, you are probably right . :-D
BTW there is no overflow protection, which might happen, but I am assuming you don't need really precise servo control? When you stop moving the robot the servo stops in place, but when you start moving it again, the servo moves to its positive limit and then starts the back and forth movement again.
Attached Files
File Type: pdf code_example.pdf (24.0 KB, 63 views)
  #8   Spotlight this post!  
Unread 14-08-2006, 17:35
CircularLogic CircularLogic is offline
Registered User
FRC #1546 (Chaos Inc)
Team Role: Leadership
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Baldwin
Posts: 38
CircularLogic will become famous soon enoughCircularLogic will become famous soon enough
Re: Help needed with coding simultaneous movement (EasyC/VEX)

Quote:
Originally Posted by intellec7
I have attached code that *should* work. You will probably need to modify all of the Rx inputs and PWM outputs.
If any one sees a problem with this code, you are probably right . :-D
BTW there is no overflow protection, which might happen, but I am assuming you don't need really precise servo control? When you stop moving the robot the servo stops in place, but when you start moving it again, the servo moves to its positive limit and then starts the back and forth movement again.

Yea, there appear to be some syntactical (things written wrong) and symantical (things done wrong). The simplest thing is that the incrementing and decrementing (is that a word?) of pendu_speed dont really do what they are supposed to. Instead incrementing or decreasing you assign the value of 1 or -1 to pendu_speed. It should be pendu_speed++ or pendu_speed--.

The next problem is with this statement

pendu_servo = pendu_speed + pendu_servo

the value of pendu_servo could be 250 in one loop and the next time around, the joystick could be nuetral but because pendu_servo already has the value of 250, it will continue to be 250.


You could probably fix that by moving the code block setPwm(3, pendu_servo) into the else statement. Then change the if statement to to setPwm(3,127). That way the if the statement evaluates to true (meaning joystick is nuetral), the pwm will be dead. However, if it evaluates falsely, it will be assigned to a value.




And in terms of the actual servo movement, I cant really help because I have actually never worked with servos.



And my *corrections* of your mistakes could also be mistakes.
__________________
Team 1546 Chaos Incorporated
2005- SBPLI Rookie All Stars
2006- SBPLI Sportsmanship award.

Gotta hand it to the straight line autonomous mode, the most effective defense out there.

Proud beyond belief of the accomplishments of the second year, 20th ranked, 6 wins and 6 losses Chaos Incorporated.
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
EasyC-Vex Rx/motor frustrations- please help! Steve0100 Programming 10 08-07-2006 02:18
HELP needed, problem with streamling, need uploading space or diffrent solution... Nimmy General Forum 5 15-02-2006 11:18
Help needed with finding stud terminal block from KOP amirjpl Electrical 11 25-01-2006 19:32
Kickoff easyC workshop integrated into EasyC help file Dan Larochelle Programming 0 11-01-2006 06:12
NEED HELP WITH CAMERA MOVEMENT nm4 Programming 3 10-02-2005 17:17


All times are GMT -5. The time now is 04:00.

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