Hot to handle multiple interrupt sources?


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Hot to handle multiple interrupt sources?

    Hello

    Have you seen this for control of more than one RC servo.

    http://www.darreltaylor.com/DT_INTS-14/SPWM.html

    Another in the Wiki section.

    http://www.picbasic.co.uk/forum/cont...th-2-I-O-lines

    Edit.: Never mind I see from the code you are using servos with encoders
    Last edited by mark_s; - 22nd April 2013 at 01:30.

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Hot to handle multiple interrupt sources?

    I'd suggest getting one motor working first, keep your code as simple as possible as a start. Once that works, add a second motor and see if timing remains stable.

    Figure out if issue is in timer interrupt, or having multiple motors.

    Robert

    Edit: Why GOSUB Encounter? It's only called once that I can see. Why not just plug in the subroutine at the GOSUB?
    Last edited by Demon; - 22nd April 2013 at 02:51.

  3. #3
    Join Date
    Apr 2013
    Posts
    32


    Did you find this post helpful? Yes | No

    Default Re: Hot to handle multiple interrupt sources?

    main loop is STANDUP in this code, and program remains in that main loop until all motors get into position, ENCOUNTER subroutine is called every time loop starts, and I'm counting pulses from encoders with it. My encoders giving a pulse every 5ms at full speed and controller can complete that loop in microseconds, so controller can catch up any pulse and count it or thats what I thought =)
    But I still have question marks in my mind, I didn't change the code in the end, just added DT-INTS and I belive I added them into code properly, but result is not right. I wonder if there are some tips or things about usage of DT-INTS

  4. #4
    Join Date
    Apr 2013
    Posts
    32


    Did you find this post helpful? Yes | No

    Default Re: Hot to handle multiple interrupt sources?

    These are problems I observed in my code with DT-INTS;
    1- There is 3 seconds pause command after defining variables and before start motor controls but motors are starting to run directly when i plug the power cable.
    2- Program cannot go out of STANDUP loop until all of encoders give 50 pulses but although I unplugged4 motors from system without changing the code, remaining 2 motors running , then pausing (not pausing from the start, it looks like it pauses after a jump) and running again and pausing ....
    3- As far as I see, program is not giving a thing about main program and ENCOUNTER subroutine
    4- Interrupt subroutine is working, because motors cannot run before int routine run but nothing else is running...

    I just cant see what is the problem here, maybe I should give up on DT-INTS and use polling methode for multiple interrupts
    Last edited by elcrcp; - 22nd April 2013 at 04:24.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Hot to handle multiple interrupt sources?

    I think Timer starts at top with INT_ENABLE.

    You have PAUSE 3 seconds at bottom of main loop (no idea why).

    DT-INT is by far the easiest method to control interrupts, especially when you have more than one.

    As I said, make a copy of your program and keep code for only 1 motor until you debug your logic. Then add 1 motor and see how that goes. Then all 6 only when logic is perfect.

    Start small. Have you tried DT's beginner examples?

    Edit: I don't see where you set T1CON.
    Last edited by Demon; - 22nd April 2013 at 13:24.

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Hot to handle multiple interrupt sources?

    This is all you need to blink an LED.

    Code:
    LED1   VAR  PORTB.1
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    Main:
      PAUSE 1
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN

  7. #7
    Join Date
    Apr 2013
    Posts
    32


    Did you find this post helpful? Yes | No

    Default Re: Hot to handle multiple interrupt sources?

    This was my trial code, I wrote it with only 1 interrupt source to try DT-INTS so I didn't use TMR1 or any other interrupt source in this code, if I can make this code work then i'll use other sources. I only used TMR0 and set it at the very beginning with "OPTION_REG=%10000100" then providing an interrupt with "TMR0=255"
    Pauses are for observing the system, so I can observe rotation amount before it starts run again.
    timer may be starting with INT_ENABLE as you said, I'll check it, and I'll apply a few more tests too. I'll report results here.
    I didn't try DT beginner examples because I didn't need them but I think I should try them to understand it's logic better.

Similar Threads

  1. port handle
    By kumara in forum Code Examples
    Replies: 6
    Last Post: - 3rd October 2012, 00:32
  2. Two interrupt sources in one program
    By Art in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th January 2012, 16:12
  3. Hot Servos
    By The Master in forum Off Topic
    Replies: 37
    Last Post: - 6th August 2010, 19:32
  4. Multiple interrupt source determination
    By PickyBiker in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th April 2010, 18:32
  5. PIC16F887 cant handle HIGH and LOW?
    By xobx in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th October 2007, 05:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

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