MATLAB Answers

How do I program a servo to respond to two different buttons on the VEX Controller?

5 views (last 30 days)
How do I program a servo to respond to two different buttons on the VEX Controller such that one button turns it right and the other one turns it left?

Answers (1)

MathWorks Student Competitions Team
Edited: MathWorks Student Competitions Team on 11 Sep 2015
Above is a screenshot of an example model on how to achieve this behavior.
Typically, you would try to use two servo blocks with the same port number to respond to two different Gamepad Button blocks, but Simulink (in R2015a and R2015b) would error out that you cannot have two motor blocks linked to the same port (as shown below).
Thus the best possible workaround is to use an Add block to combine the values from the two Button blocks and sent them as input to the Servo block (as shown in the first image). This way it receives either 127, -127 or 0 at any given time. Note that the summation will, however, result in a 0 if both buttons are pressed at any given time though. So, the driver had to be careful about not pressing both buttons at the same time.
The above error message in Simulink, when two motor/servo blocks are lined to the same port, will be removed in a future release of the VEX Cortex Support Package and thus you will be able to use duplicates of blocks in your Simulink models.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by