servo motor resets 16f877a


Closed Thread
Results 1 to 40 of 86

Hybrid View

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Burak

    Don't worry for me ... I always am calm.

    I Exceptionnaly cook code for others ...


    so,

    - you'll fist check "T" calculations and do not allow it to go out of the 800 - 2200 µs range

    - Check for a "decent" increment to the same "T" variable

    - Understand that 50 Hz is not a MUST ... just be in the 35-50 Hz range; doesn't need to be a constant frequ. nor.


    PS: "Give me THE code" or "Give me THE scheme" are the sentences that suddently re activate my Altzheimer ...

    What Were we talking about ??? ...

    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
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Smile

    Ok.I wont want you to give code because i know Altzheimer is very tough disease

    I am gonna try what you said.If I fail I will disturb you again

    Thanks for help up to now....

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Why not just write simple code to sweep servo left to right and back right to left for testing? BTW, if you use a 5v regulator with 5v output power supply, it will cause a power drop when you try to draw current. A voltage reg will probably need 6.5v++ input voltage. Also, I have driven 4 large servos off of 2 paralleled voltage regs and a low current reg for the pic....no problems at all.

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Burak

    We haven't solved the power problem ...

    so, I ask the question once more : Which is your testboard ???

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

  5. #5
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Macgman2000 wants my code...

    I wrote a new code to protect values which makes out of range.

    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      
    DEFINE ADC_CLOCK  3       
    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 4000
    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
    PULSOUT PORTC.2,T
    PAUSEUS 20000-(T*10)
    next
    return
    
    end

    I am using breadboards.A minute ago i tried to connect two parallel power supply.Servo didnt reset MCU.I was glad but sometimes when i turned power on ,servo turned full left sometimes didnt.I think my servos are crazy .BTW I connected a capacitor.

    I have an idea.Can this error(full left error) occur because of my code that i wrote.too many PAUSEUS may make this error.Should I try DUTYCYLE or PWM codes???

    Or Is there any power problem???

  6. #6


    Did you find this post helpful? Yes | No

    Default

    If you have an oscilloscope look at your control pulses from the PIC to the servo as it moves. If you see that the wave form (1~2ms pulse) is wiggling around or changing amplitude then you have a power supply issue. Do as I suggested above, get a 9v power supply (AC/DC) and use TWO 7805 regulators in parallel for the servo ONLY. At the servo use 470uF across power and ground. Look at the scope again and make sure you see a "cleaned" up signal while servo is in motion.

    Nick

  7. #7
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Macgman2000 View Post
    If you have an oscilloscope look at your control pulses from the PIC to the servo as it moves. If you see that the wave form (1~2ms pulse) is wiggling around or changing amplitude then you have a power supply issue. Do as I suggested above, get a 9v power supply (AC/DC) and use TWO 7805 regulators in parallel for the servo ONLY. At the servo use 470uF across power and ground. Look at the scope again and make sure you see a "cleaned" up signal while servo is in motion.

    Nick
    I tried everything which is suggested.I changed code and put PAUSEUS before pulsout.Something wrong ,I got same error I decided to change power supply.That can cause this problem.

    I hope it will solve my problem...

    I will use two servos...(one for left-right one for up-down).I wrote the code just for left-right.I will make servos TWO if I am successful left-right position...

    Why did you say two parallel 7805? One for pic and one for servo?

    How many 7805 regulators should I use?
    Last edited by burak450; - 3rd October 2008 at 02:38.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I wrote a new code to protect values which makes out of range.
    In the middle of that math mess? I don't think it's a good spot for it...but that's just me...

    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      
    DEFINE ADC_CLOCK  3       
    DEFINE ADC_SAMPLEUS 100
    f var porta.0 : g var porta.1 : alta var byte : usta var byte : altb var byte
    ustb var byte : t var byte : i var byt e: adcon1=2 : trisa=3 : trisb=0
    portb=0 : trisc=0 : pause 1000 : lcdout $fe,1 : pause 4000
    adcin  0,ALTa : ADCin  1,usta : t=150
    pulsout portc.2,t 'initial servo kick to center
    yap: adcin 0,altb : adcin 1,ustb
    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
    'bounds checking...
    if t < 100 then t=100
    if t > 200 then t=200
    'bounds checking
    'if 100 isn't low enough, change it, if 200 isn't high enough, change it
    gosub motor : lcdout $fe,2,#usta," ",#ustb," ",#altA," ",#altb, $fe,$C0,#T
    goto yap
    motor: for i=0 to 25 : PULSOUT PORTC.2,T : PAUSEUS 20000-(T*10) : next i
    return
    end

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


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by burak450 View Post

    but sometimes when i turned power on ,servo turned full left sometimes didnt.I think my servos are crazy .BTW I connected a capacitor.

    I have an idea.Can this error(full left error) occur because of my code that i wrote.too many PAUSEUS may make this error.Should I try DUTYCYLE or PWM codes???

    Or Is there any power problem???

    Always Place a:

    LOW PORTx.y

    just before the PULSIN command ...

    That's 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
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Always Place a:
    LOW PORTx.y
    just before the PULSIN command ...
    I've heard you say that a number of times...not bad advice by any stretch...but I'm wondering why I've never had to use it and others seem to have so much trouble with that particular 'gotcha'...

  11. #11
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Unhappy

    A voltage reg will probably need 6.5v++ input voltage. Also, I have driven 4 large servos off of 2 paralleled voltage regs and a low current reg for the pic....no problems at all.
    A low current reg?

    He said we used large servos and mine is not large but I have to ask it because after a hour i will go to buy (9v supply,7805..,)

    Should I buy a current regulator?

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


    Did you find this post helpful? Yes | No

    Default

    No current regulator.
    What he means is say one 7805 will run the PIC (7805 at best 1 amp) = low current.

    Power supply for motors are made from parallel 7805s or some other type to handle the amperage needed.
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Sep 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    No current regulator.
    What he means is say one 7805 will run the PIC (7805 at best 1 amp) = low current.

    Power supply for motors are made from parallel 7805s or some other type to handle the amperage needed.
    thanks a lot i am gonna try it...

    hi Acetronics ,

    I am sure i changed code like that

    motor:
    for i=0 to 25
    PAUSEUS 20000-(T*10)
    PULSOUT PORTC.2,T

    next
    return

  14. #14
    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

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