how to create a delay?

19 replies [Last post]
ankit
User offline. Last seen 50 weeks 5 days ago. Offline
Joined: 03/24/2009
bOt Points: 123

I am using DS89C240 ( Dallas) microcontroller. Can you tell me how to create the exact delay of .25s.

bOtskOOl
User offline. Last seen 19 weeks 2 days ago. Offline
Joined: 02/21/2009
bOt Points: 3496
Delay - Frequency

What is the frequency of the crystal being used by you?

ankit
User offline. Last seen 50 weeks 5 days ago. Offline
Joined: 03/24/2009
bOt Points: 123
frequency of crystal

11.0592MHz

bOtskOOl
User offline. Last seen 19 weeks 2 days ago. Offline
Joined: 02/21/2009
bOt Points: 3496
Code for 11.0592 MHz crystal

if you are using a 11.0592 MHz crystal then this program will create a delay of approximately 250ms

 

DELAY:MOV R1, #200

          MOV R2, #139

          MOV R3, #250

N1:     DJNZ R3,N1

N2:     DJNZ R2,N2

N3:     DJNZ R1,N3

RET     ; return to the caller

(in assembly language)

 

In Kiel C

void MSDelay (unsigned int itime)

{

unsigned int i,j,k; // where itime is time in mili second

 

for(i=0;i<250;i++)

for (j=0;j<9;j++)

for(k=0; k<139; k++);

}

shobhitkukreti
User offline. Last seen 16 weeks 5 days ago. Offline
Joined: 04/28/2009
bOt Points: 683
Ankit, try to understand the

Ankit, try to understand the logic behind the creation of that delay. Every instruction will take some time time to execute. In both the programs we explore that same feature. we load Registers R1,R2,R3 with some values, let them decrement and check with a condition. If they fullfill the condition let them move on, if not then jump to specified branch. Here the conditions is to check for zero. This way you can create delays, but here is the catch, to create delays we are considering the execution time of a single instruction. Different controllers have different execution speed, The Dallas DS89 series has a higher than it's counterparts.

heloitsadi
User offline. Last seen 50 weeks 3 days ago. Offline
Joined: 03/15/2009
bOt Points: 1321
LCD delay

do anybody have any idea about setting delay for LCD programming.

bOtskOOl
User offline. Last seen 19 weeks 2 days ago. Offline
Joined: 02/21/2009
bOt Points: 3496
Re: LCD delay

This query has already been answered in a different post. Follow this link

heloitsadi
User offline. Last seen 50 weeks 3 days ago. Offline
Joined: 03/15/2009
bOt Points: 1321
Assembly Program: ORG 0 MOV

Assembly Program:
ORG 0
MOV A, #55H
AGAIN: MOV P0, A
ACALL DELAY
CPL A
SJMP AGAIN
DELAY: MOV R2, #7
HERE1: MOV R1, #255
HERE2: MOV R0, #255
HERE3: DJNZ R0, HERE3
DJNZ R1, HERE2
DJNZ R2, HERE1
RET
END

 

Delay Calculation:
Crystal used= 4 MHz

Clocks per machine cycle for 8051 = 12

Machine cycle frequency = (Crystal Frequency) / (Clocks per machine cycle)
                                        = 4/12
                                        = 0.3333 MHz
Time Period of Machine Cycle = 1/0.33
                                                = 3.003us (microseconds)
No. of machine cycles = 1(for MOV A, #55H) + 1(for MOV P0, A)
                                    = 2 cycles
Total Delay = 7 * 255 * 255 * 2 * 3.003
                   = 2733781.05us
                   = 2.73 seconds

Dinesh (not verified)
IC Usage

Small applications, in wat way we should select a suitable IC.... For example in Wireless Switch circuit IC 3410 ic was used.... This circuit given by our EFY..... I m like to know how they select this IC..... I m waitin for ur great reply..

shobhitkukreti
User offline. Last seen 16 weeks 5 days ago. Offline
Joined: 04/28/2009
bOt Points: 683
Dinesh your question is not

Dinesh your question is not clear, Please explain your problem in detail. Switch to a new thread

Dinesh (not verified)
Circuit Design:

Hello sir,
I want to learn about circuit design and want to know full details about IC .... So please suggest me a good website and good book for me.... It will help me alot... I am waiting for your great reply.... Thanking you...

ankit
User offline. Last seen 50 weeks 5 days ago. Offline
Joined: 03/24/2009
bOt Points: 123
Hello Dinesh, The world of iC

Hello Dinesh,

The world of iC is quite large & we too are ever learning

You should be specific about the thing you wish to study

I will suggest you to start with microcontrollers and while you go for intefacing with things like motors, LCD, wireless, or even if you try  project like making a digital thermometer you shall learn that to do anything in electronics you have an IC

Just try reading some projects or tutorials on this site (hope you have basic electronics knowledge) and you shall learna s you go...

Best of Luck

Keep discussing bro

http://www.botskool.com/tutorials/electronics/general-electronics/motor-...

http://www.botskool.com/tutorials/electronics/8051/introduction-8051-ass...

(8051 is the most basic microcontroller start with it)

You can also refer to Majdi for 8051 refrence, it is an excellent book!!

 

 

vivek_vivek
User offline. Last seen 1 year 9 weeks ago. Offline
Joined: 05/27/2009
bOt Points: 77
listen to me

Can anybody could provide me the hex code for the above assembly code

ROBOTS ARE MY HEART

heloitsadi
User offline. Last seen 50 weeks 3 days ago. Offline
Joined: 03/15/2009
bOt Points: 1321
you can generate it in UMPS

you can generate it in UMPS demo software.. 

heloitsadi
User offline. Last seen 50 weeks 3 days ago. Offline
Joined: 03/15/2009
bOt Points: 1321
Here is the hex code..Just
Here is the hex code..Just use pot1 instead of port0... in your hardware connections
 
 
:100000007455F5901109F480F97A0779FF78FFD8D3
:01001000FEF1
:05001100D9FADAF62225
:00000001FF
 
 

 

abuanas
User offline. Last seen 28 weeks 2 days ago. Offline
Joined: 08/23/2009
bOt Points: 82
header

what header do i use 4 assembly language to include the device just like we use #include<> in keil c51?

sunny123
User offline. Last seen 47 weeks 2 days ago. Offline
Joined: 09/02/2009
bOt Points: 54
Can anybody tell me how to

Can anybody tell me how to generate a time delay 0f 200microsecs using 8051

robo.genius
User offline. Last seen 5 weeks 4 days ago. Offline
Joined: 04/12/2009
bOt Points: 253
Hey abuanas

i dont think u need 2 do anything.. u can directly start with d code.. have u tried doing this?

robo.genius
User offline. Last seen 5 weeks 4 days ago. Offline
Joined: 04/12/2009
bOt Points: 253
sunny

sunny123 check out this link - http://botskool.com/forum/electronics/8051-microcontrollers/how-create-d...
Program give here is for 250ms you can easily adjust d values for 200ms

sikander
User offline. Last seen 20 weeks 3 days ago. Offline
Joined: 05/02/2009
bOt Points: 128
widelar current source

what is the widelar currunt source