This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Global Var

HI!!

I declared 3 global var, i call it inside diferent task and every execution this var should be updates but not to do it.
I have a 8051 under evaluation board.
Maybe can be a problem of my small micro?
What do u think about this?

Thanks

Parents
  • SPid iA
    
    void PIDa (void) _task_ A _priority_ 1 {
    
            Ua = UpdatePID (&iA, SPa, PVa, 1, 4);
    
            os_send_signal(WRITE);
    
            os_delete_task(A);
    
    
    }
    

    iA is my global var that it is initialized into a task. This task is calling to the task A (top).

    When UpdatePID funtion is executed the iA var not update.

Reply
  • SPid iA
    
    void PIDa (void) _task_ A _priority_ 1 {
    
            Ua = UpdatePID (&iA, SPa, PVa, 1, 4);
    
            os_send_signal(WRITE);
    
            os_delete_task(A);
    
    
    }
    

    iA is my global var that it is initialized into a task. This task is calling to the task A (top).

    When UpdatePID funtion is executed the iA var not update.

Children
  • You show a global variable of an unknown data type.

    You show that you send the address of the variable to a function.

    You do not show the function implementation

    Exactly what do you think will be able to deduce from this?

  • I am not sure I understand what you are doing here: are you terminating the task that does your PID calculations just after one cycle? this is not the way to implemented a closed loop using a PID controller, of any controller whatsoever that is based on feedback.

  • The data type is :

    typedef struct {
    
    real dState;            /* Ultima posicion             */
    real iState;            /* Estado del integrador       */
    real uMax,uMin;     /* Saturacion del actuador     */
    real Kp;                    /* Ganancia proporcional       */
    real Ti,Td;                     /* Cte, tiempo integral y derivativo        */
    real Ts,Tt;                     /* Periodo muestreo, Cte. tiempo tracking   */
    real Kwindup;           /* Cte. antireset windup                    */
    
    } SPid;
    
    

    The funtion implementation i think that is not important to resolve my problem. This is the top of the funtion:

    real UpdatePID (SPid *pid, real SP, real PV, unsigned int AUTO,real Uman) reentrant;
    


    real is int data type

  • Hi Tamir,

    My idea is:
    - I have a WRITE task that initialize the PID task:

                      os_create_task(A);
                      os_create_task(B);
                      os_create_task(C);
    
                      os_wait(K_SIG, WAIT_FOREVER,0);       /* Espera hasta que algun PID actualice el valor */
                      os_clear_signal(WRITE);
    

    This 3 task should update my global var called iAiBiC respectly.

    After i send the result of the PIDs to serial port for comunications with a simulator.

  • Tamir!

    How you implement a PID in a task to controller a system??
    Thanks

  • javi,
    forget about your task for a moment. first of all you need conversion tables - for example, if you want to maintain constants speed of a system using a PID controller, assuming you have a speed sensor, you would translate your speed error (that is, set point minus actual speed) to desired current (based on the known properties of your system - speed control valve of some kind) and then again, convert that to a duty cycle (based on the properties on a valve that regulate the speed). and of course, this must be done for as long as speed control is required, so that the system can make continuous adjustments!
    please note that you do not need a task to do this. if you choose to use one - do not terminate it unless you want to stop closed loop control.