[Scilab-users] (EXCEPTION_ACCESS_VIOLATION) with "scicosim" function

Clément David clement.david at scilab-enterprises.com
Mon Feb 25 10:57:16 CET 2013


Hello Pete,

On the 'initialization' part you do not store anything on block->work
user data pointer. Using the following snippets should work:

// declare the data
double* Te;

// allocate the data
Te = (double *) MALLOC(sizeof(double));

// retrieve the data (user data)
Te = (double *) * (blk->work);

// store the pointer into the simulator provided area (user data)
*(block->work) = Te;

On Mon, 2013-02-25 at 00:52 -0800, pepe wrote:
> Hello,
> I prepared my own C - function to have own simulation block. It compiles,
> link and load the function with no problem. But during the simulation I got
> (EXCEPTION_ACCESS_VIOLATION) with "scicosim" function. 
> Attaching the function:
> 
> #include "c:\Program Files
> (x86)\scilab-5.4.0\modules\scicos\includes\scicos_malloc.h"
>     #include "c:\Program Files
> (x86)\scilab-5.4.0\libs\MALLOC\includes\MALLOC.h"
>     #include "scicos_block4.h" 
>     #include <math.h> 
>     #include <stdio.h> 
>     #include <stdlib.h> 
>      
>     #define r_IN(n, i)      ((GetRealInPortPtrs(blk, n+1))[(i)]) 
>     #define r_OUT(n, i)     ((GetRealOutPortPtrs(blk, n+1))[(i)]) 
>     
>     // inputs 
>     #define Ud              (r_IN(0,0))         
>     #define Uq              (r_IN(1,0))          
>     #define Tload           (r_IN(2,0))         
>     
>     // states 
>     #define Id              (GetState(blk)[0])           
>     #define Iq              (GetState(blk)[1])          
>     #define Wm              (GetState(blk)[2])         
>     #define Theta           (GetState(blk)[3])          
>      
>     #define dId             (GetDerState(blk)[0])       
>     #define dIq             (GetDerState(blk)[1])        
>     #define dWm             (GetDerState(blk)[2])        
>     #define dTheta          (GetDerState(blk)[3])       
>     
>     // outputs 
>     #define Id_out          (r_OUT(0, 0))       
>     #define Iq_out          (r_OUT(1, 0))        
>     #define Te_out          (r_OUT(2, 0))       
>     
>     //parameters
>     #define Rs          1.01
>     #define Lq          0.001
>     #define Ld          0.001
>     #define ke          0.02
>     #define pp          2.
>     #define Jm          0.008
>     #define B           0.000005
>     #define pi          3.14
>     #define sqrt3       1.732
>     
>     void myPMSM_block(scicos_block *blk, int flag)  
>     { 
>         double *Te  = (double *) * (blk->work);
>     
>         switch (flag) 
>         { 
>             case Initialization:
>                 Te = (double *) MALLOC(sizeof(double));
>                 Te[0] = 0;
>             break;
>                 
>             case DerivativeState:
>                 Te[0] = 3./2.*pp/2.*(ke*Iq);// + (Ld - Lq)*Id*Iq);
>                 dId = 1./Ld*(Ud - Rs*Id + Lq*pp/2.*Iq*Wm);
>                 dIq = 1./Lq*(Uq - Rs*Iq);// - (Ld*Id + ke)*pp/2.*Wm);
>                 dWm = 1./Jm*(Te[0] - B*Wm - Tload);
>                 dTheta = Wm;
>             break; 
>              
>             case OutputUpdate:
>                  Id_out = Id;
>                  Iq_out = Iq;
>                  Te_out = Te[0];
>             break; 
>             
>             case Ending:
>                  scicos_free(Te);
>             break;
>                     
>         } 
>     }
> 
> 
> After xcos block simulation I am getting within console this message:
> 
> Warning !!!
> Scilab has found a critical error (EXCEPTION_ACCESS_VIOLATION)
> with "scicosim" function.
> Save your data and restart Scilab.
> 
> 
> Any idea how to resolve this?
> 
> Thank you.
> Peter
> 
> 
> 
> --
> View this message in context: http://mailinglists.scilab.org/EXCEPTION-ACCESS-VIOLATION-with-scicosim-function-tp4026020.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-- 
Clément DAVID
Development Engineer / Account Manager
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Mobile: +33.6.26.26.51.90
Phone: +33.2.90.22.78.96
http://www.scilab-enterprises.com




More information about the users mailing list