shiremath
buttons2servo.png 

Please see above the screenshot of an example model of how to do this.

Typically, you would try to use two servo blocks with the same port number to respond to two different Gamepad Button blocks, but Simulink (2015) would error out that you cannot have two motor blocks linked to the same port (as shown below).

buttons2servo_error.png

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 in Simulink, when two motor/servo blocks are lined to the same port, will be removed in a future release of Simulink and thus you will be able to use duplicates of blocks in your Simulink models. 


 

Quote 0 0