### Welcome to our site!

#### Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Status
Not open for further replies.

#### EEs_Rule

##### New Member
Hello everyone,

First I would like to thank everyone for their input on all the other threads. As a newbee I have learned a lot from everyone and checked out most of the tutorials that I saw mentioned in the threads. I am still a little confused on the subject of timers and delays.

I am working on a project which requires two delays, a 20 sec delay, and a 40µsec delay. I am using the PIC12F683. I am not sure what prescale value to use, and which internal clk frequency i should use it with (which is best for a 20 second delay?). Aslo, how do I calculate the value to count down from? I know I cannot just say count down from 20. Any help on this topic will be greatly appreciated.

#### Gayan Soyza

##### Active Member
Since you are using PIC12F683 I'd prefer go with TMR2.

You need three variables,

To generate 20S

Code:
PS=1:1,PR2=249

Count1	= 40
Count2	= 100
Count3	= 20

250 X 40 X 100 X 20 = 20Sec

To generate 40uS

Code:
PS=1:1,PR2=39
40 X 1 X 1 X 1 = 40uS

Last edited:
Status
Not open for further replies.

Replies
2
Views
1K
Replies
0
Views
1K
Replies
9
Views
935
Replies
22
Views
2K
Replies
13
Views
1K