pompecharge
/* Modnumlib Scicos interfacing function
* Copyright (C) 2009 Alan Layec
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* pompecharge Scicos Charge Pump block
* Type 4 simulation function ver 1.0 - scilab-3.0
* 9 octobre 2003 - IRCOM GROUP - Author : A.Layec
* 10 janvier 2005 : passage type 4
* rajout du bruit sur le courant de fuite
*/
/* REVISION HISTORY :
* $Log$
*/
#include <math.h>
#include <stdlib.h> /*pour RAND_MAX*/
#include "modnum_lib.h"
#include "scicos_block.h"
/* Cette fonction de simulation réalise l'opération d'une pompe de charge
*
* entrées régulières : u[0..nu-1] : Vecteur des Signaux discrets Up(t)
* u[nu..2nu-1] : Vecteur des signaux discrets Down(t)
* sortie régulière : y[0..nu] : Vecteur des signaux discrets Icp(t)
*
* entrées d'événements : nev=0 à la rigueur (Ref(t) union Div(t))
* sinon néant (héritage)
*
* sorties d'évènement : néant
* paramètres entiers : outsz[0] : taille des vecteurs (nu)
* ipar[0] : 0=pas de bruit sur le courant de fuite
* 1=fuite constante
* 2=bruit normal sur le courant de fuite
* paramètres réels : rpar[0..nu-1] : courant max de la pompe de charge
* rpar[nu..2nu-1] : courant de fuite moyen de la pompe de charge
* rpar[2*nu..3*nu-1] : deviation du courant de fuite (si ipar[0]=1)
*/
/*prototype*/
void pompecharge(scicos_block *block,int flag)
{
/*déclaration*/
double *y;
double *up,*down;
int nu;
int typ_leak;
double *Io,*Ileak_d,*Ileak_m;
/*Récupération de l'adresse des ports d'entrée et de sortie*/
y=(double *)block->outptr[0];
up=(double *)block->inptr[0];
down=(double *)block->inptr[1];
/*Stock taille de la sortie dans nu*/
nu=block->outsz[0];
/*Récupération des paramètres*/
typ_leak=block->ipar[0];
Io=&block->rpar[0];
Ileak_m=&block->rpar[nu];
Ileak_d=&block->rpar[2*nu];
/*Appel chargepump_c*/
chargepump_c(&nu,&up[0],&down[0],&Io[0],&typ_leak,&Ileak_m[0],&Ileak_d[0],&y[0]);
}