Hey, the sample time of the GRAMPC s-function is inherited (-1). The sampling time is set the s-function grampc_run_Sfct in line 204 "ssSetSampleTime(S, 0, -1);". Therefore, I guess there is a problem in your model. Is “MPC-Subsystem” really the name of your GRAMPC s-function or did you put the s-function in another subsystem? Best regards Tobias
Hey, in the red rectangle you don't need to add anything. To the additional build information (the blue rectangle) you have to add <grampc_root>/matlab/include and <grampc_root>/include in the field "Include directories". In the field "Source files" (in the blue rectangle) you have to add all files in the folder <grampc_root>/src, similiar to how you added them in the red rectangle. Beside this, your problem description file (e.g. probfct.c) and the file <grampc_root>/matlab/src/grampc_run_Sfct.c...
You are almost right about your second question. However, the files must be specified as additional build information, as it is stated in the documentation. I.e. in the fields below your red rectangle. Regards, Tobias
Dear Andinet you must add the GRAMPC source and header files to your Simulink model so that these files can be correctly compiled and linked. The last paragraph on page 36 of the documentation (Section 5.2.2 Interface to Matlab/Simulink) explains you how to do this. Best regards Tobias
Hello botNet, if you change the datatype in grampc_init.h, you need to recompile both the example and the whole toolbox. For example, if you use the matlab interface, the command [vec,grampc] = startMPC(200,2); should work after changing the datatype. Best regards Tobias
Hello Giulio, just use a for loop to copy the data form the input array into the userparam array. For this purpose, you can use a typecast to get a typeRNum pointer to the userparam memory as it is done in various problem functions in the example folder. Thor is the prediction horizon, which is internally sampled by Nhor grid points. dt is the sampling time of the MPC. For more details, please refer to the GRAMPC documentation. Regards, Tobias
Hello Giulio, If you want to change the userparam in Simulink at runtime, you need to add an additional input to the provided s-fuction grampc_run_Sfct.c. You can specify the dimensions of this input according to your needs. In the function mdlOutputs you can read the input data from the additional pin and overwrite the userparam data before calling the function grampc_run. Regards, Tobias
GRAMPC V2.1