Interrupt won't execute.


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Thumbs down

    Hi, Jumper

    DT Basic Interrupts are wayyy too slow, here ... and overall their execution time is not predictable for timing corrections ...

    so, no joy nor !

    You do have to deal with ASM ... or write the program in pure PBP, without any interrupts ...

    Alain

    PS: and do not forget DT Bas ints consume a lot of RAM ...

    @ BB

    Does this mean there's another way of doing this without interrupts?

    Bear in mind that I need to expand this to running two servos at once.
    I alredy built a 4 channels fail-safe in pure PBP ... 4 Channels to read and 4 channels to output ... so, your project looks quite doable.
    Writing a neat timechart ... of course.
    Last edited by Acetronics2; - 25th March 2010 at 10:33.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Mar 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Unhappy One last question.

    alright Ace, I give in, you've got me in dispair with this project, I'll look for a totally different way.

    I alredy built a 4 channels fail-safe in pure PBP ... 4 Channels to read and 4 channels to output ... so, your project looks quite doable.
    Writing a neat timechart ... of course.
    Is this something you've released that I can learn from or even adapt?

    If I can't see the code, can you give me some hints about the way forward?

    I don't mind all the time charts in the world, but what's it for?

    I'll stop bothering you now, time for bed.

    Either way, thanks for the help, it's good to know when the idea you've got is impossible, that way you can move on; even if it is disheartening. Sniff...

    I'll check out DT's interrupts anyway - always learning.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Ok BB

    First of all ...

    explain with clear words what your device has to do :

    from which inputs (w/ details ) to which outputs ( w/details ) ...

    50% of the work is here ...

    Alain

    PS: and stop thinking " C " ... you must think " Basic " now ! ( ROFL)
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    DT Basic Interrupts are wayyy too slow, here ... and overall their execution time is not predictable for timing corrections ...
    Too Slow???
    For a Servo??? Get real.
    I've run 16 servo's simultaneously with DT_INTS.

    Timing not predictable??? What???
    It's extremely predictable. What are you talking about?

    PS: and do not forget DT Bas ints consume a lot of RAM ...
    oooo, ~50 bytes to have super easy interrupts, yeah too much RAM.

    Quote Originally Posted by bison_bloke
    alright Ace, I give in, you've got me in dispair with this project, I'll look for a totally different way.
    Don't listen to Alain.
    He's just being obstinate.
    DT

  5. #5
    Join Date
    Mar 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Ok, let's see if we can make something of this mess...

    I've run 16 servo's simultaneously with DT_INTS.
    Does this mean there's code out there that I can directly adapt?

    Where would I find this?

    explain with clear words what your device has to do :

    from which inputs (w/ details ) to which outputs ( w/details ) ...
    I have two inputs: start/stop button and a 'selector switch' which I already have working with that if statement you see above.

    I have three outputs: two servos that I need to 'bounce' independently of each other. I need them to simulate the somewhat random movements that a passenger in a car would experience whilst driving. The third input is for vibration, this is just an unbalanced DC motor - np.

    I also want to run a countdown timer so that it gets turned of after 20mins.

    50% of the work is here ...
    So now that my project is exactly half done, which way do I head?

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bison_bloke View Post
    Does this mean there's code out there that I can directly adapt?

    Where would I find this?
    Well, that program is extensive ... each channel has it's own Center Trim, Gain and 10-bit positions, with stored programmed movements.
    Never released it. Because I'd have to support it.

    But since you don't seem to mind ON INTERRUPT ... there's a sample at meLabs for the LAB-X1 board.
    It drives 2 servos using interrupts.
    Has buttons, an LCD ... sounds just like what you wanted.

    servosx.bas
    http://melabs.com/resources/samples.htm
    <br>
    DT

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by bison_bloke View Post
    I have two inputs: start/stop button and a 'selector switch' which I already have working with that if statement you see above.

    I have three outputs: two servos that I need to 'bounce' independently of each other. I need them to simulate the somewhat random movements that a passenger in a car would experience whilst driving. The third input is for vibration, this is just an unbalanced DC motor - np.

    I also want to run a countdown timer so that it gets turned of after 20mins.



    So now that my project is exactly half done, which way do I head?
    Hi, BB

    Just missing : is both servos position given by a unique " selector pot " ( 6 positions , if I have correctly understood ) , so both servos receive same driving pulse ???

    Alain

    For the Heading ...

    I'd propose you a " system clock " @ 50 Hz ... with a timer interrupt ( very, very simple kind of interrupt ). And as 20 mins = 60000 " ticks " @ 50 Hz ... it's done

    If you think to it, tasks are done in a linear way and the whole sequence is repeated @ 50 Hz ...

    so, just let me an hour to open the '690 Datasheet ( never worked with this chip to the day ) ...
    Last edited by Acetronics2; - 26th March 2010 at 08:28.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Mar 2010
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Both servos will run on different signals. There will be no pots involved.

    The user selects a 'program' from the selector switch, hit's start, and a predefined program controls everything from there. The servos will almost always be in different positions to each other.

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Have a look to your PMs ... and enjoy

    @ Darrel : Do not look at it ... you won't like at all ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking

    Hi,

    Here it is for Everyone ...

    a running version with a 16F877a and EasyPic 5 .

    still something to debug with HSEROUT, probably a timing issue ...

    Code:
    '****************************************************************
    '*  Name    : AdcServo2 : the ultimate vibrator ...             *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 01/10/2008                                        *
    '*  Process.: 16F877a / EasyPic5                                *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************' 
    
    '******************************************************************************
    ' Config
     @ device HS_OSC , WDT_ON , PWRT_ON , BOD_ON , LVP_OFF , protect_OFF
    
    '******************************************************************************
    'Defines
    
    DEFINE OSC 8
    
    DEFINE INTHAND _MAINLOOP
    
    DEFINE HSER_TXSTA 20h       'SET THE TRANSMIT REGISTER TO TRANSMITTER ENABLED
    DEFINE HSER_BAUD 9600       'SET BAUD RATE
                                'DEFINE ADCIN PARAMETERS
    DEFINE ADC_BITS	10          'SET NUMBER OF BITS IN RESULT
    DEFINE ADC_CLOCK 3          'SET CLOCK SOURCE (3=RC)
    DEFINE ADC_SAMPLEUS 50	    'SET SAMPLEING TIME IN uS
    
    DEFINE LCD_DREG PORTB               ' I/O port where LCD is connected
    DEFINE LCD_DBIT 0					' 0, 1, 2, 3
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4                  ' Register select pin
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5                   ' Enable pin
    DEFINE LCD_BITS 4                   ' 4-bit data bus
    DEFINE LCD_LINES 2                  ' LCD has 2 character lines
        
    '******************************************************************************
    ' Comparator Config  
    
    CMCON       = %00000111
    
    '******************************************************************************
    ' Adc Config
    
     ADCON0     = %11000001     'SET PORTA ANALOGUE AND RIGHT JUSTIFY THE RESULT
     ADCON1     = %10001110     
      
    '******************************************************************************
    ' TMR1 Config : Preset = 45543  - Prescaler 1 
    ' 
    T1CON       = %00000000          'SETS THE TIMER1 VALUES - PRESCALER = 1
    
    '******************************************************************************
    ' Interupts config
    
     INTCON     = %11000000         ' GIE + PIE
     PIE1       = %00000001         ' TMR1IE
     PIR1       = 0
     PIE2       = 0
     PIR2       = 0
     
    '******************************************************************************
    'Variables
    
    wsave       var byte $20   system   ' just to avoid a compilator error ...
    wsave1      var byte $a0   system
    wsave2      var byte $120  system
    wsave3      var byte $1a0  system
    
    ssave       var byte Bank0 system
    psave       var byte Bank0 system
    
    
    
    POSITION    VAR WORD        'POSITION OF SERVO1 1250 - 2500
    TEMP        var word
    PLOW        var word        'low part of the servo signal
    COUNTER     var word        'Timeout counter
    PRESET      var word
    
    Delay       var BYTE
    RUN         VAR BIT         'IS THE PROGRAM RUNNING
    
     
    '******************************************************************************
    'Aliases
    
    GIE         var INTCON.7
    PEIE        var INTCON.6 
    TMR1IE      var PIE1.0
    TMR1IF      var PIR1.0
    TMR1ON      var T1CON.0
    
    '******************************************************************************
    ' Variable presets
    
    
    RUN         = 0                     'TEMPORARY VARIABLE FOR SERVO RUNNING
    POSition    = 150                   ' Servo @ RestPositon.   
    counter     = 0                     ' timeout counter
    PRESET      = 25555
    TMR1H       = Preset.Highbyte       ' Must be initialized ...
    TMR1L       = Preset.Lowbyte
    
    '******************************************************************************
    ' Constants
    
    SELECTOR    CON 0                   'Assign selector ADC Input to AN0
    
    '******************************************************************************
    ' I/Os
    
    SERVO1      var PORTC.0             'OUTPUT PIN FOR SERVO1
    STARTSTOP   VAR PORTA.4             'INPUT PIN FOR PUSHBUTTON
    
    PORTA = %00010111
    PORTB = 0
    PORTC = 0
    PORTD = 0
    PORTE = 0
    
    TRISA = %00000011
    TRISB = 0
    TRISC = 0
    TRISD = 0
    TRISE = 0
    
    Pause 500
    LCDOUT $FE, 1        ' Clear display, cursor off
                   
    '******************************************************************************
    '******************************************************************************
    
    MAINLOOP: ' Here we start a cycle ...
    
    TMR1on      = 0                     ' Reload the timer ...
    TMR1H       = PRESET.Highbyte
    TMR1L       = PRESET.Lowbyte
    TMR1IF      = 0
    TMR1ON      = 1                     ' Restart the timer
    GIE         = 1                     ' Interrupts authorized
    
    IF run THEN                         ' Run Button has to be pushed for first move
    
    FINDPROGRAM:                        'SELECTS BETWEEN SEVERAL TYPES OF MOTION
    
        ADCIN Selector , TEMP          'READ CHANNEL 10 TO TEMP
        
        SELECT CASE TEMP
        
        	Case is <  250  
        	 	POSITION = 125
    
            Case is <= 366 
         		POSITION = 150
         		    
        	Case is <= 583
        	 	POSITION = 175
        	 	  
        	Case is <= 783
        		POSITION = 200
        		    
        	Case is <= 1000  
         		POSITION = 225
         		   
        	Case is >  1000  
         		POSITION = 250
         		
         End Select
        
        low servo1
        Pulsout Servo1, position
        
        PLOW = 20000-POSITION
        
            
        IF COUNTER.5 OR ! COUNTER THEN
            'HSEROUT ["HIGH =" , DEC POSITION, " LOW =", DEC PLOW, 10,10,13]
            LCDOUT $FE,2 ,"Position = ",dec position,"    ", $FE,$C0,"TEMP = ", dec TEMP,"     "                                       
        Endif
    else
    
         
        IF COUNTER.5 OR ! COUNTER THEN
            'HSEROUT ["Waiting for RUN", 10,10,13,"HIGH =" , DEC POSITION, " LOW =", DEC PLOW, 10,10,13]
            LCDOUT $FE,2 ,"Waiting for RUN", $FE,$C0,"Position = ", dec position
        ENDIF
    endif
    
    '******************************************************************************   
    TESTINPUTS:
    
    Delay = 0
    Button Startstop,1,255,0,Delay,0,jump    ' Button active LOW !!!
    
    IF RUN THEN COUNTER = counter + 1
    IF counter => 60000 then counter = 0 :goto jump
    
    stop                                     ' Stop here and wait for interrupt
                                                ' to launch a new cycle
    JUMP:
    WHILE STARTSTOP = 0 : wend  
    RUN = ~run
    stop                                     ' Stop here and wait for interrupt
                                                ' to launch a new cycle
    END
    enjoy ...

    Alain
    Last edited by Acetronics2; - 26th March 2010 at 15:55.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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