Overblog
Editer la page Suivre ce blog Administration + Créer mon blog
/ / /

''---------------------------------------------------------------------------
'
'                  CONVERTISSEUR 1 VOIE PROPORTIONNELLE
'    VERS 4 CANAUX TOUT OU RIEN
'       pour PICAXE 08M2
'
'    (c) O. Lanvin (THX-1138)
'      24.10.2011
'
'                          version sortie active BASSE (0V)
'----------------------------------------------------------------------------

symbol INP = 3   'broche d'entrée
symbol OUT1 = 0   'broches de sortie
symbol OUT2 = 1
symbol OUT3 = 2
symbol OUT4 = 4
symbol TIMP = w0   'temps impulsion entrante
symbol TCOMP  =w1   'impulsion de référence
symbol TDIFF = w2   'différence
symbol T1 = 120   'limite activation canal 1  
symbol T2 = 140   ' idem canal 2
symbol T3 = 160   ' idem canal 3
symbol T4 = 180   ' idem canal 4
symbol TMIN = 100   ' durée mini impulsion
symbol TMAX = 200   ' durée maxi impulsion
symbol TNEU = 150   ' durée du neutre
symbol NPULSES = 5  'nbre d'impulsions stables
symbol DELTA = 2   'tolérance autorisée
symbol IMPCOUNT = b6

TIMP=150    'initialisation neutre

 high OUT1    'désactivation sorties
 high OUT2
 high OUT3
 high OUT4 

start: TCOMP=TIMP   'mise à jour référence
pulsin INP,1,TIMP   'lecture temps de voie
if TCOMP>TIMP then
 TDIFF=TCOMP-TIMP  'calcul de  la différence
else
 TDIFF=TIMP-TCOMP
endif
if TDIFF>DELTA then  'si > delta autorisé
 IMPCOUNT=0   'RAZ compteur d'impulsions valides
else
 IMPCOUNT=IMPCOUNT+1 'sinon on incrémente
endif
if IMPCOUNT=NPULSES then 'si compteur d'impulsions OK
select TIMP
case TMIN to T1   'activer la sortie correspondante
 low OUT1
 high OUT2
 high OUT3
 high OUT4
case T1 to T2
 high OUT1
 low OUT2
 high OUT3
 high OUT4
case T3 to T4
 high OUT1
 high OUT2
 low OUT3
 high OUT4
case T4 to TMAX
 high OUT1
 high OUT2
 high OUT3
 low OUT4
else     'sinon, toutes sorties désactivées
 high OUT1
 high OUT2
 high OUT3
 high OUT4
end select
endif
goto start

Partager cette page
Repost0