+ Post New Thread
Results 1 to 11 of 11
  1. #1
    Full Member level 1
    Points: 1,097, Level: 7

    Join Date
    Jul 2013
    Location
    LAHORE,PAKISTAN
    Posts
    101
    Helped
    5 / 5
    Points
    1,097
    Level
    7

    Two motor encoder code for avr

    SALAM TO ALL;
    I m using this motor

    http://www.pololu.com/product/1446

    and want to interface TWO motors encoders with ATMEGA32 and confuse about writting code DO i need INT0 and INT1 pin of atmega32 and which encoder output i have to use OUTPUT A or OUTPUT B of motor encoder

    •   AltAdvertisement

        
       

  2. #2
    Advanced Member level 5
    Points: 12,735, Level: 27
    Achievements:
    7 years registered

    Join Date
    Nov 2008
    Location
    Norwich, UK
    Posts
    2,123
    Helped
    598 / 598
    Points
    12,735
    Level
    27

    Re: Two motor encoder code for avr

    if you wish to sense direction you need both A and B signals
    http://developer.mbed.org/cookbook/QEI



  3. #3
    Full Member level 1
    Points: 1,097, Level: 7

    Join Date
    Jul 2013
    Location
    LAHORE,PAKISTAN
    Posts
    101
    Helped
    5 / 5
    Points
    1,097
    Level
    7

    Re: Two motor encoder code for avr

    No i just want to take 90 degree turn using encoder

    - - - Updated - - -

    Quote Originally Posted by horace1 View Post
    if you wish to sense direction you need both A and B signals
    http://developer.mbed.org/cookbook/QEI
    No i just want to take 90 degree turn using encoder

    should i use intrupts or general purpose inputs to check both motors??



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 5
    Points: 12,735, Level: 27
    Achievements:
    7 years registered

    Join Date
    Nov 2008
    Location
    Norwich, UK
    Posts
    2,123
    Helped
    598 / 598
    Points
    12,735
    Level
    27

    Re: Two motor encoder code for avr

    I would use interrupts which sense change of level of the signal



  5. #5
    Full Member level 1
    Points: 1,097, Level: 7

    Join Date
    Jul 2013
    Location
    LAHORE,PAKISTAN
    Posts
    101
    Helped
    5 / 5
    Points
    1,097
    Level
    7

    Re: Two motor encoder code for avr

    Quote Originally Posted by horace1 View Post
    I would use interrupts which sense change of level of the signal
    Do you think TO use both intrupts simultaneously can cause a error in reading the Two encoders???



    •   AltAdvertisement

        
       

  6. #6
    Advanced Member level 5
    Points: 12,735, Level: 27
    Achievements:
    7 years registered

    Join Date
    Nov 2008
    Location
    Norwich, UK
    Posts
    2,123
    Helped
    598 / 598
    Points
    12,735
    Level
    27

    Re: Two motor encoder code for avr

    Quote Originally Posted by ANS HAFEEZ View Post
    Do you think TO use both intrupts simultaneously can cause a error in reading the Two encoders???
    so long as you keep the interrupt service routines short (e.g. increment a counter and acknowledge the interrupt) I don't see why there should be problems



  7. #7
    Full Member level 1
    Points: 1,097, Level: 7

    Join Date
    Jul 2013
    Location
    LAHORE,PAKISTAN
    Posts
    101
    Helped
    5 / 5
    Points
    1,097
    Level
    7

    Re: Two motor encoder code for avr

    I m getting problem in simulation only INT0 works but if there is no intrupt on pin INT0 then INT1 works



  8. #8
    Advanced Member level 5
    Points: 12,735, Level: 27
    Achievements:
    7 years registered

    Join Date
    Nov 2008
    Location
    Norwich, UK
    Posts
    2,123
    Helped
    598 / 598
    Points
    12,735
    Level
    27

    Re: Two motor encoder code for avr

    Quote Originally Posted by ANS HAFEEZ View Post
    I m getting problem in simulation only INT0 works but if there is no intrupt on pin INT0 then INT1 works
    I have not used AVRs for some time but it sounds as though you may be getting continuous INT0 interrupts
    what are you interrupting on? edge, level ?
    perhaps you are not clearling the INT0 interrupt in the interrupt service routine ?

    how good is the AVR simulator at handeling interrupts?
    I always use real hardware for testing such things



  9. #9
    Full Member level 1
    Points: 1,097, Level: 7

    Join Date
    Jul 2013
    Location
    LAHORE,PAKISTAN
    Posts
    101
    Helped
    5 / 5
    Points
    1,097
    Level
    7

    Re: Two motor encoder code for avr

    The problem is continous intruppts on pin INT0 from motor encoder
    i think i should use GIO pin to count the encoders reading



    •   AltAdvertisement

        
       

  10. #10
    Super Moderator
    Points: 260,228, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,443
    Helped
    13827 / 13827
    Points
    260,228
    Level
    100

    Re: Two motor encoder code for avr

    I believe it's a coding problem. Both interrupts should be programmed for "Any logical change on INTx generates an interrupt request", or alternatively rising or falling edge only.

    You should have an idea about the expectable encoder pulse rate.



  11. #11
    Full Member level 1
    Points: 1,097, Level: 7

    Join Date
    Jul 2013
    Location
    LAHORE,PAKISTAN
    Posts
    101
    Helped
    5 / 5
    Points
    1,097
    Level
    7

    Re: Two motor encoder code for avr

    Quote Originally Posted by FvM View Post
    I believe it's a coding problem. Both interrupts should be programmed for "Any logical change on INTx generates an interrupt request", or alternatively rising or falling edge only.

    You should have an idea about the expectable encoder pulse rate.
    yup i check the motor encoder output from oscilloscope its about 2.85Khz for each encoder



--[[ ]]--