View unanswered posts | View active topics It is currently Mon Jul 28, 2014 12:14 am






Reply to topic  [ 8 posts ] 
Programming beginner needs major help! 
Author Message
Rookie

Joined: Mon Mar 04, 2013 10:52 am
Posts: 8
Post Programming beginner needs major help!
The robot is to move via remote, in tank mode.
has an arm that goes up and down (one motor)
has a claw that closes (one motor)
4 motors total. I want to run the arm and the claw off the channel 5 and 6 buttons on the back of the controller.
I have posted my program, why is it not working, and what can I do to fix it?
please help we have a competition on thursday!


Attachments:
bomb extractor start.c [3.16 KiB]
Downloaded 180 times
Mon Mar 04, 2013 11:56 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 556
Post Re: Programming beginner needs major help!
Code:
while(1 == 1)
  {
    //Driving Motor Control
    motor[leftMotor] = vexRT[Ch3] / 2;
    motor[rightMotor] = vexRT[Ch2] / 2;
  }


Looking at the posted code, when exactly will the while loop's condition become false (or, when will 1 not equal 1?) and the rest of the code execute? Any time you have an opening bracket on a conditional statement, you will need a closing bracket to 'encompass' all of the code you wish to execute within that statement.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Mon Mar 04, 2013 12:00 pm
Profile
Rookie

Joined: Mon Mar 04, 2013 10:52 am
Posts: 8
Post Re: Programming beginner needs major help!
whatt eacxtly do you mean? this becomes untrue when the controller joysticks are in a neutral position. I am not entirely sure how that would be written.


Mon Mar 04, 2013 4:58 pm
Profile
Rookie

Joined: Mon Mar 04, 2013 10:52 am
Posts: 8
Post Re: Programming beginner needs major help!
JohnWatson wrote:
Code:
while(1 == 1)
  {
    //Driving Motor Control
    motor[leftMotor] = vexRT[Ch3] / 2;
    motor[rightMotor] = vexRT[Ch2] / 2;
  }


Looking at the posted code, when exactly will the while loop's condition become false (or, when will 1 not equal 1?) and the rest of the code execute? Any time you have an opening bracket on a conditional statement, you will need a closing bracket to 'encompass' all of the code you wish to execute within that statement.



when i run the debug for the code, it gets stuck in that loop, with the controller sticks since i added that bracket. and when it is not connected the motors do not move, do i need to put in something with speeds at certain conditions? its been 4 years since I did any of this from scratch. we have this competition this wednesday. so I have tonight and tomorrow night to get this code to work, also we maybe adding another motor and make the arm a double hinge. and help you could give me would be amazing, and I really do appriecate this

Leigh


Mon Mar 04, 2013 5:16 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 556
Post Re: Programming beginner needs major help!
You may want to look through the Video Curriculum Trainer for the VEX Cortex. Specifically, you will want to look through the 'Remote Control' sections that explains the code that specifically pertains to remote control operation.

For this specific code example, the while loop is still the problem. Remember, a loop will continue running the code that is 'contained' inside of its opening and closing brace set {} while its condition is true:

Code:

while (1 == 1) //The code in between the next set of { and } will run while 1 is equal to 1
{ //Opening brace for the while loop

//Any code placed in here, between the opening and closing brace, will run while 1 is equal to 1. Since 1 will always equal 1, this code will run indefinitely; the loop will never 'exit' to the other portions of code

} //Closing brace for the while loop

//Any code placed outside of the while loop will not reach since 1 will always equal 1; the condition never becomes false, and the code never stops looping.



If you wish to run the entire program continually, you will need to place all of the code inside of the while loop's {} braces. This will make sure that each command is executed upon each pass through the loop.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Mon Mar 04, 2013 5:29 pm
Profile
Rookie

Joined: Mon Mar 04, 2013 10:52 am
Posts: 8
Post Re: Programming beginner needs major help!
ok I understand that much now. When I run the debugger, the robot now constantly runs the arm and claw motors. and when it is unplkugged it does not respond to my controller. this is so frustrating!


JohnWatson wrote:
You may want to look through the Video Curriculum Trainer for the VEX Cortex. Specifically, you will want to look through the 'Remote Control' sections that explains the code that specifically pertains to remote control operation.

For this specific code example, the while loop is still the problem. Remember, a loop will continue running the code that is 'contained' inside of its opening and closing brace set {} while its condition is true:

Code:

while (1 == 1) //The code in between the next set of { and } will run while 1 is equal to 1
{ //Opening brace for the while loop

//Any code placed in here, between the opening and closing brace, will run while 1 is equal to 1. Since 1 will always equal 1, this code will run indefinitely; the loop will never 'exit' to the other portions of code

} //Closing brace for the while loop

//Any code placed outside of the while loop will not reach since 1 will always equal 1; the condition never becomes false, and the code never stops looping.



If you wish to run the entire program continually, you will need to place all of the code inside of the while loop's {} braces. This will make sure that each command is executed upon each pass through the loop.


Mon Mar 04, 2013 6:06 pm
Profile
Rookie

Joined: Mon Mar 04, 2013 10:52 am
Posts: 8
Post Re: Programming beginner needs major help!
ok robot runs successfully. I followed the instructions for the buttons to run my arm and claw. exactly as they said the arm and claw should move. BUT they do not move correctly. I have ports 6 and 7 for the motors, and channels 5 and 6. the code should work, I followed the tutorial perfectly...
please help
JohnWatson wrote:
You may want to look through the Video Curriculum Trainer for the VEX Cortex. Specifically, you will want to look through the 'Remote Control' sections that explains the code that specifically pertains to remote control operation.

For this specific code example, the while loop is still the problem. Remember, a loop will continue running the code that is 'contained' inside of its opening and closing brace set {} while its condition is true:

Code:

while (1 == 1) //The code in between the next set of { and } will run while 1 is equal to 1
{ //Opening brace for the while loop

//Any code placed in here, between the opening and closing brace, will run while 1 is equal to 1. Since 1 will always equal 1, this code will run indefinitely; the loop will never 'exit' to the other portions of code

} //Closing brace for the while loop

//Any code placed outside of the while loop will not reach since 1 will always equal 1; the condition never becomes false, and the code never stops looping.



If you wish to run the entire program continually, you will need to place all of the code inside of the while loop's {} braces. This will make sure that each command is executed upon each pass through the loop.


Mon Mar 04, 2013 9:04 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 556
Post Re: Programming beginner needs major help!
Please try to keep the conversation to one thread, as splitting it across multiple threads will generally only create confusion. From the code posted on this side thread, the code looks correct as far as I can see; there may be a wiring issue or joystick connection issue. I highly suggest going through all of the Curriculum Video Trainer sections, as they walk through the entire coding process step-by-step and will help you immensely in the programming process.

Also, are you using the VEX PIC with this:

Image

or the VEX Cortex with this:

Image

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Mar 05, 2013 2:42 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.