PDA

View Full Version : Timer Of 40 Days 12f675 Or 16f628



Leonardo
- 12th August 2005, 21:46
Hello forum, I am making with 12F675 a timer that ignites PORTB.0 when pressing a pulser in RB.1 and off it to the 40 days but not like doing it, you you can help me please.

Thank you very much

Darrel Taylor
- 12th August 2005, 23:28
Take a look at this Elapsed Timer Demo.

http://www.picbasic.co.uk/forum/showthread.php?t=190

Then, all you need to do is this...
Loop:
if (DaysChanged= 1) and (Days = 40) then
DaysChanged= 0
Gosub ResetTime
' ... Do something here ...
endif
Goto Loop

Leonardo
- 13th August 2005, 01:18
hello Darrel

Thank you for your answer but I cannot compile neither to make the tests because I have the version demo and alone I can make 50 you line, he wanted that somebody helped me and he send me to [email protected] the program to make all the test thank you a lot to the person that helped me.

Thank you





Take a look at this Elapsed Timer Demo.

http://www.picbasic.co.uk/forum/showthread.php?t=190

Then, all you need to do is this...
Loop:
if (DaysChanged= 1) and (Days = 40) then
DaysChanged= 0
Gosub ResetTime
' ... Do something here ...
endif
Goto Loop

Leonardo
- 13th August 2005, 01:23
Darrel,

You can explain to me as making it I don't understand and forgive my ignorance.

Thank you

Leonardo



Take a look at this Elapsed Timer Demo.

http://www.picbasic.co.uk/forum/showthread.php?t=190

Then, all you need to do is this...
Loop:
if (DaysChanged= 1) and (Days = 40) then
DaysChanged= 0
Gosub ResetTime
' ... Do something here ...
endif
Goto Loop

Darrel Taylor
- 13th August 2005, 01:55
Nope, Sorry! It's not going to work with the Demo version.

Come back after you buy PicBasic Pro, and I'll tell you all about it.
<br>

Leonardo
- 13th August 2005, 03:15
Darrel,

Can I make the program with the version demo, if it is can he/she tell this way me as?.

Thank you again







Nope, Sorry! It's not going to work with the Demo version.

Come back after you buy PicBasic Pro, and I'll tell you all about it.
<br>

Darrel Taylor
- 13th August 2005, 17:00
Well, if it doesn't need to be exact, you might do something like this.
Minutes VAR Byte
Hours VAR Byte
Days VAR Byte

Wait40Days:
For Days = 1 to 40
For Hours = 1 to 24
For Minutes = 1 to 60
PAUSE 60000 ; 60 Seconds
Next Minutes
Next Hours
Next Days<BR><BR>

Leonardo
- 13th August 2005, 20:01
Hello Darrel,

Thank you for the code, I want that when push RB.0 he lights the led on RB.1 after the fixed time lapses I have carried out the tests and I have not been able to make it work, you can help me and to say eats up I please make it.

I am using a PIC16F628.

Thank you







Well, if it doesn't need to be exact, you might do something like this.
Minutes VAR Byte
Hours VAR Byte
Days VAR Byte

Wait40Days:
For Days = 1 to 40
For Hours = 1 to 24
For Minutes = 1 to 60
PAUSE 60000 ; 60 Seconds
Next Minutes
Next Hours
Next Days<BR><BR>

Leonardo
- 13th August 2005, 20:19
Darrel,

You helps me with the code so that it works.

Thank you


'************************************************* ***************
'* Name : TIMER 40 DAYS.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2005 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 13/08/05 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
' Turn LED on. Interrupt on PORTB.0 (INTE) turns LED off.

PUSH VAR PORTB.0
LED var PORTB.1


Minutes VAR Word
Hours VAR Word
Days VAR Word


loop:
HIGH LED
GOTO LOOP


OPTION_REG = $7f


Wait40Days:
For Days = 1 to 40
For Hours = 1 to 24
For Minutes = 1 to 60
PAUSE 60000 ; 60 Seconds
Next Minutes
Next Hours
Next Days







Well, if it doesn't need to be exact, you might do something like this.
Minutes VAR Byte
Hours VAR Byte
Days VAR Byte

