Timers

General questions about Firewing...

Timers

Postby AndrewB » Sun Oct 23, 2016 4:25 pm

Could somebody help me with timers.

I am trying to make an intervalometer for my camera . Only for my usage.

I have tried to work out how to use timers but having problems.

I need an output that can be triggered every so many min/secs with an exposure of secs/10th of secs

Thanks
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Timers

Postby David John Barker » Mon Oct 24, 2016 10:03 am

what problems are you having?
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: Timers

Postby AndrewB » Mon Oct 24, 2016 10:55 am

Just getting my head round it :)

The example shows a sub with timers set and also similar timers triggered on the main.

Not sure how that works as there is no way to determine which one is which?

I want to have a timer that repeats every set time by vaiable that can be started and stopped.

That first timer also triggers another timer of a set time by variable at its finished event.
This one only triggered by the first.

Sorry but I'm in and out of programming. I bounce around firewing,Picbasic,Venom etc so forget a fair bit.
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Timers

Postby AndrewB » Tue Oct 25, 2016 10:43 am

Any chance of some help please.
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Timers

Postby Jerry Messina » Tue Oct 25, 2016 1:00 pm

Not sure which examples you're looking at, but hardware timers are good for short intervals... they can't typically be used for minutes without extra code to extend them.

If you're having a hard time understanding how they work then maybe just use delay loops?
Code: Select all
dim seconds as ulong          // time to repeat, in seconds
dim exposure as uinteger      // time output is active, in msecs (65535 msecs = 65.535 secs) 

sub WaitSeconds(secs as ulong)
   while (secs <> 0)
      delayms(1000)
      secs = secs - 1
   end while
end sub

Sub Main()
seconds = (5*60) + 30            // repeat every 5 mins, 30 seconds
exposure = (2*1000) + (25*10)   // output high for 2secs, 25 tenths (in msecs)
 
while (true)
   WaitSeconds(seconds)
   high(PORTB.0)
   delayms(exposure)
   low(PORTB.0)
end while
End Sub
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Timers

Postby AndrewB » Tue Oct 25, 2016 1:03 pm

Thanks Jerry.

How would I be able to abort the waitseconds with a button?
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Timers

Postby Jerry Messina » Tue Oct 25, 2016 3:11 pm

Change WaitSeconds to something like....
Code: Select all
dim Button as PORTB.1

sub WaitSeconds(secs as ulong)
   dim msecs as uInteger
   while (secs > 0)
      msecs = 1000                 // wait 1 sec (1000msec)...
      while (msecs > 0)
         delayms(1)
         if (Button = 0) then    // leave if button pressed (PORTB.1 to GND)
            exit sub
         end if
         msecs = msecs - 1
      end while
      secs = secs - 1
   end while
end sub
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: Timers

Postby AndrewB » Wed Oct 26, 2016 10:34 am

Thanks for your help
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Timers

Postby AndrewB » Thu Oct 27, 2016 4:32 pm

Hi Jerry I dont think that routine is aborting the subroutine.

I have a lcd shield
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm

Re: Timers

Postby AndrewB » Thu Oct 27, 2016 6:50 pm

Ok I have rewired the reset to portb.1 and it works ok.

I had tried using the keypress but that bounced the programme and would never stop. I guess its a something to do with making it public?
AndrewB
 
Posts: 94
Joined: Thu Jan 02, 2014 3:38 pm


Return to Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x