using RTC to time 1 second pause

andyshrimpton

New Member
I have spent most of the day getting no where fast.

I have a DS1307 RTC clock set up and running thanks help from Westaust55

It pulses an LED once per second, i also have an LCD showing me the time and date, clocking nicely

In my current project i am using the pause command to wait a second, this is not accurate as i have many "if" statements that makes a countdown timer and depending where it jumps out of the "if" staements effect the time accuratacy when timing more than a few minutes

Instead of using a pause 1000 command, can a use the output on the flashing LED (one per second). So if the LED is HIGH the programme with continue, as all of my "if" statement take less than i would say 0.3 of a second to complete, the code should complete all of the "if" staement and then wait for the LED to go high, meaning a second has passed for it to continue.

Thanks

Andy
 

andyshrimpton

New Member
Using RTC to pause code fro 1 second

Here is part of the code

The pasue statement at the start try to stop the code from running for 1 second (4000=1 second i have reduced to to take into acount if the if statements)

I am trying now to use a hintsetup command to try and detect when the LED on the RTC goes high.

My idea is when the led is high a second must have past since it was high last time and it will let the code continue.

So as long as the "IF" statement take less than a second to execute, which they do, no matter where the the code jumps out of the "IF" statements the code should always pause for 1 second. I hope

I may not be using the right command here but i thought "hinsetup" mite work

'pause 3770 'wait 1 second = 3774=2 mins fast over 10 hours
if cddays=0 and cdthours=0 and cdtmins=0 and cdtsec=0 then cdfin
 
Last edited:

eclectic

Moderator
Can I suggest that you provide
an simple plan/overview of your project?

What are you trying to achieve?
What are you measuring?

Picaxe?
Frequency?

And so on.....

e
 

andyshrimpton

New Member
I am trying to get a 28X2 chip to pause the code for one second until it recieves a "high" from the RTC.

I am trying to set pin B.2 to look at the signal from the RTC.

If the signal is low the code will loop around itself waiting for the signal to go high.

once high the code will continue.

I now do not thick the interupets is the way forward they must be something simple

I have tried

do
loop until pinsB.2=1
 

eclectic

Moderator
I am trying to get a 28X2 chip to pause the code for one second until it recieves a "high" from the RTC.

I am trying to set pin B.2 to look at the signal from the RTC.

If the signal is low the code will loop around itself waiting for the signal to go high.

once high the code will continue.

I now do not thick the interupets is the way forward they must be something simple

I have tried

do
loop until pinsB.2=1
Getting closer. :)

1. AFAIK, the signal is 0.5s on / 0.5s off.

2. Do you have an oscilloscope to do tests?

e
 

ValueAdd

Senior Member
Still not entirely clear, to me at least, what the overall program is doing and how it is interacting to start the required 1 second pause interacting.

Okay so far we know:
- the PICAXE is to wait for 1 second until an input goes high.
- there are a set of "IF" statements that will take kless than 1 second to go thru

questions
- exactly what instigates the 1 second pause
- where is that pause in the program

as eclectic has previously requested, post a "simple plan/overview of your project" and you may get a better response.
 

MartinM57

Moderator
Untested...

Code:
do
   'wait to go high
   do
   loop until pinsB.2=1

   <do stuff>

   'wait to go low which will be:
   '- 0.5 seconds later than the go high
   '- so you will wait here if <stuff> takes < 0.5 seconds
   'Or if <stuff> takes more than 0.5 seconds, you will wait here for just one do:loop
   do
   loop until pinsB.2=0

'...and again
loop
 

kevrus

New Member
Could you not use the 'settimer' command, and with 'setintflags' to detect the correct no. of ticks for the interrupt.
Remember to reset the 'toflag' bit back to zero each time. Page 211 in the manual has the details.
 
Top