Setting Positions with Smart Motors

I am programming an autosorter for my robotics team and I have a question. So it is a revolver design so is there anyway to use encoders in the smart motors to track its position. For example, if the color of the ring is green, then turn to position 90 and then turn to back to starting position. I want it to remember the points rather than it just turning 90 degrees. Let me know if you need more clarification about this. Thank you!

If you could provide the code you are starting with, that would be a plus.

In RobotC this is pretty easy and can be done in graphical. SetMotorTarget will tell the motor to go to a set position regardless of where the motor currently is.

Be sure that you put the menu level to super user or it will be hidden from view.

No matter what language you are using, you really need to go through the manual and read about the commands so you are aware of what the program is capable of!

Which language are you using?

You can rest the motor’s rotation then record the angle.

However, my experience is this type of controlled motion is not very accurate.

I get different results between starting the movement from a neutral position vs from a “rockbottom” position – for example, when lift an arm, the final position is different if I leave the arm to start from the bottom, then enable motor hold position, lift up 60 degrees vs. forcing the arm down to the bottom (with tension inside the motor), then do a 60 degree lift. The second method turns out to lift more than the first. I think it may have to do with the internal brake.

Depending on your gear settings, it probably won’t matter for your revolver design.

komanduriab~

As above, I am not sure of your programming language or what you have tried. However, here are a few ideas:

If you simply want to use a command like MOVE TO GREEN, you could use a variable. If the variable is set to the precise degree rotation needed to drop a part in the green bin, then you should be able to instruct to motor to spin to GREEN degrees.

Often, with this kind of setup, I find that the guesswork is in establishing the zero-position.

Here is a simple fix I sometimes use in Modkit to establish zero:

  1. Build your moving part with a defined range of motion (at least on one end) so that some part of your structure acts as a block, or, for lack of a better term, a stopper to the moving part.
  2. On startup, pause the larger program to run a mini calibration program for the desired motor.
  3. Reduce motor power to 5-10% and speed to around 10-15 % for that motor and rotate it in the direction of the stopper.
  4. Set a time-out for n seconds to make sure that the part has come into contact with the stopper.
  5. Stop the motor.
  6. Reset the rotation to zero degrees.
  7. Reset the power level to the desired value.
  8. Initiate the larger program

With regards to saltshaker’s comments, you may need to try steps 5 and 6 with holding turned off and then again with it turned on to see which option gives you the more consistent result.

I used this method to set the position of a launch arm for one of my bots, and it worked great. Combining this method with a gear ratio of 1:3, for example, should get you accuracy of about 1/3 of a degree! Feel free to check out the example below:

http://www.vexiqforum.com/forum/main…rble-challenge

Best of luck!

~Vexatron

One last thought: If speed is not an issue, reducing overall motor speed will sometimes increase accuracy with regard to the internal break.