Wait40Days:
For Days = 1 to 40
For Hours = 1 to 24
For Minutes = 1 to 60
PAUSE 60000 ; 60 Seconds
Next Minutes
Next Hours
Next Days<BR><BR>

Darrel Taylor
- 13th August 2005, 20:25
<table><tr><td nowrap><img src="http://toons.artie.com/alphabet/ralph/arg-n-50-trans.gif"><img src="http://toons.artie.com/alphabet/ralph/arg-o-5O-tRr-a-pl0ase-ns.gif"></td></tr></table><br><br>
Try going here... http://www.melabs.com/resources/index.htm#Manuals<br><br>

Leonardo
- 19th August 2005, 16:48
Hello Darrel, I have bought the PBP and I am happy, if I need its aid I can write to him?.

Thanks

Leonardo






<table><tr><td nowrap><img src="http://toons.artie.com/alphabet/ralph/arg-n-50-trans.gif"><img src="http://toons.artie.com/alphabet/ralph/arg-o-5O-tRr-a-pl0ase-ns.gif"></td></tr></table><br><br>
Try going here... http://www.melabs.com/resources/index.htm#Manuals<br><br>

Dwayne
- 19th August 2005, 17:20
Hello Leonardo,


Minutes VAR Word
Hours VAR Word
Days VAR Word


loop:
HIGH LED
GOTO LOOP


OPTION_REG = $7f


Wait40Days:
For Days = 1 to 40
For Hours = 1 to 24
For Minutes = 1 to 60
PAUSE 60000 ; 60 Seconds
Next Minutes
Next Hours
Next Days


Leaonardo, Dave gave you some wonderful working code... You can do it on your 675 if you want....

Now about your code...

>>
loop:
HIGH LED
GOTO LOOP
<<

None of your pins are assigned to outputs... granded HIGH changes it to OUTPUT, but turn off your AD's and compariters for "Habit" sake.

you have this loop, and it is going to turn on your LED...but never turn it off...

Your interput is not configured properly... check out the manual on how to use interupts...

your subroutine of 40 days is does not have a return, nor does it have a interupt turnoff.

Dwayne

Darrel Taylor
- 20th August 2005, 20:02
Hola Leonardo,

Ahora que usted tiene PicBasic Pro. La manera más fácil de hacer el programa de 40 días es utilizar el primer ejemplo que di al principio de este thread.

Primero, usted necesita Download el programa de
http://www.picbasic.co.uk/forum/showthread.php?t=190

Entonces, intente esto...
<font color="#008000"><b>CLEAR

</b></font><b>Bcount </b><font color="#008000"><b>VAR BYTE

INCLUDE </b></font><font color="#FF0000">&quot;Elapsed.pbp&quot; </font><font color="#0000FF"><b><i>; Include the Elapsed Timer Routines
</i></b></font><font color="#008000"><b>GOSUB </b></font><b>ResetTime </b><font color="#0000FF"><b><i>; Reset Time to 0d-00:00:00.00

</i></b></font><b>Start</b>:
<b>Bcount </b>= <b>0
MainLoop</b>:
<font color="#008000"><b>BUTTON </b></font><b>PORTB</b>.<b>1</b>,<b>0</b>,<b>200</b>,<b>255</b>,<b>Bcount</b>,<b>1</b>,<b>Start40 </b><font color="#0000FF"><b><i>; Wait for button press
</i></b></font><font color="#008000"><b>PAUSE </b></font><b>1
</b><font color="#008000"><b>GOTO </b></font><b>MainLoop

