Partial motor rotation

Im trying to advanced my skills and labview and up to this point i’ve been able to do most of what me and my team want with help from communities like this, so thank you! My next question is, is there a way that I can program a motor to go to this position when i hit this button. For example if i press button 1 can i make that rotate the motor 50% of the way or 1/2 a rotation then stop? I know when programming mindstorm items I can set it to rotate a percent, second or number of rotation but i’m looking for how to do that in FRC.

If you have an encoder you can easily command the motor to go whatever number of rotations you want. Without an encoder this will be very difficult to get repeatable accuracy (unless you are able to use some other sensor to indicate when travel is complete).

As a common trick question I’ll often ask FLL teams to name all the sensors they used on their robot. A handful have provided the complete answer: The motors themselves usually have built-in sensors to track the distance and speed.

Some FRC motors have similar sensors, some do not. Regardless, to do it well, you’ll probably need a sensor.

A very simple approach:
First, add a sensor (usually called an encoder) to track the number of rotations of the mechanism in question. Then, implement software which does the following:
–If you haven’t rotated enough, keep rotating
–If you’ve rotated enough, stop rotating.

There’s a number of other ways to do it - you’ll hear lots of terminology like “bang-bang”, “PID”, “Motion Profiling”…

You might find this series helpful - it’s not labview, but it does explain some of the concepts well.

Decide what sensor to use

There are a few types of sensors that may be applicable. To determine which is best requires some understanding of the mechanism you want to control. Here is a list of a few common sensors and appropriate applications.

Limit switches - An arm, elevator, claw, etc. that has only 2 target positions (i.e. setpoints). Also can and should be used along with or as a backup to other sensors.

Potentiometer - An arm, elevator, claw, etc. that may have 3 or more setpoints. Potentiometers give you the position they are turned to without needing to be reset everytime you turn your robot off and on. Potentiometers are analog and therefore have noisy signals which you may or may not need to filter.

Relative Encoder - Use to measure rotational speed (e.g. of a shooter) or relative position from a known point (e.g. arm or elevator). If using to measure position, you MUST consider that the encoder reading will allways be reset to 0 when you turn the robot off and on or restart the code. You can reset the reading manually at a later time but it is very easy for drive teams to forget. Instead put a limit switch at one end of the arm’s range and programatically reset the encoder reading whenever the limit switch is pressed.

Absolute Encoder - Similar use to potentiometers because they don’t reset on restart but require many more digital input channels than relative encoders. These are uncommon in FRC (in my experience) (disclaimer: I have not used absolute encoders).

If you need to control an actuator between two endpoints with no extra target positions in-between and no need to slow down when approching the endpoints, just use limit switches.
If you want more control, first use limit switches (as a failsafe) then use either a potentiometer or relative encoder depending on the aplication.

Please let us know what sensor you decide to use and why.

Mechanical sensor mounting tips (from a non-mecanical programmer):

Connect rotational sensors (potentiometers and encoders) directly to the arm, elevator or other mechanism itself, NOT to the motor, driving belts, chain or gearing. This way if there is any backlash (jiggle) between the motor and mechanism, the sensor will report the real position of the mechanism instead of the relatively unimportant position of the motor.

If the above tip cannot or is not followed and there is a chance that belts may skip, do not use a potentiometer or absolute encoder. Instead, use a relative encoder and reset the encoder reading regularly throughout matches using a limit switch.

You’ll want to implement PID (Proportional Integral Derivate) control using a rotation sensor, usually an “encoder”. Falcon and NEO brushless motors have built-in rotation sensors and have methods that will return the number of rotations.

Here’s a good video I refer people to for learning how PID works:

This type of control, position control, can also be done without using a PID. A chapter in the Secret Book of FRC LabVIEW talks about this. (Actually this is a PID with only a P term, with a clamped output, and a deadband on the error.)

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.