0% found this document useful (0 votes)
38 views6 pages

Correction td1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views6 pages

Correction td1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Correction de TD1 2019/2020

Correction
Exercice1

program chenillard;

var i:byte;

begin

trisb:=0:

portb:=0;

while true do

begin

for i:=0 to 7 do

begin

portb.i:=1;

delay_ms(500);

portb.i:=0;

end;

end;

end.

Exercice2

a)

program compteur10;

var i:byte;

const tab:array[10]of
byte=(%00111111,%00000110,%01011011,%01001111,%01100110,%01101101,%0
1111101,%00000111,%01111111,%01101111);

Hmaied Sarhene Page 17


Correction de TD1 2019/2020

begin

trisb:=0:

portb:=0;

while true do

begin

for i:=0 to 9 do

begin

portb:=tab[i];

delay_ms(1000);

end;

end;

end.

b)

program compteur100;

var i,j:byte;

const tab:array[10] of byte=(%00111111,%00000110,%01011011,%01001111,


%01100110,%01101101,%01111101,%00000111,%01111111,%01101111);

begin

trisb:=0:

trisd:=0;

portb:=0;

portd:=0;

while true do

begin

Hmaied Sarhene Page 18


Correction de TD1 2019/2020

for i:=0 to 9 do

begin

portb:=tab[i];

portd.0:=1;

delay_ms(1);

portd.0:=0;

for j:=0 to 9 do

begin

portb:=tab[j];

portd.1:=1;

delay_ms(1);

portd.1:=0;

delay_ms(1000);

end;

end;

end ;

end.

Exercice3

program grafcet;

var x:byte;

begin

portb:=$ff;

trisd:=0;

x:=%00000001;

Hmaied Sarhene Page 19


Correction de TD1 2019/2020

portd:=0;

while true do

begin

if ((x.6=1) and (portb.6=1)) then

begin

x.6:=0;

x.0:=1;

end;

if ((x.0=1) and (portb.0=1)) then

begin

x.0:=0;

x.1:=1;

x.5:=1;

end;

if ((x.1=1) and (portb.2=1)) then

begin

x.1:=0;

x.3:=1;

end;

if ((x.2=1) and (portb.3=1)) then

begin

x.2:=0;

x.4:=1;

end;

Hmaied Sarhene Page 20


Correction de TD1 2019/2020

if ((x.3=1) and (portb.4=1)) then

begin

x.3:=0;

x.4:=1;

end;

if ((x.4=1) and (portb.5=1)) then

begin

x.4:=0;

x.5:=0;

x.6:=1;

end;

portd.0:=x.1 or x.4;

portd.1:=x.5 or x.6;

portd.2:=x.2 or x.4;

portd.3:=x.3 or x.6;

end;

end.

Exercice3

program equation;

begin

trisb:=$ff;

trisd:=$00;

portd:=0;

Hmaied Sarhene Page 21


Correction de TD1 2019/2020

option_reg:=$00;

while true do

begin

if((portb.0=0) or (portb.1=0) or (portb.2=1)) then portd.0:=1 else portd.0:=0;

if((portb.0=0) xor (portb.2=0)) then portd.1:=1 else portd.1:=0;

if((portb.0=1) and (portb.1=1)) then portd.2:=1 else portd.2:=0;

end;

end.

Hmaied Sarhene Page 22

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy