servo motor resets 16f877a


Closed Thread
Results 1 to 40 of 86

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    God bless you guys!

    1-I connected 9v 450ma(I hope 450ma is fine) power supply and connected two 7805 paralel and used a 470uf between vdd and vss.Mcu doesnt reset itself and works fine! But I think servo works a little bit slower than past.I dont know why? maybe changing power supply from 5.2 to 5 makes this difference...If its neccessary I can put here its video...

    2-I think I finished left-right position and wrote a new code to complete my project.I wrote this
    but That doesnt work and servo2(up-down) made some stupid moves (like vibration).Also left-right motion gets very very slower...I know I made too many mistakes.But I learned here this forum too many things that I dont know.Everybody wants to help here and I was a little suprised at the beginning of this Thread.I put my code here.

    Can you help me again? t for left-right j for up-down.I bounded "j" between 135 and 115

    My code is....


    Code:
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS  4
    DEFINE LCD_LINES 2
    DEFINE OSC 4                                                                       
    DEFINE ADC_BITS     8       'A/D çevirim sonucu kaç bit olacak
    DEFINE ADC_CLOCK  3       'Clock kaynağı (3=rc)
    DEFINE ADC_SAMPLEUS 100
    SYMBOL F=PORTA.0
    SYMBOL G=PORTA.1
    alta var byte
    usta var byte
    altb var byte
    ustb var byte
    sola var byte
    solb var byte
    saga var byte
    sagb var byte
    k var byte
    t var byte
    i var byte
    j var byte
    ADCON1=2
    TRISA=%00001111 
    TRISB=0
    PORTB=0
    TRISC=0
    LCDOUT $FE,1 
    pause 2000
    adcin  0,ALTa
    ADCin  1,usta
    adcin  2,sola
    adcin  3,saga
    
    T=150
    j=125
    yap:
    
    
    
    
    adcin  0,altb
    ADCin  1,ustb
    adcin  2,solb
    adcin  3,sagb
    
    
    
    
    
    
    if  ((((usta+10)*100)/(ustb+10)))>130 and (not (t>194)) then 
    T=T+15
    endif
    
    if (((alta*100)/altb))>130 AND (not (t<51)) then 
    T=T-15
    endif
    
    if  ((((sola+10)*100)/(solb+10)))>130 and (not (t>134))    then 
    j=j+10
    endif
    
    if (((saga*100)/sagb))>130 AND (not (j<116)) then 
    j=j-10
    endif
    
    gosub motor2
    gosub motor1
    
    
    
    
    
    
      
    
    LCDOUT $fe,2,#usta," ",#ustb," ",#altA," ",#altb
    lcdOUT $fe,$C0,#T,"  ",#j    
    
    goto yap
    
    motor1:
    for i=0 to 25
    PAUSEUS 20000-(T*10)
    PULSOUT PORTC.2,T
    
    next
    return
    
    motor2:
    for k=0 to 25
    PAUSEUS 20000-(j*10)
    PULSOUT PORTC.3,j
    
    next
    return
    
    end

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The lower the voltage the slower the motor.

    Are the values displayed on the LCD what you expect, are they in range?
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Most hobby servo's have a max voltage of 6v. The 450 mA should be OK for testing the servo unloaded.

    If you have it turning a platform with large weight/mass then you can easily exceed 1A. A rule of thumb, the closer you get to maxing out the capabilities of your power supply the more noise you will see, especially true with motors, which could lead to glitches. I usually don't go over 50%, if I use a 2A supply for example, I only pull 1A.

    Also, decoupling caps are a MUST! use inductors when feeding motors power with custom H-bridges. Use 0.1uf caps to filter out high frequency spikes at the motor and on your power supply to the PIC.

    Do a search online for good engineering practice guides for dealing with inductive loads. There are tons of things that will go wrong working with inductive loads, you can solve most of them with well placed caps and careful layout.

    Nick

  4. #4
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    The lower the voltage the slower the motor.

    Are the values displayed on the LCD what you expect, are they in range?

    Yes,I think,they are....

    I follow t and j values by using lcd...

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    The lower the voltage the slower the motor.
    Are the values displayed on the LCD what you expect, are they in range?
    How many extra loops is he executing between servo updates?

  6. #6
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    thanks for the code.I am sorry it doesnt work properly..

    First I get a error and I fixed code in compiler--------pauseus 20000-((t*10)+(j*10) you forgot a parenthesis

    Servo stiil slower than usual mode

    When I worked with your code even j values got out of range...Once I saw j as 195...

    I might have another power problem like Macgman2000 said or something about code???

    You are right above.I have too many extra loops.I am stuck dont know what to do
    Last edited by burak450; - 3rd October 2008 at 20:25.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by burak450 View Post
    Servo stiil slower than usual mode
    Does it speed up if you disconnect one at a time?
    The PIC won't (i.e. shouldn't) care if there's 1, 2, or 3, or more servo's plugged in since it's not reading anything back from them.

  8. #8
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Does it speed up if you disconnect one at a time?
    The PIC won't (i.e. shouldn't) care if there's 1, 2, or 3, or more servo's plugged in since it's not reading anything back from them.

    When I used single servo and used this code.Everything was perfect.Object followed by servo perfecly.(left-right position)

    Code:
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS  4
    DEFINE LCD_LINES 2
    DEFINE OSC 4                                                                       
    DEFINE ADC_BITS     8       'A/D çevirim sonucu kaç bit olacak
    DEFINE ADC_CLOCK  3       'Clock kaynağı (3=rc)
    DEFINE ADC_SAMPLEUS 100
    SYMBOL F=PORTA.0
    SYMBOL G=PORTA.1
    alta var byte
    usta var byte
    altb var byte
    ustb var byte
    ADCON1=2
    TRISA=3
    TRISB=0
    PORTB=0
    TRISC=0
    LCDOUT $FE,1 
    pause 2000
    adcin  0,ALTa
    ADCin  1,usta
    
    t var byte
    i var byte
    T=150
    
    yap:
    
    
    
    
    adcin  0,altb
    ADCin  1,ustb
    
    
    
    
    
    
    if  ((((usta+10)*100)/(ustb+10)))>130 and (not (t>194)) then 
    T=T+15
    endif
    
    if (((alta*100)/altb))>130 AND (not (t<51)) then 
    T=T-15
    endif
    
    
    gosub motor
    
    
    
    
    
      
    
    LCDOUT $fe,2,#usta," ",#ustb," ",#altA," ",#altb
    lcdOUT $fe,$C0,#T   
    
    goto yap
    
    motor:
    for i=0 to 25
    PAUSEUS 20000-(T*10)
    PULSOUT PORTC.2,T
    
    next
    return
    
    end
    second servo and new code =trouble
    Now i unplugged a servo ,left-right position servo stiill slower and worked not properly..

    Something wrong about codes you and me wrote....

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Swap servos? What happens?
    Dave
    Always wear safety glasses while programming.

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by burak450 View Post
    second servo and new code =trouble
    Now i unplugged a servo ,left-right position servo stiill slower and worked not properly..
    still slower and worked not properly.
    That doesn't tell me much. Is your servo spitting out banana's again? Or is it making breakfast? both of which are not proper actions for a servo...

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Try this...see if it's any faster
    Code:
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_BITS  4
    DEFINE LCD_LINES 2
    DEFINE OSC 4                                                                       
    DEFINE ADC_BITS     8       'A/D çevirim sonucu kaç bit olacak
    DEFINE ADC_CLOCK  3       'Clock kaynağı (3=rc)
    DEFINE ADC_SAMPLEUS 100
    f var porta.0 : g var porta.0 : alta var byte : usta var byte : altb var byte
    ustb var byte : sola var byte : solb var byte : saga var byte : sagb var byte
    k var byte : t var byte : i var byte : j var byte : adcon1=2 : trisa=15
    trisb=0 : portb=0 : trisc=0 : pause 1000 : lcdout $fe,1 : adcin 0,alta
    adcin 1,usta : adcin 2,sola : adcin 3,saga : t=150 : j=125
    yap: adcin 0,altb : adcin 1,ustb : adcin 2,solb : adcin 3,sagb
    if ((((usta+10)*100)/(ustb+10)))>130 and (not (t>194)) then T=T+15
    if (((alta*100)/altb))>130 AND (not (t<51)) then  T=T-15
    if ((((sola+10)*100)/(solb+10)))>130 and (not (t>134)) then j=j+10
    if (((saga*100)/sagb))>130 AND (not (j<116)) then  j=j-10
    for i=0 to 25 : pauseus 20000-((t*10)+(j*10) : pulsout portc.2,t
    pulsout portc.3,j : next i
    lcdout $fe,2,#usta," ",#ustb," ",#altA," ",#altb, $fe,$C0,#T,"  ",#j
    goto yap
    end

Similar Threads

  1. More Servo Woes
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 13th May 2009, 08:40
  2. Problem with 12F629, servo and EEPROM
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 1st March 2008, 09:53
  3. Servo does not move
    By ruijc in forum General
    Replies: 12
    Last Post: - 12th November 2007, 19:14
  4. Beginner + Servo
    By james in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st July 2007, 21:31
  5. Help with Servo Control Please!
    By wireman22 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 18:15

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