Problems with my "intelligent timer"


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with my "intelligent timer"

    I did it again !

    Code:
    @ Device PIC12F675,INTRC_OSC_NOCLKOUT, WDT_OFF,PWRT_ON,PROTECT_OFF,MCLR_OFF,BOD_OFF
    Include "C:\WIPPER\Elapsed.bas"   ' just wsave(s) removed
    CLEAR
    DEFINE OSC 4
    ANSEL=0       
    CMCON=7
    TRISIO=%00100000
    
    LED         VAR  GPIO.0 ;  sets the GPIO.0 port as LED
    wipp_time   var byte    ;  number of seconds while LED=off
    nr          var bit
    
    nr = 0
    low led
    Gosub ResetTime                ' Reset Time to  0d-00:00:00.00
    
    loop:
    IF GPIO.5 = 0 THEN
      nr=nr+1
         if nr=1 then 
         gosub memo                ' Setting wipe_time 
         else
         GOSUB WIPPER              ' use seconds elapsed as wipe_time
            nr = 0                 ' ready for another setting of wipe_time 
         endif
    if nr > 2 then nr =  0    
    endif         
    goto loop
    
    memo:
    gosub StartTimer
    while gpio.5 = 0
            wipp_time = seconds    ' seconds counts from the beginning of gpio.5 = 0                 
    wend
    Gosub StopTimer
    Gosub ResetTime
    return
    
    
    wipper:
    while gpio.5 = 0
    LED = 1 
    PAUSE 1000
    LED = 0
    PAUSE (wipp_time * 1000)
    wend
    return
    
    END                             ' of story !
    Thanks for support !
    Last edited by fratello; - 6th July 2012 at 11:04.

  2. #2
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with my "intelligent timer"

    Ooooooops !!!
    I build the schematic and I found a BIG issue !!! For value of "wipp_time" bigger than 10 seconds or so ..., if gpio.5 return to "1" BEFORE these seconds, then the counter dont increment ?! At next command (gpio.5=1) programs go to wipper instead memo ! Any ideea ?! Thanks !

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with my "intelligent timer"

    I think in this subroutine the "pause xxx" commands make problems... It's another way to do this ?
    Code:
    wipper:
    while gpio.5 = 0
    LED = 1 
    PAUSE 1000
    LED = 0
    PAUSE (wipp_time * 1000)  ; this command run for (wipp_time * 1000) seconds  even gpio.5 is no more = 0 ?!?
    wend
    return

  4. #4
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Problems with my "intelligent timer"

    How about something like a 'for next' loop:-

    For wipp_time = 1 to 10 ;adjust for your required timing delay
    Next wipp_time
    Last edited by tasmod; - 3rd September 2012 at 18:06.

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with my "intelligent timer"

    Thanks for reply...but wipp_time dont have just 1 to n value ...It's "seconds elapsed between two pushing of button @gpio.5" !
    I dont understand why in "while...wend" command, the failure of condition " gpio.5 = 0" dont stop the "pause (wipp_time * 1000)" command and dont return to master (loop) ...

  6. #6
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Problems with my "intelligent timer"

    You have to write:

    Delay VAR word

    Wipper:
    Delay = wipp_time * 1000
    While gpio.5 = 0
    Pause 1000
    Led = !Led
    If Delay= 0 then Skip_0
    Pause 1
    Delay = Delay - 1
    Skip_0:
    Wend
    Return


    Cheers

    Al.
    All progress began with an idea

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Problems with my "intelligent timer"

    Thank You !
    ...but the schematic dont work if I wish ...
    Code:
    @ Device PIC12F675,INTRC_OSC_NOCLKOUT, WDT_OFF,PWRT_ON,PROTECT_OFF,MCLR_OFF,BOD_OFF
    Include "C:\WIPPER\Elapsed.bas"   ' just wsave(s) removed
    CLEAR
    DEFINE OSC 4
    ANSEL=0       
    CMCON=7
    TRISIO=%00100000
    
    maneta      var gpio.5
    LED         var GPIO.2         ' set GPIO.0 port as OUTPUT (LED)
    wipp_time   var byte           ' number of seconds while LED=off
    nr          var bit
    delay       var word
    
    nr = 0
    low LED
    Gosub ResetTime                ' reset Time to  0d-00:00:00.00
    
    Main:
    IF GPIO.5 = 1 then
      nr=nr+1
         if nr=1 then 
            gosub memo             ' set wipe_time 
         else
            gosub wipper           ' use seconds elapsed as wipe_time
            nr = 0                 ' ready for another setting of wipe_time        
         endif
    if nr > 2 then nr =  0     
    ENDIF    
    Goto Main
    
    memo:
    gosub StartTimer
        while maneta = 1
          	wipp_time = seconds    ' seconds counts from the beginning of gpio.5 = 0                 
        wend
    Gosub StopTimer
    Gosub ResetTime
    return
    
    
    Wipper:
    Delay = wipp_time * 1000
    While gpio.5 = 1
    Pause 1000
    Led = !Led
    If Delay= 0 then Skip_0
    Pause 1
    Delay = Delay - 1
    
    Skip_0:
    Wend
    Return
    Attached Files Attached Files

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