################################################################################
# FICHE DE MODELE SABER : ED:1 REV:0
# AUTEUR:OCSIMIZE DATE:04/21/07
#
# FICHIER tri_detect.sin : ind.a
# ETAT : valid
################################################################################
################################################################################
# Copyright 2007 and beyond, Ocsimize.
# This template may not be reproduced or modified
# without permission from Ocsimize. Ocsimize does not assume
# liability for the use of this template or the results
# obtained from using it as long as it is not validated.
################################################################################
################################################################################
# MODIFICATION
#
# 04/21/07: creation
#
################################################################################
#
# pins
#
################################################################################
# Name Type Signification
#
# a electrical phase a
# b electrical phase b
# c electrical phase c
# out logic_4 digital output on three phase presence
#
################################################################################
#
# Parameters definition
#
################################################################################
# Name Default value Signification
#
# freq 200 (Hz) generally half of the mains frequency
# init _x (-) initial state of output
#
################################################################################
#
# Postprocess information
#
################################################################################
# Name Unit Signification
#
# - - -
#
################################################################################
#
# usage
#
################################################################################
#
# This template takes the three phase of a three-phase sources
# and detects if there was a breakdown after O.5/freq seconds
#
#
# ----------
# --/ \-/ \- (a) o--| |
# --/ \-/ \- (b) o--| |--o (out)
# --/ \-/ \- (c) o--| |
# ----------
#
################################################################################
# Notes :
################################################################################
#
# * the detection threshold is 90 V for a use in airplane electrical networks.
# As soon as the voltage is under 90 volts there is significantly a problem
# on board.
#
################################################################################
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
#==============================================================================#
template tri_detect a b c out ground = freq, init
#==============================================================================#
state logic_4 out
electrical a, b, c, ground
enum {_0,_1,_x} init = _x
number freq=200
{
state logic_4 sch_out
state nu latch_a[2], latch_b[2], latch_c[2]
state nu before_ap,after_ap
state nu before_bp,after_bp
state nu before_cp,after_cp
# state nu before_an,after_an
# state nu before_bn,after_bn
# state nu before_cn,after_cn
state nu spy
val v va, vb, vc
#
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
when(dc_init) {
if(init == _0) {
schedule_event(time,out,l4_0)
}
else if(init == _1) {
schedule_event(time,out,l4_1)
}
}
when(threshold(va,90,before_ap,after_ap)) {
spy = 1
if(before_ap < 0 & after_ap > 0) {
schedule_event(time ,out,l4_1)
latch_a = schedule_event(time + 0.5/freq ,out,l4_0)
deschedule(latch_b)
deschedule(latch_c)
spy = 1.5
}
}
when(threshold(vb,90,before_bp,after_bp)) {
spy = 2
if(before_bp < 0 & after_bp > 0) {
schedule_event(time ,out,l4_1)
deschedule(latch_a)
latch_b = schedule_event(time + 0.5/freq ,out,l4_0)
deschedule(latch_c)
spy = 2.5
}
}
when(threshold(vc,90,before_cp,after_cp)) {
spy = 3
if(before_cp < 0 & after_cp > 0) {
schedule_event(time ,out,l4_1)
deschedule(latch_a)
deschedule(latch_b)
latch_c = schedule_event(time + 0.5/freq ,out,l4_0)
spy = 3.5
}
}
#
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
values {
va = v(a) - v(ground)
vb = v(b) - v(ground)
vc = v(c) - v(ground)
}
#
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
equations {
i(a) += 0
i(b) += 0
i(c) += 0
i(ground) += 0
}
}