Quick thoughts: DT Ints with encoders


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    That's pretty cool! I've played a bit with digitizing arms from FARO and they are very impressive devices, good luck and please keep as posted on the progress!

    /Henrik.

    BTW. I think the term is forward kinematics...

  2. #2
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    Right you are Henrik . Good thing it's just the form title .
    I think I am going to go with the 6 pics reporting to a master via SEROUT2.
    I'll have the master report to the pc via HSEROUT. I think the speed will benefit
    from this scheme as well.

    Chris

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    Hmm, SEROUT2 (ie software UART) may not be a good idea. The interrupts will screw with the timing. The PIC12F1822 looked perfect for this untill I saw it was listed as a future product... (It's an 8-pin device with USART and Interrupt on change feature). Maby you can use it for the production model ;-)

    The PIC16F688, though a 14pin device, is available and has both USART and interrupt on change feature (on 6 pins), have a look at that.

  4. #4
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    Hey Hendrik,

    I'll take a glance at the parts you mentioned. Kinda cool you mentioned the uarts. Maybe you can answer a lingering question for me... In the example of the six "slaves" reporting to the "master"... If I send HSEROUT from the slaves, what would be the protocol for receiving at the master? Would I use SERIN2? What mode? Etc, etc?

    That question has driven me nuts for some time!

    I'm thinking 20 Mhz on the slaves and 40 Mhz on the master.

    What are your thoughts?

    Thanks again,

    Chris

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    Hi Chris,
    There are varoius ways to do it. You could for example have two wires between each slave and the master PIC. The master signals one slave at a time to to send the current position, and receives it with SERIN or SERIN2. When all 6 slaves are polled it sends the data to the master. The USART sends the data "true" so the master would need to receive it "true".

    Another approach is to implement a RS485 network.

    /Henrik.

  6. #6
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    I'll work on a bit of code and we'll see where it takes us...

    I'll keep you posted.

    Thanks,

    Chris

  7. #7
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default

    Here's what I've got so far... for the "slave" pics anyhow.

    Critiques are definitely welcome!

    16F688 w/20Mhz

    Code:
    INCLUDE "DT_INTS-14-MOD.bas"
    INCLUDE "ReEnterPBP.bas"
    
    'Clock setup
        Define OSC 20
    'Pin setups
        ANSEL = %00000000       'No analog input
        TRISA = %00000111       'PortA: TRISA = %00XXXXXX
        TRISC = %00000000       'PortC: TRISC = %00XXXXXX
    'Usart setups
        DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
        DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
        DEFINE HSER_CLROERR 1 ' Clear overflow automatically
        DEFINE HSER_SPBRG 86  ' 57600 Baud @ SPBRGH = 0
        BAUDCTL.3 = 1         ' Enable 16 bit baudrate generator
    '----------------------------------------------------------------------------
    
    MaxCount con 21600
    BtnZeroCount var PORTA.0
    APin var PORTA.1
    BPin var PORTA.2
    AOld var byte
    BOld var byte
    CurCount var word
    
    ASM
    INT_LIST  macro    ; IntSource,  Label,  Type, ResetFlag?
            INT_Handler   RAC_INT,  _ABInt,   PBP,  yes
        endm
        INT_CREATE           ; Creates the interrupt processor
    
        INT_ENABLE  RAC_INT  ; Enable RA change interrupt
    ENDASM
    
    curcount = 0
    
    Start:
    
    if btnzerocount = 0 then    'btnzerocount (A.0) has pullup res
        curcount = 0
    endif
    
    aold = apin
    bold = bpin
    
    hserout ["$", dec5 curcount]
    
    goto start
    
    ABInt:
    
    '\\\ A caused the interrupt ///
    IF apin != aold THEN                       'APin IS NOT equal to AOld
        IF apin != bpin THEN                   'If A and B are different,
            GOTO CW                                 'it was clockwise rotation
        ELSE                                   'Otherwise,
            GOTO CCW                                'it was counter-clockwise rotation
        ENDIF
    ENDIF
    
    '\\\ B caused the interrupt ///
    IF Bpin != Bold THEN                       'BPin IS NOT equal to BOld
        IF apin == bpin THEN                   'If A and B are the same,
            GOTO CW                                 'it was clockwise rotation
        ELSE                                   'Otherwise,
            GOTO CCW                                'it was counter-clockwise rotation
        ENDIF
    ENDIF
    
    CW:                 ' -1
    if curcount > 0 then
        curcount = curcount -1
    else
        curcount = MaxCount
    endif
    @ INT_RETURN
    
    CCW:                ' +1
    if curcount < maxcount then
        curcount = curcount +1
    else
        curcount = 0
    endif
    @ INT_RETURN
    Thanks again guys,
    Chris
    Last edited by kevlar129bp; - 6th January 2010 at 02:22. Reason: Added Pic part#, fixed TRIS reg's...Doh!

Similar Threads

  1. DT Ints work around for IOCA Register?
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th January 2010, 01:20
  2. Problem with Dt Ints Interrupts
    By Quin in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th July 2008, 19:21
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21

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