File11 Real Delays To Be Applied On Circuit

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Microlab File11 – by Joseph Massoud

Real Time calculation in delays ( square and rectangular waves)

The core loop is the one marked in red ;


According to the instructions sheet, the time elapsed by each instruction is
1 cycle ( 1 microsecond) and 2 cycles ( 2 microseconds) respectively.

They are repeated N times till the total time runs out.
N = Reg3*Reg2*Reg1

( To define reg1 , reg2, reg3 as the variables of the counter in the EQU section)

Delay of 1 second function (( 5*255*255 * ( 2+1) )microseconds


=~ 1,000,000 microseconds = 1second

DELAY1S
MOVLW D'5'
MOVWF REG3
MOVLW D'255'
MOVWF REG2
MOVLW D'255'
MOVWF REG1
DECFSZ REG1,F ; 1 microseconds
GOTO $-1 ; 2 microseconds
DECFSZ REG2,F
GOTO $-5
DECFSZ REG3,F
GOTO $-9
RETURN
Microlab File11 – by Joseph Massoud

Delay of 2 seconds function ( 10*255*255 * ( 2+1))microseconds


=~ 2,000,000 micros = 2 seconds

DELAY2S
MOVLW D'10'
MOVWF REG3
MOVLW D'255'
MOVWF REG2
MOVLW D'255'
MOVWF REG1
DECFSZ REG1,F
GOTO $-1
DECFSZ REG2,F
GOTO $-5
DECFSZ REG3,F
GOTO $-9
RETURN

Delay of 0.5 seconds function ( 10*255*255 * ( 2+1)micros =~ 500,000 micros


= 500 ms= 0.5 seconds

DELAY500MS
MOVLW D'5'
MOVWF REG3
MOVLW D'127'
MOVWF REG2
MOVLW D'255'
MOVWF REG1
DECFSZ REG1,F
GOTO $-1
DECFSZ REG2,F
GOTO $-5
DECFSZ REG3,F
GOTO $-9
RETURN
Microlab File11 – by Joseph Massoud

Exercises ( based on lab91 and lab92)

Repeat lab91 by applying them on the circuit using different length of delays as follow:

1. Lab111 : 1 second

2. Lab112 : 5 seconds

3. Lab113 : 100 milliseconds ( 100ms)

4. Lab114 : 10 milliseconds ( 10 ms)

5. In lab114, what do you notice about the flashing? Interpret.

Repeat lab92 by applying them on the circuit using :

1. Lab115: 2.5 seconds being the starting delay.

2. Lab116: 300 milliseconds being the starting delay.

Extra assignments: (square wave and rectangular wave generator)

1. Write a program lab117 which creates a square wave on output D0 of the pic
having a frequency of 1 KHz. ( If this signal variations cant be recognized on the
led, we will be reading it later on output pin D0 using an oscilloscope in the lab).

2. Write a program lab118 which creates a rectangular wave on output D0 of the pic
having a frequency of 500 Hz and a duty cycle of 80%. ( If this signal variations
cant be recognized on the led, we will be reading it later on output pin D0 using
an oscilloscope in the lab).

GOOD LUCK

You might also like