Shop OBEX P1 Docs P2 Docs Learn Events
Servo problems — Parallax Forums

Servo problems

HoffaHoffa Posts: 46
edited 2007-06-13 16:59 in Propeller 1
Hi

I have a big problem using my servos.

If I use my own code:


PUB start
repeat
  setPin(0)
  left
  setPin(1)
  left

PUB setPin(pinnr)
  Pin := pinnr

PUB left
  outa[noparse][[/noparse]Pin]~                                                                    ' Clear I/O Pin
  dira[noparse][[/noparse]Pin]~~                                                                   ' Make Pin Output 
  pulsOut(1500)
  clock.PauseMSec(20)

PUB right
  outa[noparse][[/noparse]Pin]~                                                                    ' Clear I/O Pin
  dira[noparse][[/noparse]Pin]~~                                                                   ' Make Pin Output
  pulsOut(1500)
  clock.PauseMSec(20)  

PUB pulsOut(uSec)                                                               
  outa[noparse][[/noparse]Pin]~~                                                                   ' Set I/O Pin
  clock.PauseUSec(uSec)
  outa[noparse][[/noparse]Pin]~                                                                    ' Clear I/O Pin





The servos works fine and rotates together.

If I use the file servo32 to steer my servos they try to rotate forward, but it goes very slow and there are a big pause between every pulse.

Here is the code that I use to steer the servos using servo32:


OBJ
  servo : "Servo32"
  clock : "Clock"

PUB start
  
  turnleft(0,200)
  turnright(1,200)
  servo.Start
  

PUB center(servoNr)
  turn(servoNr, centerpuls)
  
PUB turnleft(servoNr, amount)
  turn(servoNr, centerpuls+amount) 

PUB turnright(servoNr, amount)
  turn(servoNr, centerpuls-amount)

PUB turn (servoNr, pulses)
  servo.Set(defaultServoPin+servoNr, pulses)


Comments

  • HoffaHoffa Posts: 46
    edited 2007-06-13 11:59
    Found the problem, the microcontroller restarted over and over again.
  • rokickirokicki Posts: 1,000
    edited 2007-06-13 16:59
    This is extremely common. The best way to see this immediately in the future is to put a unique
    blink or beep sequence at the very start of the code. This way you know immediately if it resets.

    (When the batteries get low on my bot it tends to show up as frequent prop resets.)
Sign In or Register to comment.