FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Inverting a Motor

Highlighted

Our team is controlling a motor with the XBox Left and Right trigger buttons. We are using LabView. We want one of the trigger buttons to have the motor turn one way and the other button have the motor turn theother way. The motor is capable of going in both directions as we have already tested. However, the motor is connected in a PWM port and thus we cannot define it two times (One regular and on inverted). I was wondering if there was a solution to being able to have one tigger control the motor one way and another control the motor another way??

0 Kudos
Message 1 of 2
(1,375 Views)

Hello Nick R1216,

You can determine the direction of a motor based on the value that you send to the PWM. For example, a +1 will make the motor rotate forward, and a -1 will make it rotate backward. However, you mentioned controlling the same PWM with two different triggers, and that may cause problems. Think about cases where both triggers are pressed, or non are pressed, or when you only press one trigger and not the other. Each trigger is always going to send a value to the PWM and the values will overwrite and you will be getting an indeterminate behavior. To avoid this, you have to create an action for every combination of trigger presses. A truth table can help you make sure that you have considered every case of trigger values. This requires checking multiple logic levels. For example, you may want to check if a trigger is pressed, and if not ignore that value, and check the other trigger.

The following snippet might give you an idea of how the checking might start. The code is incomplete, but you should be able to finish or alter it to you meet your needs.

I hope that this helps,

Regards.

Sal H.

Applications Engineering

National Instruments

Using two triggers for one motor.png

Sal H.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(937 Views)