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
  • OK, well!! I explain the code:

    -I have a global var type struct.
    -I have 2 task: WRITE task: here create PID task PID task: here call to the funtion that update the those struct.

    This is the piece of code:

    PID.H
    
    typedef int real;
    
    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;
    
    real UpdatePID (SPid *pid, real SP, real PV, unsigned int AUTO,real Uman) reentrant{
             into PID.c
             ....
             pid->iState += error;
             return pid->iState;
    }
    
    MAIN.C
    
    //global var
    SPid iA
    
    void Write (void) _task_ WRITE _priority_ 1{
               .....
               os_create_task(A);
               os_wait(K_SIG, WAIT_FOREVER,0);
               os_clear_signal(WRITE);
    }
    
    void PIDa (void) _task_ A _priority_ 1 {
               ...
               Ua = UpdatePID (&iA, SPa, PVa, 1, 4);
               os_send_signal(WRITE);
               os_delete_task(B);
    }
    
    the iA var never update
    
    

Reply
  • OK, well!! I explain the code:

    -I have a global var type struct.
    -I have 2 task: WRITE task: here create PID task PID task: here call to the funtion that update the those struct.

    This is the piece of code:

    PID.H
    
    typedef int real;
    
    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;
    
    real UpdatePID (SPid *pid, real SP, real PV, unsigned int AUTO,real Uman) reentrant{
             into PID.c
             ....
             pid->iState += error;
             return pid->iState;
    }
    
    MAIN.C
    
    //global var
    SPid iA
    
    void Write (void) _task_ WRITE _priority_ 1{
               .....
               os_create_task(A);
               os_wait(K_SIG, WAIT_FOREVER,0);
               os_clear_signal(WRITE);
    }
    
    void PIDa (void) _task_ A _priority_ 1 {
               ...
               Ua = UpdatePID (&iA, SPa, PVa, 1, 4);
               os_send_signal(WRITE);
               os_delete_task(B);
    }
    
    the iA var never update
    
    

Children
No data