Subsections

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

##
Hystheresis

### Library

Others

### Description

### 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: YYYY
- switch off at: YYYY
- output when on: YYYY
- output when off: YYYY
- use zero crossing: yes : YYYY

### 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;
          }
        }
      }
    }