Shop OBEX P1 Docs P2 Docs Learn Events
Why won´t this program work? — Parallax Forums

Why won´t this program work?

HoffaHoffa Posts: 46
edited 2007-08-20 13:15 in Propeller 1
I can´t understand why this program won´t work. The problem is that I can´t use the function setangle. Center, Left, and Right works fine, but if I assamble the program as written here nothing happens. I think that something happens when the lines·· "angle := 0 #> angle <# 180" or·"v := (MAXLEFT*90-(angle*PER90DEGREES))/90" are running, but I can´t find anything wrong with these lines.

Please help me.


<code>

CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
··· servoPin = 11
··· MAXRIGHT =····· 520
··· MAXLEFT· =···· 2450
··· CENTERPULS = (MAXLEFT + MAXRIGHT)/2
··· PER90DEGREES=·· (CENTERPULS-MAXRIGHT)
······
OBJ
· servo : "Servo32"

PUB start | i
· dira[noparse][[/noparse]servoPin]~~
· SERVO.Start
· setangle(90)·····

PUB setangle (angle) | v
· angle := 0 #> angle <# 180
· v := (MAXLEFT*90-(angle*PER90DEGREES))/90
· turn(v)

PUB turn (pulses)
· SERVO.Set(servoPin, pulses)

PUB center
· turn(CENTERPULS)

PUB left
· turn(MAXLEFT)

pub right
· turn(MAXRIGHT)·
</code>·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-20 13:15
    Servo32 manages its own copy of DIRA so you shouldn't set "dira[noparse][[/noparse] servoPin ]~~". What you must do is set an initial position for each servo pin you intend to use before you call "servo.start". The object uses this to decide which pins to control. It's described in the demo program that comes with servo32.spin, but is not well documented in servo32.spin itself.

    You have to use square brackets ([noparse][[/noparse] ]) around your message tags rather than corner brackets (<>).
Sign In or Register to comment.