Yesterday 23:49
Forum: Proton Plus Compiler v3
Starter: xldaedalus
Views: 0
Replies: 11
Go to last post By: tumbleweed
Yesterday 19:54
Forum: Proton Plus Compiler v3
Starter: joesaliba
Views: 0
Replies: 4
Yesterday 18:02
Forum: Proton Studio
Starter: GAMBOA
Views: 0
Replies: 1
Yesterday 14:28
Forum: Timer Modules
Starter: See_Mos
Views: 0
Replies: 1
Yesterday 14:23
Forum: The Lounge
Starter: craig
Views: 0
Replies: 24
+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: Simple timer5 days old

  1. #1
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    51
    Thumbs Up
    Received: 33
    Given: 4
    Total Downloaded
    5.95 MB

    1 Not allowed!

    Default Simple timer

    Iam making a simple timer for 60 seconds with setpoint.suppose if I set 45 then timer start with a pulse and when I get 0 then timer stop.

    I tried but Iam not able to place set value.
    Pls help.

  2. #2
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,346
    Thumbs Up
    Received: 83
    Given: 23
    Total Downloaded
    3.86 GB

    0 Not allowed!

    Default Re: Simple timer

    Post your code and please explain a bit better what you want.
    Regards

    Joseph

  3. #3
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    51
    Thumbs Up
    Received: 33
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Simple timer

    my Code

    Device = 16F877A
    Xtal = 16
    Include "MODEDEFS.BAS"
    All_Digital = True
    Declare LCD_DTPin = PORTB.4
    Declare LCD_RSPin = PORTB.2
    Declare LCD_ENPin = PORTB.3
    Declare LCD_Interface = 4
    Declare LCD_Lines = 4
    Declare LCD_Type = 0

    Dim onn As Byte

    TRISA=1
    TRISC=%11111111
    TRISB=0
    TRISD=%11111110
    TRISE=0

    main:

    If onn=0 Then PORTB.1=0 ;relay on
    If onn < 0 Then PORTB.1=1 ;relay off
    DelayMS 1000
    If PORTD.7=1 Then onn=onn-1 ;timer start decreasingly when d.7 is high
    If PORTD.6=1 Then onn=onn+1 ;set point


    Print At 1,1,"IN=",Dec0 onn," "

    GoTo main

  4. #4
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    51
    Thumbs Up
    Received: 33
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Simple timer

    Lcd should display INJ=60 .suppose by button I set 60 to 45 .now by an input pulse timer starts 44,43,42,41,40.....till zero .when it reaches 0 then a relay should on.After on an input pulse will be given to make timer to reset to 45 again and relay to off position again.

  5. #5
    Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    375
    Thumbs Up
    Received: 67
    Given: 0
    Total Downloaded
    118.16 MB

    0 Not allowed!

    Default Re: Simple timer

    Code:
    Dim onn As Byte
    
    If onn < 0 Then PORTB.1=1 ;relay off
    A 'byte' is unsigned, so it can never be negative (< 0)

    If you subtract 1 from a byte that's = 0 you'll get 0xff (255)

  6. #6
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    51
    Thumbs Up
    Received: 33
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Simple timer

    Sorry it's equal to = sign

  7. #7
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,190
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    407.03 MB

    0 Not allowed!

    Default Re: Simple timer

    Hi,
    I dont think you need the 0 (Dec0)

    I think you also need to have
    If PORTD.7=1 and onn > 0 Then PORTB.1=0 ;relay on 'only turn relay on if start is on and timer greater than zero
    If onn = 0 Then PORTB.1=1 ;relay off
    andIf PORTD.7=1 and onn > 0 Then onn=onn-1 ;timer start decreasingly when d.7 is high
    if you do not have the and condition onn > 0 it will roll over to 255 and the timer will start again

    You could simplify it to
    If PORTD.7=1 and onn > 0 Then
    PORTB.1=0 ;relay on 'only turn relay on if start is on and timer greater than zero
    Dec onn
    Else
    PORTB.1=1 ;relay off
    Endif

    Regards,
    Bob


    Last edited by RGV250; 11th October 2018 at 21:22.

  8. #8
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    51
    Thumbs Up
    Received: 33
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Simple timer

    Giving error 'incorrect else'

  9. #9
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    51
    Thumbs Up
    Received: 33
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Simple timer

    Dear Bob,
    I also need an end condition when timer reaches 0.it do not start again.if I want to start again then input pulse will be given again.

  10. #10
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    51
    Thumbs Up
    Received: 33
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Simple timer

    Dear Bob,
    Timer maximum time is 60 sec.setpoint can be between 0 to 60 sec.if I set 45 then each time timer start from 45 sec till it reaches 0.when it reaches 0 then relay should start.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. simple timer query
    By staffstony in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 18th July 2008, 09:11
  2. How to turn 8-bit timer into 16-bit timer?
    By HelpMe! in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 29th October 2007, 20:08
  3. Timer example
    By smclark in forum The Lounge
    Replies: 8
    Last Post: 6th September 2007, 17:04
  4. [SOLVED !] Timer
    By FabioPedro in forum The Lounge
    Replies: 5
    Last Post: 9th June 2007, 21:49
  5. simple second timer
    By crankshaft in forum Proton Plus Compiler v3
    Replies: 17
    Last Post: 27th May 2007, 01:14

Posting Permissions

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