How to program two buttons to control the same motor.

Hello! we were trying to program two buttons to control a CIM motor. one button gives the motor a value of 1, and the other gives the motor a value of 0.6. every time that we push the first button, it moves perfectly. however, when we push the second button, it stutters, and spins ridiculously slow. we know that it is not the number because on another test with the same values, the button that gives the motor a value of 0.6 works and the motor spins at 60% of the original speed. the other button is now the one that stutters or sometimes doesnt run at all. if anyone can help, we would really appreciate it.

Thanks!

It sounds like your implementation is causing multiple (different) values to be set to the motor during one iteration of your code.

You’ll also want to determine which button you want to have priority (if both are pressed, what speed do you want the motor to spin at?). Then, you can either use a case structure or two select nodes to choose the motor speed, which you would then wire into a motor set VI. Try and write the code so that there’s only one instance of the Motor Set VI controlling the motor.

*http://www.chiefdelphi.com/forums/attachment.php?attachmentid=11937&d=1329451162

To add some background to what the above posters said, it sounds like you used two different motor set output VIs for the same motor. The code resulted in one being supplied with a 0 value, and the other with a 1 or 0.6. This will cause it to rapidly stop and start (in a matter of milliseconds) giving it the “sputtering” effect you described.

When controlling a motor, its always best to have a single “Motor Set Output” VI per motor, and manipulating the number being input into the VI through code such as Ether provided. If you stick to this simple rule of thumb of only one VI per motor, you’ll never have two values “fighting” each other and giving this effect.

You can use the “Highlight Execution” button in Labview (the icon with the lightbulb) and run your code to literally watch what happens in slow motion. This is a pretty handy debugging tool.