Servo troubles.


Closed Thread
Results 1 to 28 of 28

Thread: Servo troubles.

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Ok, now I suspected the servo, so I changed the brand new chinese servo to an old one from my box of "old RC stuff", and with two different (working) hitec servos (different models) I get another result, they go to one endpoint and stay there, regardless of the original position ??

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Glenn View Post
    Ok, now I suspected the servo, so I changed the brand new chinese servo to an old one from my box of "old RC stuff", and with two different (working) hitec servos (different models) I get another result, they go to one endpoint and stay there, regardless of the original position ??
    That's why when you buy a transmitter, it has trim settings on it. when you change servo's in an airplane, generally you have to re-center it, reset the endpoints, etc.etc.etc.
    If the one servo isn't going end to end, increase the end points in the program.
    And I was wrong. The endpoints in that previous program should've been 100 and 200, not 150 and 250.

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


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Glenn

    Just try

    LOW PortB.0

    just before the PULSOUT Command ...

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

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Just try
    LOW PortB.0
    just before the PULSOUT Command ...
    Arg! In post #4, that should've been a PortB.0 instead of the posted PortB.1 in the third line!!!

  5. #5


    Did you find this post helpful? Yes | No

    Talking

    try just a simple code to make sure your servo is functioning correctly. I found a servo that seemed to drift. I thought it was my code. So i wrote a simple code that sets my pulse widths to left, center and right limits.
    Yes I do violate the 20ms refresh rate but if all you care about is moving to positions to verify servo operation this is quick and dirty.

    start:
    portd.0=1
    pausus 1000
    portd.0=0

    pause 2000

    portd.0=1
    pausus 1500
    portd.0=0

    pause 2000

    portd.0=1
    pausus 2000
    portd.0=0

    pause 2000

    goto start


    Nick

  6. #6
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Strangly enough, it kinda work now.. a bit out of scale and so on, but mostly work, after the 'low bortb.0'

    HOWEVER..

    Now I got to the next part, trying to actually being able to move the servo myself.. so I wrote a bit of code that I thought should work.

    Code:
    @ device HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
    DEFINE OSC 4
    
    'Use b1 to hold pulse width variable for servo 1
    
    b1 var byte
    
    'initialize variables
    
    b1 = 150
    
    low portb.0		' put the servoport low.
    
    main:
    
    	pulsout portb.0, b1		'send current servo 1 position out
    	
    	if porta.0 = 0 then left1	'check for pressed switch 0
    	if porta.1 = 0 then right1	'check for pressed switch 1
    
    	pause 18
    	
    	goto main
    	
    left1:
    	b1 = b1 + 1
    	if b1 >254 then max1
    	goto main
    
    right1:
    	b1 = b1 - 1
    	if b1 <75 then min1
    	goto main
    
    max1:
    	b1 = 75
    	goto main
    	
    min1:
    	b1 = 254
    	goto main
    ..I have pullup-resistors (10k) on a0 and a1 and wiring them to ground when I activates them.

    ..Well, the problem is that the servo just goes to one endposition and stay there regardless what I do with a0 and a1 ?

    ..HOWEVER.. if I comment out theese two lines:

    Code:
            if porta.0 = 0 then left1	'check for pressed switch 0
    	if porta.1 = 0 then right1	'check for pressed switch 1
    ..The servo "works", it put itself in the middle position (well not really middle but more or less.)

    Why ? ..I could think that my subroutines are destroying the timing, bit it aint working even if I dont touch the inputs ?

  7. #7
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Btw, thanks for all help, I'm completly stuck, and I know noone else that uses PBP

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    @ device HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
    DEFINE OSC 4
    'Use b1 to hold pulse width variable for servo 1
    b1 var byte
    'initialize variables
    b1 = 150
    low portb.0		' put the servoport low.
    main:
            low portb.0
    	pulsout portb.0, b1		'send current servo 1 position out
    	if porta.0 = 0 then left1	'check for pressed switch 0
    	if porta.1 = 0 then right1	'check for pressed switch 1
    	if b1 > 150 then
                   b1 = b1 - 1
            else
                   b1 = b1 + 1
            endif
            pause 18 : goto main
    left1:  b1 = b1 + 1 : if b1 >254 then max1
    	goto main
    right1:  b1 = b1 - 1 : if b1 <75 then min1
    	goto main
    max1:  b1 = 75 : goto main
    min1:  b1 = 254 : goto main
    END
    This should go left with one button, go right with the other button, and if no buttons are pressed, should 'walk' back to center.
    Note the BOLDED statements

  9. #9
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    This should go left with one button, go right with the other button, and if no buttons are pressed, should 'walk' back to center.
    Note the BOLDED statements
    Unfortunatly it gives exactly the same result, the servo goes to the endpoint and stay there..

    ..And just like in my program, if I uncomment the if-lines it "works" as in it stands in the middle position (more or less)

    Strange.

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Ok, try this...
    Code:
    @ device HS_OSC,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
    DEFINE OSC 4
    temp var byte
    main:
            for temp = 0 to 255
            pulsout portb.0, temp
    	pause 18
            next temp
            for temp = 255 to 0 step -1
            pulsout portb.0, temp
            pause 18
            next temp
            goto main
    END
    This should do nothing more than swing the servo back and forth, from endpoint to endpoint. It'll probably hang up for a bit at the endpoints and might even move too fast or jerk around a bit trying to catch up to the program.
    If it doesn't, you've got something else going on.
    It all boils down to breaking it down to it's simplest form and building it back up again.
    Try it and report back...

Similar Threads

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