Quote Originally Posted by Glenn View Post
Aha.. Hmm, but my original code didnt have those pauses, and still doesnt work..
But I'll change my testcode and remove the pauses and makes it update continuosly.
..Also, if I make a loop that just send 150 to the servo, it stands in one of the nedpositions.. shouldnt that (150) be the middle position ?
If your original code was going too FAST, you might see the same results.
And a middle position of 150 (1.5ms) is almost an arbitrary number...might be 160, might be 140-ish. Depends on the servo and what day of the week it was made...
Code:
@ device INTRC_OSC_NOCLKOUT,MCLR_OFF,LVP_OFF,WDT_OFF,PROTECT_OFF
DEFINE OSC 4
ct var byte : ct2 var byte : ct = 150 : low portb.1
main:
     for ct = 150 to 250 step 1    'sweep one way
          for ct2 = 1 to 50
               pulsout portb.0, ct
               pause 18
          next ct2
     next ct
     for ct2 = 1 to 50    'hang out there for a bit
          pulsout portb.0, ct
          pause 18
     next ct2
     for ct = 250 to 150 step -1     'sweep the other way
           for ct2 = 1 to 50
                pulsout portb.0, ct
                pause 18
           next ct2
     next ct
     for ct2 = 1 to 50     'hang out there for a bit
          pulsout portb.0, ct
          pause 18
     next ct2
goto main