Hi there. I'm in a PLTW run course that utilizes the vex cortex along with the metal vex kits. I was wondering if it were possible to code non-sequentially. I've been tasked to design an elevator that uses three bump switches as call signals to make a motor move a platform up and down. When I code it, even after putting each function in it's own while loop with different sensor values, it still wants me to press each button in sequence. Here's an example of one of the codes for a single floor.

For above, I would have to hit floor two, wait for it to reach floor two, and then manually reset the elevator to floor 3 to then press the floor one button to get it to work. Is it even possible to change this?

Tue Mar 05, 2013 11:54 pm

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Coding Non-Sequentially

Could you post your entire code please? Thanks.

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

In the future, use the code tabs to make your code easier to understand. I'll try to work this out!

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

Thu Mar 07, 2013 6:37 pm

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Coding Non-Sequentially

Could you tell me the expected sensor values for each floor?

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

Thu Mar 07, 2013 6:43 pm

DeskLamp

Rookie

Joined: Tue Mar 05, 2013 11:44 pmPosts: 4

Re: Coding Non-Sequentially

Sure.

Floor one is precisely eight centimeters.

Floor two is about twelve to fourteen given the coasting on the elevator. (I had to replace a track because of a physical catch that would stop the elevator even at 127 motor power. With the new track it runs muuch smoother.)

Floor three is above nineteen centimeters.

I should be able to fiddle with these if they aren't quite on point. Thanks!

Thu Mar 07, 2013 6:54 pm

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

Re: Coding Non-Sequentially

What about limit and quad?

Also, do you want to be able to move to any floor from any other floor?

Sorry, but the more questions I ask, the more likely it is I will be able to help you.

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

Thu Mar 07, 2013 7:44 pm

DeskLamp

Rookie

Joined: Tue Mar 05, 2013 11:44 pmPosts: 4

Re: Coding Non-Sequentially

No problem! I'm the same way with questions. I haven't actually figured out how to use the quad, and i'm not sure it's necessary to use it anyway. The limit switch is on floor three. And yes, the objective is to be able to move from any floor to any floor. Please fill me in on what you do so I can learn to do it myself

Thu Mar 07, 2013 11:02 pm

Coder A

Moderator

Joined: Thu Jan 03, 2013 5:10 pmPosts: 207Location: The plateau north of the Ohio River Valley, also known as Cave Country.

while(floor1button is not pressed and floor3button is not pressed){DO NOTHING} if(floor1button is pressed) go_to_floor1from2(); else go_to_floor3from2();

break;

case floor3;

while(floor1button is not pressed and floor2button is not pressed){DO NOTHING} if(floor1button is pressed) go_to_floor1from3(); else go_to_floor2from3();

break; } }}

You need to fill in the go_to_floorxfromx() functions with the commands that work. Also, these commands should write the new currentfloor value to it, so that when the switch runs again, it enters the correct block.

The reason this code works is that the switch enters the block for the current floor and waits for a button on another floor to be pressed, then goes to that floor and exits the switch to loop again.

I changed the 1==1 in the loop to true, as this just saves a compiler step and is easier to understand. Any always true statement works.

Finally, note that I used no multitasking, as it was not needed, and adding it would only cause confusion.

Tell me if this helps!

_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robot

Who is online

Users browsing this forum: No registered users and 2 guests

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