Registered: 1475436752 Posts: 1
Reply with quote #1
We have been having a few issues while trying to get our robot's arm to move. We want to be able to make the arm turn counterclockwise and clockwise using two different gamepad buttons. Can anyone please help??
Registered: 1443021001 Posts: 112
Reply with quote #2
What have you tried so far? What software are you using?
edit: (Ah, Simulink forum) Something like " if up button pressed then set motor arm to +127; if dn button pressed then set motor arm to -127" should work if you use the right syntax for the software you are using. edit: There are probably examples of this in example simulink training library examples code. Start with up button make motor A turn clockwise. dn button make motor B turn counterclockwise. when you have that working, Then take away the motors A and B, join the stubs with ADD block, and set output to the Arm motor.
Registered: 1426724490 Posts: 59
Reply with quote #3
Here is adding to Joel's (jgraber) explanation. Take a look at the model below in Simulink. It shows how to use the buttons to control both a servo and a DC motor using game pad buttons. Two buttons are use to control the clockwise and counterclockwise rotation on each of the motors. The Latch block helps you to press the button and leave it to latch on to the rotate or no rotate state (for DC motor), or new position or original (0 degrees) position. The problem with this above model is that both button groups (5 and 6) feed to the same servo or DC motor. Thus, a motor will receive both signals from the buttons in the group (say 5up and 5dn) and will be confused as to which one to execute. To avoid this confusion, the simplest solution that you can use to fix this is as follow: - As Joel suggested, use an Add block to sum the inputs from both buttons and send the output to a single motor block. The assumption, however, here is that the buttons up and down may not be pressed simultaneously. If both are pressed then nothing will happen (because sum value of 100 and -100 will be 0). See image below.