PDA

View Full Version : Question about using the WavePlayerSDAccess and Standard Servo



Dan E
11-20-2010, 12:19 AM
Hi,

I am tryng to use the WavePlayerSDAccess object from the object exchange in my main program. I learned how to list that object in my program from the PE Kit book, but I'm not sure about what command to use in order to access individual WAV files from my within my program.

Secondly, I am also using a standard servo, and I also have the servo controller. I noticed that there is spin code on the bottom of the store's webpage for the servo. If I use that code do I still need the servo controller? also I noticed there several objects in the exchange for servo control, which would be most suitable for the Standard Servo?

I am looking to rotate my servo 10 degrees clockwise and 10 degrees counterclockwise in 1 degree increments, controlled by 2 buttons, one for each direction. After reading several objects I am not sure which variable to change to accomplish this. I understand PWM, but each method seems to involve time in some way, so I would appreciate someones expertise to help point me in the right direction as to the correct variable to change.

Thank you,

Dan E

Rayman
11-20-2010, 01:10 PM
As for the servo control, I use: Servo32v5.spin from Beau of Parallax.
You can find it in OBEX. It's very easy to use.

I haven't tried wav player. But, I also have one in OBEX that's easy to use.

Dan E
11-20-2010, 03:34 PM
Thanks, that was helpful, in that first link it seems the step size is controlled dividing the clock frequency, just what i was looking for.

Rayman
11-20-2010, 03:55 PM
Here's some code for continuous rotation servos. You just need to call servo.start and then servo.set(). Regular servos work the same way except servo.set() with set the position instead of the speed:


OBJ
SERVO : "Servo32v5.spin"
PUB Servo32_DEMO | temp
SERVO.Start 'Start Servo handler


Roll(0,0) 'Force Servo to Center
repeat
waitcnt(cnt+clkfreq*3)
roll(100,100)
waitcnt(cnt+clkfreq*3)
roll(-100,-100)
waitcnt(cnt+clkfreq*3)
roll(0,0)
waitcnt(cnt+clkfreq*3)
roll(100,-100)
waitcnt(cnt+clkfreq*3)
roll(-100,100)
repeat

PUB Roll(LeftSpeed,RightSpeed)
SERVO.Set(RWheel,RCenter+RightSpeed)
SERVO.Set(LWheel,LCenter+LeftSpeed)