timer interupt help 16f73


Closed Thread
Results 1 to 6 of 6
  1. #1
    EDWARD's Avatar
    EDWARD Guest

    Default timer interupt help 16f73

    i was wondering if anyone out there could help me out with using a timer in my program. are there any resources out there that will give me some basics on timer interupts and how to use them. i cant seem to find any examples in picbasic language on how to define the interupt and more importanty how to utilize it. as of now i have my own nested timer with a 1 ms pause:

    X =X +1
    pause 1

    if X > 1000 then
    X = 0
    Z = Z + 1
    endif

    'Z basically holds the numbers of seconds

    this works just fine but i would like to eliminate the 1 ms pause. from what i have read so far the tmr interupts allows for a "multi tasking" type abilty. where the counter keeps on counting regaurdless of the programming running. for example the tmr will continue to count even if i am in the middle of a pause 5000 command or similar. am i correct in this thinking?

    my goal here is to have an output pin going high to low at a rapid pace, as long as an input pin is countues to go high to low at a much slower rate. the simplest way in my mind for this to happen is to have the program run a chunk of code as long as the intcon.1=1 at least once every second.

    suedo:

    some event to put z = 1 to start loop

    start timer to count to 1 second

    while z = 1
    if intcon.1 =1 and timer is below 1 second 'intcon.1 is portb.0 rising edge intrpt
    let z = 1

    do code here

    wend

    this code is a firing sequence for an electro pnumatic airsoft gun. the idea is this. the gun fires in semi auot mode normally, meaning if i pull and HOLD the trigger only one shot will fire. now heres where things get complex.

    there is another firing mode called ramping. and it is not quite semi auto and not quite fully auto. heres how it works. as long as i pull the trigger once every 500ms the gun will shoot at a rate determind in my program. to make the gun shoot all i need to do is this:

    simple firing sequnce (semi auto ONLY in this example) just to give an idea.

    if intcon.1 =1 then 'if trigger is pulled( portb.0 rising edge)
    let intcon.1 = 0 'reset intcon.1
    high portb.5 'turn on solenoid
    pause FT ' FT is the time the bolt stays foward about 2ms to 20ms
    low portb.5 'turn off solenoid
    pause BT ' BT is the time the bolt has to stay back for about 30ms to 70ms
    endif

    so its basicallt fullauto aslong as i update the portb.0 pin once every 500 ms.

    the rate of fire is determined my the BT value.

    the pauses in the FT and BT causes my custom timer to be thrown off, which i knew wuld happen but only way i can get it to work. yes i read the data sheet it tells how to define the timer but not how to use it, as far as i can comprehend.
    Last edited by EDWARD; - 28th June 2005 at 20:48.

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Edward...

    I took a quick look, Maybe this could help you:

    http://www.picbasic.co.uk/forum/show...highlight=Fire

    One thing to remember... in PBP, if you are in a PAUSE 5000, and a interupt is triggered... It will NOT be triggered (subroutine called) until the PAUSE 5000 is over with.

    If you want "instant" triggering (subroutine called), you have to use a ASM Subroutine.


    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Do delay LOOP with PAUSEUS will fix the problem. Let's assume a loop of 5uSec.... not bad. No need to use Assembler interrupt as it's not as this timing critical.

    I hope you don't try to modify a DM4, DM5 or DMC if so, stay away from me in future PaintBall battle... ;o]
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default ha!

    wow mister e u are on the money. i didnt know if people would relate to paintball more over then airsoft, being that airsoft is a little more international. in fact i use a Bob Long intimidator although the dm4, 5 are superior markers. kinda kool that someone in here has heard of paintball and even knows a little somehting about it. well i just got online so i havent tried any of those ideas out yet, but that is a good idea on using the pauseus (pause in micros and not milli) i forgot about that command. ill also check out that link that dwayne was kind enough to add. i dont think that it will be a problem if it occurs during a pause command because 1 or 2 extra shots is acceptable. thanks guys for taking the time to read that long post, i had a lot of trouble try to spit it all out. im gonna try the interpt approch first. ill keep ya updated. thanks

  5. #5
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default any insight?

    I am still having trouble understanding the timer interupt on the 16f73 and how to use it. whatvariable holds the value for the timer? basically i think all i need is something as simple as this follow psuedo code idea.

    while tmr0 is less then 500ms 'tmr0 counts in the background regaurless of pauses.
    gosub ramp
    if trigger pulled reset tmr0
    wend

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Have a look at this thread... it shows how a PICs timers work and gives an interrupt example... may not be exactly what you need, but it's intended as a starting point for interrupts and timers.

    http://www.picbasic.co.uk/forum/showthread.php?t=632

Similar Threads

  1. Help me with interupt
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd February 2009, 00:17
  2. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  3. Is a timer delay accomplished with an interupt?
    By ShortBus in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th September 2007, 22:07
  4. Timer1 and Interupt wierdness
    By mind in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd August 2005, 01:24
  5. 16f73 pwm capture interupt
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd July 2005, 22:22

Members who have read this thread : 2

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