Let's Make Robots!

Learning Spin: Objects

In this tutorial, I'll show you how to drive multiple servos at once with the Propeller. Along the way, I'll also introduce you to using objects.  My other tutorials (including my written objects guide) are here.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I also use Servo32v7 from the OBEX to control TOBI's HB-25's and the servos. It is such a cool object!

Why do your tutorials keep coming out 1 day after I figure someting out?!


Good video.  There are a bunch of H-Bridge motor driver objects - I don't think all of them ramp. 

One thing for all beginners to remember - a new object does not always equal a new cog.  The servo object is a good example - it will use one cog to drive the servos, but it can also use 2 cogs if you want to enable ramping.  Other objects, however, may not use a new cog (like reading a ping sensor), their methods run within the calling cog.  You could make them run in a new cog by using the cognew command, though.

I have one method in my top object that is launched into its own Cog. It just loops over and over again. It reads variables from the first Cog to find out what PING)))'s to read and what servo position to send to my sensor array and then it launches the PING.Spin object to read each PING))) into a set of distance variables. The distance variables that it writes to are used by the main Cog in an object avoidance Method.

This is becoming a theme --These moments of clarity where I realize something that seems so obvious in hindsight. Modify the object! I have no idea why I didn't think to do this or that I couldn't do it but I have now and it is great. Yeah, I simply added to the PWM object some extra methods that allow me to go straight to a speed without ramping. I was also able to take the ping object, strip it down and modify it to work with a LV-EZ1 sonar sensor. Problem solved. --and a lot of problems in the future solved.