Shop OBEX P1 Docs P2 Docs Learn Events
Problem: prop chip controlling servo using servo32 obj — Parallax Forums

Problem: prop chip controlling servo using servo32 obj

seadog13seadog13 Posts: 9
edited 2009-01-10 15:36 in Propeller 1
hey all, ran into a really weird problem with the servo32 object. We have eliminated a lot of our code to take it out of the equation. For some reason when we add a simple line of code setting a variable to 0, the servo quits working. If we have 3 variables the servo runs fine, if we put a fourth variable in the servo will not work. Not sure why this is happening. Below is a copy of our code. If we add any other variable the servo does not work.

This could be related to timing or memory, But have no reason why just adding a simple (variable := 0) will make the servo object quit working....

Any thoughts or suggestions are appreciated

thanks in advance



CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000

RUDDER = 1 'Servo Rudder pin

VAR
long theta,hbx,hby,tiltx,tilty,temp,temp2,thetafix,thetatemp

OBJ

HM55B : "HM55B Compass Module Asm"
acc : "memsic2125"
Debug : "FullDuplexSerialPlus"
SERVO : "Servo32v3"
MATH : "Float32Full"

PUB MAIN | thetanew


SERVO.Start 'Start Servo handler


repeat
tilty := 0
HBX := 0
HBY := 0
'tiltx := 0

'ThetaTemp:= 0 'Reset values to Zero
'Theta := 0
'thetafix := 0
'temp := 0




SERVO.Set(rudder,1250)
waitcnt(clkfreq*4 + cnt)
SERVO.Set(rudder,1750)
waitcnt(clkfreq*4 + cnt)

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,562
    edited 2008-12-30 23:29
    seadog13,

    In order for the servo32 object to work properly you need to 'set' an initial·servo position before you 'start' the servo handler.· This is by design so that the servo32 object knows what pins will be used, and that the servo starts up in a known or valid position.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • seadog13seadog13 Posts: 9
    edited 2009-01-02 00:34
    thanks Beau, that worked. After I posted I created a servo.stop in your program, and then put servo.start in the beginning of the repeat, and servo.stop in the end of the repeat. That seemed to work as well.
  • Travis_Travis_ Posts: 6
    edited 2009-01-10 15:36
    One thing not mentioned is that, if you are using a separate power supply for the Prop and for the Servos (which you probably should), the VSS (Ground) needs to be shared between the two power supplies.

    Below is working code that issues the Servo.Set command before the Servo.Init, as Beau mentioned.

    I also attached a photo of my breadboard used with this code and the SPIN code in a ZIP file for reference.

    CON
       _CLKMODE = XTAL1 + PLL16X
       _XINFREQ = 5_000_000
    
       RUDDER = 0 'Servo Rudder pin - PX
    
    OBJ
    
       SERVO  : "Servo32v3"
    
    PUB Main
    
       SERVO.Set(rudder,1500)
       
       SERVO.Start  'Start Servo handler
       
       repeat 
          SERVO.Set(rudder,1250)
          waitcnt(clkfreq*4 + cnt)
          SERVO.Set(rudder,1750)
          waitcnt(clkfreq*4 + cnt)
    
    
    
Sign In or Register to comment.