deadband.c

Go to the documentation of this file.
00001 #include "scicos_block.h"
00002 #include <math.h>
00003 void deadband(scicos_block *block,int flag)
00004 {/* rpar[0]:upper limit,  rpar[1]:lower limit */
00005   if (flag==1){
00006     if (get_phase_simulation()==1||block->ng==0) {
00007       if (*block->inptr[0]>=block->rpar[0]){
00008         block->outptr[0][0]=*block->inptr[0]-block->rpar[0];
00009       }else if (*block->inptr[0]<=block->rpar[1]){
00010         block->outptr[0][0]=*block->inptr[0]-block->rpar[1];
00011       }else {
00012         block->outptr[0][0]=0.0;
00013       }
00014     }else{
00015       if (block->mode[0]==1){
00016         block->outptr[0][0]=*block->inptr[0]-block->rpar[0];
00017       }else if(block->mode[0]==2) {
00018         block->outptr[0][0]=*block->inptr[0]-block->rpar[1];
00019       }else{
00020         block->outptr[0][0]=0.0;
00021       } 
00022     }
00023   } else if (flag==9){
00024     block->g[0]=*block->inptr[0]-(block->rpar[0]);
00025     block->g[1]=*block->inptr[0]-(block->rpar[1]);
00026     if (get_phase_simulation()==1) {
00027       if (block->g[0]>=0){
00028         block->mode[0]=1;
00029       }else if (block->g[1]<=0){
00030         block->mode[0]=2;
00031       }else {
00032         block->mode[0]=3;
00033       }
00034     }
00035   }
00036 }
00037 

Generated on Sun Mar 4 15:03:59 2007 for Scilab [trunk] by  doxygen 1.5.1