Delayed output 10 secs


Closed Thread
Results 1 to 38 of 38

Hybrid View

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


    Did you find this post helpful? Yes | No

  2. #2
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Its all good now!

    Thanks

    Mike

  3. #3
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Trying out the "Elapsed Timer" I am observing these issues:

    Beeing that I don't have an LCD module, I am trying to write the values in EEPROM and then read back using a PICKit2.

    I know the code is working because LED1 is blinking and the rate seems to be good.

    My first write is succesful
    then trying to write the value for "Seconds" is always 00
    trying to write the value for Minutes is always FF (even after a few minutes)


    Code:
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    INCLUDE "Elapsed_INT.bas"  ; Elapsed Timer Routines
    LED1 var portc.0
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE            ; Creates the interrupt processor
    
        INT_ENABLE  TMR1_INT  ; Enable Timer 1 Interrupts  
    ENDASM
    
    GOSUB ResetTime           ' Reset Time to  0d-00:00:00.00
    GOSUB StartTimer          ' Start the Elapsed Timer
    
    write 5,3 ; this is working fine.
    
    Main:
      IF SecondsChanged = 1 THEN  
         SecondsChanged = 0
         toggle led1
         T1CON.0 = 0
         write 0,Minutes  ; this is always showing 00
         write 1,Seconds  ; this is always showing FF
         'LCDOUT $FE,2, DEC Days,"d-",DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds
      ENDIF
    GOTO Main
    Am I missing something?

    Thanks

    Mike

  4. #4
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    I tried adding DEFINE WRITE_INT 1 but still getting same results

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


    Did you find this post helpful? Yes | No

    Default

    The T1CON.0 = 0 line is turning off the Timer.
    So it never counts again.

    At the start of the program, the SecondsChanged bit is set so that programs will display the initial 00:00:00.

    So it stops counting before the first second passes.
    <br>
    DT

  6. #6
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    Some days I feel dumber than others and today is one of those!

    I tried joining this code with my code and things are not going so well... I have a piezo beeping on the press of the swithes and when I added this code it is more like rigning than beeping and also I have a feeling I need something short and simple but I am trying to use something big and complex.

    All I really need is to have a counter that counts the minutes up to 720 and then cycle to 0 and start over endlessly. I don't need an interupt as I can test compare by branching from the main loop (in one minute I have plenty of time to test) Accuracy is not really important + or - 10 minutes over 720 is ok. I am already using timer0 so I guess I need to use timer1 or timer2.

    Do you have any simple and quick advice or link to suggest?

    I feel I have taked already too much of your time and I apologize for that.

    Mike

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lilimike View Post
    Some days I feel dumber than others and today is one of those!


    All I really need is to have a counter that counts the minutes up to 720 and then cycle to 0 and start over endlessly. I don't need an interupt as I can test compare by branching from the main loop (in one minute I have plenty of time to test) Accuracy is not really important + or - 10 minutes over 720 is ok. I am already using timer0 so I guess I need to use timer1 or timer2.
    Mike
    Hi Mike,
    Welcome to My World!
    Code:
    counter var byte
    minutes var word
    clear  ' zero variables at start
    loop:
    
    PortB  = %00000000
    TRISB  = %00000000
    counter = counter + 1
    Pause 1000
    If counter >= 60 then minutes  = minutes + 1 : counter = 0
    
    if minutes >= 720 then gosub action
    goto loop
    
    Action:
    minutes = 0
    Toggle PortB.1 ' change this to do what you need done
    return
    A great clock this will not be, it does (should do) what you asked, you may need to juggle the numbers if you have a bunch of code to stuff in.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lilimike View Post
    Some days I feel dumber than others and today is one of those!
    Well, that in itself implies there are days when you don't feel that way ...
    Only prior instances of feeling "Smart" can make you recognize the "dumb" when it comes around.
    Let's see if we can't make tomorrow a little better.

    At first I was trying to make it easy with an example Without Interrupts.
    Then you found my interrupt program, and the Elapsed Timer.
    Combining the two has no doubt created the headaches.

    I've tried to figure out what you were doing from the previous posts, and failed.

    If I could see what you had so far, I might be able to combine things using only DT_INTS.
    Who knows?
    <br>
    DT

Similar Threads

  1. How to drive the Vinculum VDIP1 in UART mode
    By BrianT in forum Code Examples
    Replies: 41
    Last Post: - 23rd May 2013, 13:34
  2. USB-FTDI[UM232R] with PIC16f877a
    By bjox in forum USB
    Replies: 1
    Last Post: - 23rd February 2008, 23:40
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46
  4. Serial Output 10 Bits
    By GEEZER in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th May 2005, 03:14
  5. Using 4 input to control 10 output
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th November 2004, 13:08

Members who have read this thread : 0

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