Need 4 modes with just 3 switches - need all modes to be selectable QUICKLY!


Closed Thread
Results 1 to 40 of 68

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Poor Bruce ...

    It's not a book upon PBP he'll have to write , but a 32 parts encyclopaedia ...

    sure this explains ...

    No, no, Bruce, please , ... do not strike the head

    Regards
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    ??

    I'm not locked into your groove there ....just feeding back what I'm experiencing. The led obviously lights up after removing the finger from the switch, which sounds fine on paper but in practise it feels a little weird to the senses (ie I guess a lifetime of pushing buttons that immediately light up, is messing with my own grey matter - "Does not compute"!!)

    By the way, I'm not asking for anyone to write further code (Bruce has gone beyond the cause here!) ....just bouncing ideas of you all! IOC is all new to me - using the three diodes and the INT pin was ultra responsive....just wondering what ideas can be tabled to make IOC feel similar.
    Last edited by HankMcSpank; - 7th August 2010 at 20:24.

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Hank ( Humour ON : I do love how this sounds ...)

    seriously,

    I think twisting the Switch: and Process: labels could do it... at first sight.

    Alain
    Last edited by Acetronics2; - 7th August 2010 at 21:02.
    ************************************************** ***********************
    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
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    so wouldn't SOMETHING as noobesque (as befits me) like this suffice...

    Code:
    Switch_Interrupt:
    
    If sw1 = 0 then 
    mode = 1
    HIGH LED1  'green LED
    LOW LED2   ' red LED
    endif
    
    If sw2 = 0 then 
    mode = 2
    HIGH LED1  'green LED
    HIGH LED2   ' red LED
    endif
    
    If sw3 = 0 then 
    mode = 3
    LOW  LED1  'green LED
    HIGH LED2   ' red LED
    endif
    
    @ INT_RETURN

    (Yielding either a green LED, amber-esque led, red led)

    ok, it needs padding out....just wanted to get the main cut & thrust across.... the LED would change colour pretty darned quick, thereby giving the user the feeling of 'rapido'.

    Yes, sure there'll be an interupt generated when the finger is removed from the switch, but since none of the conditions in the Switch_interrupt subroutine would be met (since the pins would be high when the second interrupt happens) nothing will happen? - a few clock cycles wasted - but hey, there's heaps more where they came from?

    or would the quick succession interrupt from the finger being removed from the switch cause probs?
    Last edited by HankMcSpank; - 7th August 2010 at 21:32.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Ok. This one blinks immediately, it's 133 words smaller, and a lot faster than the last...

    Edit: I don't see why your own version wouldn't work too, but you'll need to sort out the interrupt-on-release.
    Attached Files Attached Files
    Last edited by Bruce; - 7th August 2010 at 21:54.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Ok. This one blinks immediately, it's 133 words smaller, and a lot faster than the last...

    Edit: I don't see why your own version wouldn't work too, but you'll need to sort out the interrupt-on-release.
    -wow Bruce, what can I say ....that nailed the puppy - my leds are positively zippy now (they light before I've even pressed the switch - and they know which switch I'm going to press...like I say you're good!)

    Can't thank you enough - to paraphrase the woman in Poltergeist "This thread is cleeeeaaan"

    ....no more questions your honour.

    Now, back to PCB layouts....wow, look at all the new space I now have!

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok....experiencing a few diffs here.

    Basically I need IOC interupts (which I'm basing on a simpler cut down noobesque version of excellent Bruce's provided code)...but I also need timer interupts.

    My problem is that I get a boat load of errors when my program compiles when IOC & timer interupts are enabled together - what are the errors I hear you say? Well, I'm at work right now so can't cut/paste in what I'm seeing, but what I can say is that when I remove the timer interupt it compiles fine. Or when I remove the IOC interupt it compiles fine - only when both are enabled does it spew out heaps of errors during compilation.

    I also know that my overall code is fine - previously I was using the INT pin for interupts ...I was able to get both INT & Timer interupts enabled & working in that setup. So I'm figuring here that maybe this latest way of handling the switches - IOC interupts - are using up a whole lot more PIC resource than the previous way I was doing this? Maybe the combinbation of IOC interupts, timer interupts, plus my coat are pushing things too far?

    How to progress this?

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Ok, I'm home now.....here are the compile errors...

    Error[116] : Address label duplicated or different in second pass (_305AfterUserRoutine)
    Error[116] : Address label duplicated or different in second pass (_305NoInt)
    Error[116] : Address label duplicated or different in second pass (INT_EXIT)
    Error[116] : Address label duplicated or different in second pass (_290OverCREATE)
    Error[116] : Address label duplicated or different in second pass (L00001)
    Error[116] : Address label duplicated or different in second pass (L00002)
    Error[116] : Address label duplicated or different in second pass (L00003)


    .....and so on.

    Like I say I think it's to do with both interupt handlers being enabled?

    Which prompts me, how should two interupt handlers be coded wrt 'returns'. Should it look like this (wrt IOC Interupts, I've stripped it back to basics & removed the disabling/enabling in the interupt handler here.... just for easiness on the eye)

    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  RABC_INT,  _Switch_Interupt,   PBP,  no
            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
    @ INT_ENABLE RABC_INT 
    
    Main:
      PAUSE 1
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    
    '---[ioc Interupt Handler]------------------------------------------------------
    Switch_Interupt:
    TOGGLE LED2
    @ INT_RETURN

    Many thanks.
    Last edited by HankMcSpank; - 12th August 2010 at 18:52.

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