Scicos Block
eng - fr


Discrete zero crossing block

\epsfig{file=VCOEVT_f.eps,width=90.00pt}

Contents

Palette

Description

This block realizes a discrete threshold detection at zero, by analysing instaneous angulary position of oscillator and generates events when a crossing at zero occurs.
To understand the computational function, define an oscillator which have a general output equation :

$\displaystyle y_{s}\left(t\right)=\cos\left(\Theta\left(t\right)\right)
$

with $ \Theta(t)$ defined by :

$\displaystyle \Theta\left(t\right)=2\pi f_{o}t+\varphi_{s}\left(t\right)
$

where $ f_{o}$ is the free-running frequency and $ \varphi_{s}\left(t\right)$ the instantaneous phase position of the oscillator and assume that :

$\displaystyle \varphi_{s}\left(t\right)<<2\pi f_{o}t
$

When sampling the angulary position with constant step, $ \Theta(t)$ becomes $ \Theta_{k}$ and the following figure describes values and event date of the oscillator.
\begin{figure}\centering
\scalebox{0.8}{%
\input{2picross.pstex_t}}
\end{figure}
Figure : Discrete zero crossing of oscillators

to be continued...

Algorithm

\begin{figure}\centering
\scalebox{0.5}{%
\input{algo_vco.pstex_t}}
\end{figure}
Figure : Flow chart of VCOEVT computational function

Dialog box

\begin{figure}\begin{center}
\epsfig{file=VCOEVT_f_gui.eps,width=300pt}
\end{center}\end{figure}

Default properties

Interfacing function

VCOEVT_f.sci

Computational function (type 4)


/* vcoevt Scicos Time transition calculator block
 * Type 4 simulation function ver 1.1 - scilab-3
 * 7 Avril 2004 - IRCOM GROUP - Author : A.Layec
 * 21 Novembre 2004 : rajout option ipar[0]
 * 10 janvier 2005 : passage au type 4
 */
 
/* REVISION HISTORY :
 * $Log$
 */
 
#include "machine.h"
#include "scicos_block.h"

/* Cette fonction réalise le calcul approximé de la date d'évenement
 * correspondant au passage du signal d'entrée aux valeurs rpar[1]
 * (rpar[1]*u2[0] si ipar[0]=1).
 * Rmq : L'entrée est considérée strictement croissante et monotone.
 * 
 * entrées régulières : u1[0] : wot+phi(t)
 *                      u2[0] : entrée dynamique(rapport de division)
 * sortie régulière : néant
 * entrée d'évenement : Pas de calcul : Tsampl
 * sortie d'évenement : date du passage à rpar[1] (ou rpar[1]*u2[0])
 * paramètre entier : ipar[0] : 0 : passage aux valeurs rpar[1]
 *                              1 : passage aux valeurs rpar[1]*u2[0]
 * paramètres réels : rpar[0] : Tsampl
 *                    rpar[1] : valeur de passage en radian
 * état discret : z[0] : u(k-1)
 *                z[1] : valeur de u à la date de passage
 */

/*prototype*/
void vcoevt(scicos_block *block,int flag)
{
 /*déclaration des variables*/
 double *u1;
 double v; /*valeur de passage*/

 /*Récupération des adresses des ports d'entrées*/
 u1=(double *)block->inptr[0];
 
 /*Test si entrée 2*/
 if (block->ipar[0]==1)
 {
  /*déclaration*/ 
  double *u2;
  /*récupération adresse*/
  u2=(double *)block->inptr[1];
  v=block->rpar[1]*u2[0];
 }
 else v=block->rpar[1];

 /*le flag 3 calcul la date de transition*/
 if(flag==3)
  {
   /*Test si la valeur est >=rpar[1]*/
   if((u1[0]-block->z[1])>=v)
    {
     /*Calcul la date par extrapolation*/
     /*tvec[0] = *t + (((z[1]+v)-z[0])*rpar[0])/(u1[0]-z[0]);*/
     block->evout[0]=(((block->z[1]+v)-block->z[0])*block->rpar[0])/(u1[0]-block->z[0]);
     /*mémorise valeur à la date*/
     block->z[1] = block->z[1] + v;
    }
    /*mémorise u*/
    block->z[0]=u1[0];
  }
}

See also

Authors

IRCOM Group Alan Layec