Documente Academic
Documente Profesional
Documente Cultură
Broches du PIC16F84A
b0
0
1
0
1
H0
H1
H2
H0 = ..
H1 = ..
H2 = ...
1re Mthode
1- Complter lalgorithme ainsi que le programme relatif au comparateur binaire.
Algorithme
Algorithme Comparateur ;
Programme en MikroPascal
Program Comparateur;
DEBUT
.............
TrisA .. ;
TrisB ...;
PortB .. ;
..
DEBUT
BEGIN
If (((porta.0=.....................
....................
ALORS
Then portb.1.............;
If ((porta.0 .....................
FIN FAIRE ;
then portb.2................................;
if ((porta.0 ................
then portb.0..... ;
;
FIN.
ACTIVTES : PIC16F84A
4SC.TECH.
M.JEMIL
Page 1 /8
2me Mthode
1 -
2 -
Programme en MikroPascal
Algorithme Comparateur2;
Program Comparateur2;
DEBUT
TrisA .;
TrisA .. ;
TrisB .;
TrisB ...;
PortB .;
.. ;
....
Dbut
if portA.0 ..................
else
else
if portA.0 ..........................................
else .... ;
FIN FAIRE;
..;
FIN DU PROGRAMME
port..... ;
port...... ;
else portB.0:= ;
else
else portB.0:=.. ;
else ................................;
if .. then...................................
else portB.2:=.. ;
else ..............................;
ACTIVTES : PIC16F84A
4SC.TECH.
Clearbit(portB, .....);
M.JEMIL
Page 2 /8
S2
KM1
KM1
Schma ISIS:
RA4
RA3
RA2
RA1
RA0
TrisA =
TRIS A
2- On va associe KM1 une variable X de type Octet et dont l'quation est :
X RA0.( RA1 X )
Proposer un programme en MikroPascal traduisant le fonctionnement de cette quation.
Programme MikroPascal
Program act2;
Var .................. : ....................... ;
..
X:=............................;
// Initialisation de la variable X
While ...................................
Begin
...
4SC.TECH.
M.JEMIL
Page 3 /8
Etat de X
Etat de l'afficheur
Arrt
Marche
A
F
1- Trouver la valeur affecte au port B traduisant les diffrents tats de lafficheur. (Dans le
menu Tools choisir la commande Seven segment convertor).
Remarque: Cet outil nest valable que si les segments
de lafficheur sont connects au port B comme suit:
X=.......... then
else
portb:=$ ............;
.;
BEGIN
trisa:= $ ...................;
//Configuration du port A
trisb:= $.....................; // Toutes les broches du port B sont des Sorties
Portb:=0;
// Initialisation du port B
X:=0;
// Initialisation de la variable X
While . Begin
....................................; // appel de la procdure ETAT
if ((porta.0=0) .. ((.......................) .. (...................... ))) then X:=..... Else X: =.....;
.............................................................................................................; //RA3 = X
End;
ACTIVTES : PIC16F84A
4SC.TECH.
M.JEMIL
Page 4 /8
Remarque :
Le temps dattente entre deux
tats successifs est de 0.5s.
0 1 2 3 4 5 6 7 8 9
Valeur du port[B]
en dcimal
1re Mthode (structures itratives ou rptitives)
Ecrire un programme en MikroPascal utilisant les instructions suivantes : Repeat..until
begin
portb:= ; delay_ms(500);
portb:= ; delay_ms(500);
portb:= ; delay_ms(500);
End
else
begin
portb:= ; delay_ms(500);
portb:= ; delay_ms(500);
portb:= ; delay_ms(500);
portb:= 63
end;
; delay_ms(500);
Until .................;
ACTIVTES : PIC16F84A
END.
4SC.TECH.
M.JEMIL
Page 5 /8
i: integer;
Const
portb:= ......;
BEGIN
delay_ms (....);
end;
trisB:=%......................;
repeat
if portb.7=1 then begin for i:=0
Else begin for i:=9
........
do
......................;
end
............. 0 do
.....................;
end;
.................. .
..
AV
S3
T=5s
t/2/5s
EJ
S3
ACTIVTES : PIC16F84A
4SC.TECH.
M.JEMIL
Page 6 /8
Affection
Entres
PIC 16F84A
Sorties
PIC 16F84A
S1
RA1
EJ: Ejection
RB1
S2
RA2
AV: Avance
RB2
S3
RA3
Configuration des ports A et B (une broche non utilise sera configure comme entre).
TrisA :=
TrisB :=
X0
RA1
..
X1
.
X2
t
X3
.
Commentaire
Program convoyeur;
Nom du programme
Var X . ;
BEGIN
...;
...;
.;
boucle infinie
begin
if ((X0=) and (..)) then
begin X0:=;
X1:=.; end;
ACTIVTES : PIC16F84A
4SC.TECH.
M.JEMIL
Page 7 /8
if X2=0
then
t:=0 else
begin
Programmation du temporisateur T
t:=0; ...(5000);
t:=1;
;
End;
. .
FIN du programme
X0
RB0
RA0
RB1
X1
T1
t1/300s
X2
RA1.t4
Program_MT ;
Var X0, , ;
Begin
TrisA :=
TrisB :=
portB
X0 :=1 ;
While . ;
Begin
if....then
Begin
X0 :=0 ; X1 :=1 ;
;
if.then
Begin
;
End ;
if.then
..
;
.
...then
..
;
. ;
ACTIVTES : PIC16F84A
4SC.TECH.
T4
NotRA1.t4
if X0=1 ;
if X1=1 then
Begin
portb.1 :=1 ; t1 :=0 ;
Vdelay_ms(..) ; t1 :=. ;
End
Begin
Portb.1 :=0 ; t1 :=0 ;
End ;
if X2=1 then
Begin
;
.. ;
End
.. ;
;
M.JEMIL
Page 8 /8