Little problem with controlling servo`s

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Little problem with controlling servo`s

Post by bunny-rabbit » Thu Nov 19, 2009 2:29 pm

Hello all!

I`m working on a in car HVAC, but i have a little problem with controlling the flaps.

The problem is when the servo reaches his position it sometimes wil stutter, this is very anoying!
It`s like the servo cant go to the exact place i have send it and its moving between 2 postitions, say 100° and 101°.

Can this be overcome?


Here`s my servo code:

Code: Select all


Event Servos()
    If servo = 0
    Then 
    High(Servo1)
    DelayUS(servo1T)
    Low(Servo1)
    servo = 1
    GoTo eind
    Else
    EndIf
    
    If servo = 1
    Then
    High(servo2)
    DelayUS(servo2T)
    Low(servo2)
    servo = 2
    GoTo eind
    Else
    EndIf
    
    If servo = 2
    Then
    High(servo3)
    DelayUS(servo3T)
    Low(servo3)
    servo = 0
    GoTo eind
    Else    
    EndIf
    
    
          
eind:      

End Event

Interrupt ISR()
    Dim WREGHold, BSRHold As Byte 
    BSRHold = BSR 
    WREGHold = WREG 
    Save(0, PCLATH, WREG, FSR0L, FSR0H, FSR1L, FSR1H, INDF0, INDF1, STATUS, PRODL, PRODH, TABLEPTR, TABLAT)
     INTCON.7=0
     If Timer0.InterruptFlag =1 Then
        Timer0.SInterrupt()      
     EndIf
     INTCON.7=1
       Restore      
   WREG = WREGHold 
   BSR = BSRHold 
End Interrupt
Timer0 intit:

Code: Select all

Timer0.Initialize(Servos)
Timer0.SetPrescaler(Timer0.PS2)
Timer0.EightBit = 0
Timer0.Preload=32203
Timer0.EnableInterrupt()
Timer0.Enabled()
Enable(ISR)

Greetz,
Gert
NL

User avatar
JWinters
Posts: 106
Joined: Mon Feb 04, 2008 4:56 pm
Location: North Carolina, USA
Contact:

Post by JWinters » Thu Nov 19, 2009 7:12 pm

If you are using the standard analog PWM servos, you may see better results from a digital servo. With a digital servo, you only need to send the pulse once to change position and the holding torque is much higher. It might be enough to keep your servo from jittering.

bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Post by bunny-rabbit » Thu Nov 19, 2009 8:42 pm

Hello, thanks for the reply!

As far as i know i have digital servo`s..
Is my program ok for digital servo`s?

Can i stop the jittering when i disconnect the signal wire? Or is there a better way to do this?

User avatar
JWinters
Posts: 106
Joined: Mon Feb 04, 2008 4:56 pm
Location: North Carolina, USA
Contact:

Post by JWinters » Thu Nov 19, 2009 8:58 pm

With an analog servo, removing the signal wire will just cause the servo motor to swing free. If the servo isn't pushing much force, the friction in the gears will be enough to hold the position. If not, the servo will move around.

An analog servo needs to be pulsed continuously. For example, it might need a 1.5ms pulse every 20ms. The motor only delivers torque when it receives the 1.5ms pulse. If you were send just a single pulse to a analog servo, it would get nudged in the direction you want, but would only go about 1 degree.

A digital servo works a little differently. It "listens" on its signal line for a pulse. When it gets one, it uses that to update it's own internal pulse generator that is continuously running. This means, you can just send it a single pulse from a digital output line and it will drive itself to that position and hold it. This is a nice feature in situations when you can't use interrupts.

bunny-rabbit
Posts: 42
Joined: Fri Jan 18, 2008 10:39 am
Location: Emmen/ Netherlands

Post by bunny-rabbit » Thu Nov 19, 2009 9:19 pm

Hmm i have just read some disturbing information about the cheap servo`s i bought :(..

They are very crappy!

So thats probably my problem :(..
Damn i glued them in place, hope i somehow can replace the internals with better ones...

To be continued...

Post Reply