Setting Motor Encoder "home" position

We use V5 C++ VCS.
We are trying to learn how to use the internal encoder on the V5 motor to control the tray height.
Our question is, how do we program so that the motor encoder knows where “0” dergrees of rotation is each time we turn the robot on without having to show it where it is?

In other words, where “home” is?

Well you see, the problem is when using the built in encoders, whatever position the tray is in before you turn the robot on will read as 0. So if the tray is all the way out before your turn the Brain on, then that’s the 0 position. If it’s all the way back before you turn the brain on, then that’s the 0 position. To overcome this, you really should use a potentiometer as it will always read the same values even if the robot is off. This way, you will be able to code this “home” by finding the desired potentiometer value and setting the robot to go there. And since these values are consistently updated, even when the robot is on, you can easily track the tray and the robot will know where it is at all times. (I say 0 position as both degrees and rotations will be read as 0)

Ok. Thank you. Is there a way to set a range in the code.
Example: motor spin @ 15% when angle is at 20-40%
motor spin @ 40% when angle is at 40%-60%

here is a section of our code:

    if(Controller1.ButtonUp.pressing())
    { 
        if(Potentiometer1.value ( percentUnits::pct ) >=21 ) 
    {
       Lift.spin(directionType::fwd,100,velocityUnits::pct); 
    }
        
        else if(Controller1.ButtonLeft.pressing())
    {
 
       Lift.spin(directionType::fwd,100,velocityUnits::pct); 
    }

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