Start40</b>:
<font color="#008000"><b>GOSUB </b></font><b>StartTimer </b><font color="#0000FF"><b><i>; Start the Elapsed Timer
</i></b></font><b>Loop40</b>:
<font color="#008000"><b>IF </b></font><b>DaysChanged</b>= <b>1 </b><font color="#008000"><b>THEN
</b></font><b>DaysChanged</b>= <b>0
</b><font color="#008000"><b>IF </b></font><b>Days </b>= <b>40 </b><font color="#008000"><b>THEN </b></font><font color="#0000FF"><b><i>; Has it been 40 days
</i></b></font><font color="#008000"><b>GOSUB </b></font><b>StopTimer
</b><font color="#008000"><b>GOSUB </b></font><b>ResetTime </b><font color="#0000FF"><b><i>; Reset Elapsed Timer
</i></b></font><font color="#008000"><b>HIGH </b></font><b>PORTB</b>.<b>0 </b><font color="#0000FF"><b><i>; Turn ON output
</i></b></font><font color="#008000"><b>PAUSE </b></font><b>10000 </b><font color="#0000FF"><b><i>; Hold output high for 10 seconds
</i></b></font><font color="#008000"><b>LOW </b></font><b>PORTB</b>.<b>0 </b><font color="#0000FF"><b><i>; Turn OFF output
</i></b></font><font color="#008000"><b>GOTO </b></font><b>Start </b><font color="#0000FF"><b><i>; go back to beginning.
</i></b></font><font color="#008000"><b>ENDIF
ENDIF
</b></font><font color="#0000FF"><b><i>; .. You can do other things here while waiting for 40 days (if needed) ..
</i></b></font><font color="#008000"><b>GOTO </b></font><b>Loop40</b>

Leonardo
- 21st August 2005, 00:11
Hola Darrel,

Gracias por contestarme en mi idioma natal el español, estoy muy agradecido por su ayuda y hare lo que me dice.

Muchas Gracias

Leonard






Hola Leonardo,

Ahora que usted tiene PicBasic Pro. La manera más fácil de hacer el programa de 40 días es utilizar el primer ejemplo que di al principio de este thread.

Primero, usted necesita Download el programa de
http://www.picbasic.co.uk/forum/showthread.php?t=190

Entonces, intente esto...
<font color="#008000"><b>CLEAR

</b></font><b>Bcount </b><font color="#008000"><b>VAR BYTE

INCLUDE </b></font><font color="#FF0000">&quot;Elapsed.pbp&quot; </font><font color="#0000FF"><b><i>; Include the Elapsed Timer Routines
</i></b></font><font color="#008000"><b>GOSUB </b></font><b>ResetTime </b><font color="#0000FF"><b><i>; Reset Time to 0d-00:00:00.00

</i></b></font><b>Start</b>:
<b>Bcount </b>= <b>0
MainLoop</b>:
<font color="#008000"><b>BUTTON </b></font><b>PORTB</b>.<b>1</b>,<b>0</b>,<b>200</b>,<b>255</b>,<b>Bcount</b>,<b>1</b>,<b>Start40 </b><font color="#0000FF"><b><i>; Wait for button press
</i></b></font><font color="#008000"><b>PAUSE </b></font><b>1
</b><font color="#008000"><b>GOTO </b></font><b>MainLoop

Start40</b>:
<font color="#008000"><b>GOSUB </b></font><b>StartTimer </b><font color="#0000FF"><b><i>; Start the Elapsed Timer
</i></b></font><b>Loop40</b>:
<font color="#008000"><b>IF </b></font><b>DaysChanged</b>= <b>1 </b><font color="#008000"><b>THEN
</b></font><b>DaysChanged</b>= <b>0
</b><font color="#008000"><b>IF </b></font><b>Days </b>= <b>40 </b><font color="#008000"><b>THEN </b></font><font color="#0000FF"><b><i>; Has it been 40 days
</i></b></font><font color="#008000"><b>GOSUB </b></font><b>StopTimer
</b><font color="#008000"><b>GOSUB </b></font><b>ResetTime </b><font color="#0000FF"><b><i>; Reset Elapsed Timer
</i></b></font><font color="#008000"><b>HIGH </b></font><b>PORTB</b>.<b>0 </b><font color="#0000FF"><b><i>; Turn ON output
</i></b></font><font color="#008000"><b>PAUSE </b></font><b>10000 </b><font color="#0000FF"><b><i>; Hold output high for 10 seconds
</i></b></font><font color="#008000"><b>LOW </b></font><b>PORTB</b>.<b>0 </b><font color="#0000FF"><b><i>; Turn OFF output
</i></b></font><font color="#008000"><b>GOTO </b></font><b>Start </b><font color="#0000FF"><b><i>; go back to beginning.
</i></b></font><font color="#008000"><b>ENDIF
ENDIF
</b></font><font color="#0000FF"><b><i>; .. You can do other things here while waiting for 40 days (if needed) ..
</i></b></font><font color="#008000"><b>GOTO </b></font><b>Loop40</b>