Subsections

- Library
- Description
- Dialog Box
- Default properties
- Interfacing function
- Computational function (type 4)

##
Hystheresis

### Library

Others

### Description

Hysthersis block.

### Dialog Box

Set parameters |
switch on at | 1
switch off at | 0
output when on | 1
output when off | 0
use zero crossing: yes (1), no (0) | 1

- switch on at: the lower threshold
- switch off at: the upper threshold
- output when on: value of the output when on
- output when off: value of the output when off
- use zero crossing: matter only if input is continuously active.

### Default properties

- always active: no
- direct-feedthrough: yes
- zero-crossing: yes
- mode: yes
- number/sizes of inputs: 1 / 1
- number/sizes of outputs: 1 / 1
- number/sizes of activation inputs: 0 /
- number/sizes of activation outputs: 0 /
- continuous-time state: no
- discrete-time state: no
- name of computational function: hystheresis

### Interfacing function

`scilab/macros/scicos_blocks/misc/HYSTHERESIS.sci`

### Computational function (type 4)

    #include "scicos_block.h"
    #include <math.h>

    void  hystheresis(scicos_block *block,int flag)
    {
      if (flag==1){
        if (get_phase_simulation()==1) {
          if (*block->inptr[0]>=block->rpar[0]){
    	block->outptr[0][0]=block->rpar[2];
          }else if (*block->inptr[0]<=block->rpar[1]){
    	block->outptr[0][0]=block->rpar[3];
          }
        }else{
          if (block->mode[0]<2){
    	block->outptr[0][0]=block->rpar[3];
          }else{
    	block->outptr[0][0]=block->rpar[2];
          }
        }
      } else if (flag==9){
        block->g[0]=*block->inptr[0]-(block->rpar[0]);
        block->g[1]=*block->inptr[0]-(block->rpar[1]);
        if (get_phase_simulation()==1) {
          if (block->g[0]>=0){
    	block->mode[0]=2;
          }else if (block->g[1]<=0){
    	block->mode[0]=1;
          }
        }
      }
    }