View unanswered posts | View active topics It is currently Sun Apr 20, 2014 11:53 am






Reply to topic  [ 5 posts ] 
Closed Loop or Encoder????? 
Author Message
Rookie

Joined: Wed Nov 28, 2012 4:49 pm
Posts: 2
Post Closed Loop or Encoder?????
What can I do if I dint want my robots arm to rotate 360 just 180. I have an encoder on it but I was trying to put a closed loop in my program. Is an encoder the same as a closed loop or is a closed loop better? Can someone please help??


Wed Nov 28, 2012 5:10 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 534
Post Re: Closed Loop or Encoder?????
Hello Jugga-bot,

We will need a bit more information before we are able to help you with this particular question. For instance, are you using a motor or a servo to control the arm? Would you be able to post the code here using the [code][/code] tags so we can look through it for potential issues? The more information you are able to provide us with, the better we will be able to assist you.

Thank you

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Wed Nov 28, 2012 6:37 pm
Profile
Rookie

Joined: Wed Nov 28, 2012 4:49 pm
Posts: 2
Post Re: Closed Loop or Encoder?????
we are using a motor it is motor F
Code:
  motor[ArmUpDown] = 0;                        // Motor F is stopped with a powere level of 0.
    }
    if(abs(joystick.joy1_x1) > threshold)          // If the left analog stick's Y-axis readings are either above or below the threshold:
    {
    motor[ArmRotation] = (joystick.joy1_x1)/3;   // Motor G is to rotate arm clockwise
    }
    else                                           // Else if the readings are within the threshold:
    {
      motor[ArmRotation] = 0; // Motor G is stopped with a powere level of 0.



Is this what you mean by code?


Wed Nov 28, 2012 7:03 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1343
Post Re: Closed Loop or Encoder?????
It is very similar to the code I posted on this thread:
viewtopic.php?f=1&t=5183
Note that this code is assuming the LEGO motor encoder that has 360 clicks per revolution. If you have a Tetrix motor with an encoder that has 1440 clicks per revolution or if you have any gear up/down, you need to determine the ARM_MAX_ANGLE appropriately.
Code:
#define DEADBAND_THRESHOLD 15
#define DEADBAND(x) ((abs(x) >= DEADBAND_THRESHOLD)? x: 0)
#define BOUND(x) (((x) > 100)? 100: ((x) < -100)? -100: (x))
#define JOYSTICK_POWER(x) (BOUND(DEADBAND(x)))

#define ARM_MIN_ANGLE 0
#define ARM_MAX_ANGLE 180

task main()
{
    //Assume the arm is at min angle when start.
    nMotorEncoder[armRotMotor] = ARM_MIN_ANGLE;
    while (true)
    {
        //
        // Get joystick readings.
        //
        getJoystickSettings(joystick);

        //
        // Translate controller 2 right stick x axis value to within motor power range (-100 to 100) and with deadband.
        //
        int armRotPower = JOYSTICK_POWER(joystick.joy2_x1)/3;

        //
        // Read the current arm angle.
        //
        int armAngle = nMotorEncoder[armRotMotor];

        //
        // Only allow the motor to move if we are within limits.
        //
        if ((armRotPower > 0) && (armAngle < ARM_MAX_ANGLE) ||
            (armRotPower < 0) && (armAngle > ARM_MIN_ANGLE))
        {
            motor[armRotMotor] = armRotPower;
        }
        else
        {
            motor[armRotMotor] = 0;
        }
        wait1Msec(100);
    }
}


Wed Nov 28, 2012 7:16 pm
Profile
Rookie

Joined: Thu Apr 18, 2013 2:29 am
Posts: 1
Post Re: Closed Loop or Encoder?????
In general open loop control means that you send electrical signals to an actuator to perform a certain action, like connecting a motor to a battery for example. In this scheme of control, there is no any mean for your controller to make sure the task was performed correctly, and it often need human intervention to obtain accurate results. A very simple example of open loop control, is the remote controller of an RC toy car; you – the human – have to constantly check the position and the velocity of the car to adapt to the situation and move the car to the desired place.

But what if you could let the electronics handle a part, if not all of the tasks performed by a human in an open loop controller, while obtaining more accurate results with extremely short response time? This what is called closed loop control. In order to be able to build a closed loop controller, you need some mean of gaining information about the rotation of the shaft like the number of revolutions executed per second, or even the precise angle of the shaft. This source of information about the shaft of the motor is called “feed-back” because it sends back information from the controlled actuator to the controller.


Sat Apr 20, 2013 4:01 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.