timer interupt help 16f73


Results 1 to 6 of 6

Threaded View

  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.

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 : 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