Temporary central repository of Darrel Taylor's works (including Mr E's Multicalc)


Results 1 to 40 of 55

Threaded View

  1. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer Demo

    It keeps running in the background.
    The interrupts will not wait for PBP statements to finish.

    Ok fine, ... for many years I've resisted making a count down elapsed timer for humanitarian reasons.
    But if you guys are going to do it anyhow, I might as well make a new version of the Elapsed Timer.
    I can only hope that if somebody uses it for nefarious purposes, they end up blowing themselves up.

    Here's the test circuit.



    Here's the test program ...
    Code:
    ' Define LCD connections
    DEFINE LCD_DREG PORTC   ' Set LCD Data port
    DEFINE LCD_DBIT 4       ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTC  ' Set LCD Register Select port
    DEFINE LCD_RSBIT 2      ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTC   ' Set LCD Enable port
    DEFINE LCD_EBIT 3       ' Set LCD Enable bit
    DEFINE LCD_BITS 4       ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2      ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2000 'Command delay time in us
    DEFINE LCD_DATAUS 50 'Data delay time in us
    
    DEFINE  OSC 4
    
    INCLUDE "Elapsed_DN.bas"  ; Elapsed Timer Routines
    
    ZERO_LED   VAR PORTB.3
    
    ANSEL = 0                 ' All Digital
    ANSELH = 0
    LOW ZERO_LED              ' start with LED OFF
    OPTION_REG.7 = 0          ' enable PORTB pull-ups
    PAUSE 250                 
    LCDOUT $FE,1              ' Initialize LCD
    PAUSE  250
    
    Days = 1                  ' set initial time
    Hours = 1
    Minutes = 3
    Seconds = 10
    
    GOSUB StartTimer          ' Start the Elapsed Timer
    
    Main:
    CountDown = !PORTB.0
      IF SecondsChanged = 1 THEN  
         SecondsChanged = 0
         LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
      ENDIF
      IF ZERO_LED != ZERO THEN ZERO_LED = ZERO
    GOTO Main
    If the button on PORTB.0 is pressed it counts down.
    If it is not pressed, it counts up.
    The LED comes on when it reaches 0.

    If you are using the countdown for a movie set, it has to stop at 1 second.
    Put this in the main loop.
    Code:
      IF (CountDown=1) AND (Days=0) AND (Hours=0) AND (Minutes=0) and (Seconds=1) _
          THEN GOSUB StopTimer
    You'll need the ASM_INTS include from the original Elapsed Demo.
    Attached Files Attached Files
    DT

Similar Threads

  1. Darrel Taylor Interrupts and MultiCalc
    By AvionicsMaster1 in forum General
    Replies: 6
    Last Post: - 14th February 2012, 06:18
  2. Question on Mister E's PIC MultiCalc.
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th December 2011, 13:37
  3. Darrel Taylor's SPWM code usage
    By Homerclese in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th July 2010, 14:13
  4. using darrel taylor's instant interrupts
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st July 2007, 04:07
  5. Replies: 18
    Last Post: - 23rd May 2006, 05:57

Members who have read this thread : 7

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts