onof timer


Closed Thread
Results 1 to 7 of 7

Thread: onof timer

  1. #1
    Join Date
    Jun 2006
    Posts
    20

    Default onof timer

    can any one help i need to turn on 1 pin of a pic16f84a for 3 min then off for 3 min repeted for 15 mins then off for 45 min here is the code i have tryed
    i use microcode studio and pic basic pro

    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 7/2/2007 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    b0 var byte
    b1 var byte
    b2 var byte
    trisb.1 = 0
    seqsta:
    b0 = 1
    b1 = 0
    portb.1 = b0
    sleep 180
    if b2 = 3 then slep
    for b2 = 0 to 3
    b1 = b0 * 2
    b0 = b1
    portb.1 = b0
    sleep 180
    next b2
    slep:
    sleep 2700
    goto seqsta

    any help with this would be much apprecated

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by andrewwaack View Post
    can any one help i need to turn on 1 pin of a pic16f84a for 3 min then off for 3 min repeted for 15 mins then off for 45 min here is the code i have tryed
    i use microcode studio and pic basic pro
    Looks to me like you might be over-thinking the problem just a bit...

    Assuming portb.0 is the pin you want to turn on and off...

    main:
    high portb.0
    sleep 180 '3 minutes
    low portb.0
    sleep 180 '6 minutes
    high portb.0
    sleep 180 '9 minutes
    low portb.0
    sleep 180 '12 minutes
    high portb.1
    sleep 180 '15 minutes
    low portb.0
    sleep 2700 '45 minutes
    goto main

    or in 'skimask format'
    x var portb.0 : output x : x = 0
    main: x=1:sleep 180:x=0:sleep 180:x=1:sleep 180:x=0:skeep 180:x=1:sleep 180:x=0:sleep 2700:goto main
    end

  3. #3
    Join Date
    Jun 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Talking you's are legends

    thanks for your rapid responce if you have any more sugestions for this problem it would be great



    thanks andrew

  4. #4
    Join Date
    Jun 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default me again

    is there a way of making this code more accurate


    main:
    high portb.0
    sleep 190 '3 minutes
    low portb.0
    sleep 190 '6 minutes
    high portb.0
    sleep 190 '9 minutes
    low portb.0
    sleep 190 '12 minutes
    high portb.0
    sleep 190 '15 minutes
    low portb.0
    sleep 2700 '45 minutes
    goto main



    thanks andrew

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Without a timer chip? I guess not. The example by skimask is based on the watchdog of the PIC, which is innacurate by itself very much (look at 5.77 of the manual).

    Another option might be the elapsed timer by Darrel Taylors Instant Interrupts. But, maybe too complicated for what you want.

    Ioannis

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by andrewwaack View Post
    is there a way of making this code more accurate
    Learn how to use the TIMER interrupts...
    Put the PIC to sleep using the sleep instruction, let the TIMER interrupt wake up the PIC, increment a counter to keep track of elapsed seconds/milliseconds/minutes/hours/whatevever, take whatever action is neccessary based on elasped time, put the PIC back to sleep.

  7. #7
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile How accurate does it have to be?

    Quote Originally Posted by andrewwaack View Post
    is there a way of making this code more accurate thanks andrew
    Hi Andrew,

    Ski and Ioannis are right. Search the forum.

    Take a look at Darrel’s Elapsed Timer Demo
    http://www.picbasic.co.uk/forum/showthread.php?t=190
    There is a lot of information, but you may be able to use the parts needed for your project.

    How accurate does it have to be? Tell us something about the project.
    -Adam-
    Ohm it's not just a good idea... it's the LAW !

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  3. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  4. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  5. timer interupt help 16f73
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd July 2005, 08:41

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