Shop OBEX P1 Docs P2 Docs Learn Events
RUNNING LINEAR ACTUATOR without feed back - Page 2 — Parallax Forums

RUNNING LINEAR ACTUATOR without feed back

2»

Comments

  • ajit.nayak87ajit.nayak87 Posts: 76
    edited 2014-01-07 20:14
    Thanks Jordan, I am looking for below algorithm only. But only question i wanna ask here X input , how can make variable w.r.t time.

    In below code i am converting length to degree, But i assume length as constant.I need to make actual degree variable so that if desire -actual with limit motor try to kepp within limit of 1 degree. Let me know changes to made in below code.
    
    
    signed int Desire_Degree;
    unsigned int TS;
    static float slope= 0.00227272727273;
    static float intercept=- 102.272727273;
    static int length;
    signed int Actual_Degree;
    
    double Actual_postion;
    static float ACT_SPEED=3.2;
    
    
    static int Lmin=0;
    static int Lmax=600;
    static int Smin=-45;
    static int Smax=45;
    static float Slope_length;
    
    signed int Intr_length;
    
    void setup()
    {
       h=7;
      m=30;
      rtcSetup();
      setupActuator();
    Serial.begin(9600);  
    }
    static int time_interval;
    
    void loop()
    {
     // getRTCDateTime();
      calc_min();
      //Desire degree calculation
      if(h<23)
      {
      TS=(3600*h)+(60*m);
      Desire_Degree=(TS*slope)+intercept;
      
      //Actual anngle calculation
     // time_interval=(10)/(11*ACT_SPEED)*(25/88);
     length =(0.0151466666667*TS - 381.504);
     Actual_Degree=((3 *length) / 20) - 45;
     Actual_postion=((Actual_Degree + 45) * 20) / 3;
      moveActuator();
     if((Desire_Degree-Actual_Degree)>1)
     {
         Move_Forward();
         if((Actual_postion-length)==0);
         Move_Stop();
     }else
     {
       
       Move_Reverse();
     }
      
    /*  Slope_length=(Smax - Smin) / (Lmax-Lmin);
      Intr_length=Smin - ( Lmin * Slope_length);*/
    // Actual_Degree=((3*length)/200)-45;
      Serial.print("HH-MM: ");
      Serial.print(h);Serial.print(":");Serial.println(m);
      Serial.print("Desired Degree:");
     Serial.println(Desire_Degree);
     Serial.print("Actual Degree:");
     Serial.println(Actual_Degree);
     Serial.print("length:");
     Serial.println(length);
     Serial.print("Actual pos:");
     Serial.println(Actual_postion);
    Serial.println(".................................");
      
      }  
      delay(1000);
    }
    
    void calc_min()
    {
    
    if(m<60)
    {
       m=m+5;
    }else if(m==60)
    {
      m=0;h=h+1;
    }
    }
    
    void moveActuator(){
      
    
      switch(DIR){
      case FWD:
        Move_Forward();
        break;
      case REV:
        Move_Reverse();
        break;
      case STOP:
        Move_Stop();
        break;
      }
    }
    
    
    
    
    Move_Forward(){
    PIn setting for Driver
    }
    
    Move_Reverse()
    {
    PIn setting for Driver
    }
    Move_Stop()
    {
    PIn setting for Driver
    }
    
    setupActuator()
    {
    Pin configuration setting
    }
    
    
    
    
    I think the OP's problem here is understanding linear scaling.

    All scaling has the following can be done using three equations. (before anyone comes along and says 'Jordan, I've only ever used one or two', bear in mind that many applications can cancel out terms.)

    Lets take the given values from the top post, converting a mm position to an angular one, and using the same assumptions given. We can set some initial values:

    Input Min (Imin) = 0
    Input Max (Imax) = 600
    Scaled Min (Smin) = -45
    Scaled Max (Smax) = 45

    First, we can calculate Slope (m):
    m = (Smax - Smin) / (Imax-Imin) = (600-0) / (45-(-45)) = 0.150

    From there we calculate our Offset (b):
    b = Smin - ( Imin * m) = -45 - (0 * .150) = -45

    Now, can calculate any desired position where x = Input_Value and y = Scaled_Output. For instance, at 30mm:
    y = mx +b = (0.150)(30) - 45 = 40.5

    This method works for all linear scaling. If you want a time_in_minutes converted to a desired angle, then your Imin and Imax would be 0 and 660, respectively.

    Hope this helps point you in the right direction.
  • JordanCClarkJordanCClark Posts: 198
    edited 2014-01-08 05:03
    I'm not going to tell you how to write your code. Especially since this isn't an arduino forum. :tongue: I will, however, suggest a method of process. Actually, this ties in with what Duane was explaining in post 11. Keep your process to what you are actually controlling. In this case, the linear actuator.

    Using the equations I outlined earlier, here are all the possible slopes and offsets (intercepts):

    1-8-2014 6-11-38 AM.png


    Assuming a linear relation between angle and length we can see that 1 degree equals 6.667mm. With that, we can now disregard the desired angle in our process, because we only need to worry about the position of the actuator. We'll use this number in a moment.

    At the start of the day, desired length is 0, actual length is 0. Always a great place to begin!

    As time progresses, we can calculate our desired length. (1 min = .909mm, 2min=1.818mm, etc.)

    We then look at the amount of process error (desired_length-actual_length) to see if we need to move. With +/-1 degree of resolution required, the max amount of allowable process error, called deadband, is +/-6.667mm, mentioned earlier. When the process error is outside the deadband, then we must move the actuator.
    Deadband.png




    At 3.2mm/sec travel speed, we can move the actuator for 2 seconds, then add/subtract 6.4mm to your actual_length. Since we have no feedback from the actuator, this distance must be assumed. After moving the actuator, we go back to monitoring the process error.


    If you want to convert lengths to angles for display purposes, that's fine. There's just no need to use them in the process.

    1-8-2014 8-00-13 AM.png
    740 x 340 - 21K
    206 x 174 - 1K
    467 x 696 - 15K
  • ajit.nayak87ajit.nayak87 Posts: 76
    edited 2014-01-08 05:14
    Thanks for algoritms..Here how you extend and retract actuator for 2 second
  • JordanCClarkJordanCClark Posts: 198
    edited 2014-01-08 05:48
    I'm not sure I understand. How are you moving the actuator now? It appears you are using a forward and reverse signal to move it with Move_Forward() and Move_Reverse(). It would seem to me you would use one of those, wait 2 seconds and then use Move_Stop().

    Are are you asking how we came up with 2 seconds? You specified that the speed of the actuator is 3.2mm/sec. In 2 sesonds it would move 6.4mm, which is very close to the 6.667mm of the deadband.
  • ajit.nayak87ajit.nayak87 Posts: 76
    edited 2014-01-08 22:09
    I'm not sure I understand. How are you moving the actuator now? It appears you are using a forward and reverse signal to move it with Move_Forward() and Move_Reverse(). It would seem to me you would use one of those, wait 2 seconds and then use Move_Stop().

    Are are you asking how we came up with 2 seconds? You specified that the speed of the actuator is 3.2mm/sec. In 2 sesonds it would move 6.4mm, which is very close to the 6.667mm of the deadband.


    Question:
    1)Here TS value calculate min. But i found actual position continuously varying.
    after 1 min.JPG
    init _mode.JPG

    2)As i told you, How to run Exactly for 2Second
    3)Desired Degree and actual Degree are not stable. continously varying
    343 x 558 - 35K
    446 x 400 - 28K
  • JordanCClarkJordanCClark Posts: 198
    edited 2014-01-09 03:09
    1) You are constantly moving the actuator. Your process error method does not properly handle the deadband. Separate the if/else to separate if statements. It's why I showed two separate decision polygons in the flowchart.

    2) Really? Ok, you need something like:
    Move_Forward();
    Something_to_make_it_wait();
    Move_Stop;
    
    If only there was something to make it wait. To delay any further action. Maybe this will help.

    3) I imagine this is related to number 1.
  • ajit.nayak87ajit.nayak87 Posts: 76
    edited 2014-01-09 03:34
    1) You are constantly moving the actuator. Your process error method does not properly handle the deadband. Separate the if/else to separate if statements. It's why I showed two separate decision polygons in the flowchart.

    2) Really? Ok, you need something like:
    Move_Forward();
    Something_to_make_it_wait();
    Move_Stop;
    
    If only there was something to make it wait. To delay any further action. Maybe this will help.

    3) I imagine this is related to number 1.


    This code worked for me . Is it possible to reduce bandwidth
    [
  • ajit.nayak87ajit.nayak87 Posts: 76
    edited 2014-01-09 04:53
    out.jpg
    The Code is working Fine , But it gutters ,since taking difference of length. Is there any way we can filter so that, When it reaches Desired length motor gets stops.
    1024 x 576 - 53K
    out.jpg 52.7K
  • JordanCClarkJordanCClark Posts: 198
    edited 2014-01-09 06:04
    If it gutters, then the code is doing what you told it to do. You're just not telling it the right things yet.
    • You have nothing to stop the motor once it starts.
    • You are still not properly handling the deadband.
      • The deadband needs an upper limit (6.667mm) and a lower limit (-6.667mm).
      • When you're within the deadband, nothing is supposed to happen.
      • When you're outside the deadband, move the actuator to to but it back in.
    Against my better judgement, here is a snippet. It may or may not work. This is not an arduino forum, and we're not arduino guys around here. I don't mind helping you to understand the math or visualize a process. But it is really up to you to write and understand your code.
    void calc_processError()
    {
      proecss_error=Desired_pos-Actual_pos;
      if (proecss_error > band_legth)
      {
       Actual_pos=Actual_pos+6.4;Move_Forward(); delay(2000); Move_Stop();
      }
    
      if (proecss_error < -band_legth)
      {
       Actual_pos=Actual_pos-6.4; Move_Reverse(); delay(2000); Move_Stop();
      }
    Serial.print("Actual_pos:");
    Serial.println(Actual_pos);
    }
    
  • ajit.nayak87ajit.nayak87 Posts: 76
    edited 2014-01-09 21:01
    Thanks for support
Sign In or Register to comment.