3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Seg...stick.

Step 12Steering, and other loose ends.

Steering, and other loose ends.
«
  • stick26.jpg
  • stick28.jpg
  • stick27.jpg
Steering is accomplished the same way it would be on a tank-drive robot: differential commands sent to the left and right motors. For example, increasing the speed of the left motor while decreasing the speed of the right motor will make it turn right. This is readily implemented based on the signal read in from the steering potentiometer.

Outputting to the motors is done by setting a pulse width modulated (PWM) signal on the motor controller inputs. In Arduino land, this is done with analogWrite(). However, the default Arduino PWM frequency is way too low for motor control, so I added some direct register manipulation to force it to be 15.625kHz. Since the controllers are reversible, I use a small forest of if statements to figure out what to put on the DIR pins and whether or not to invert the output command.

One very important part of writing good control software is managing data types. You can see in the code that I often explicitly typecast to make sure I'm getting exactly the data type I want at every step of the calculation. Nothing is worse than having your controller freak out because a variable overflowed. For that reason, I also apply limiting at each step to ensure that the variables stay within appropriate ranges. For example, analogWrite() takes an integer value between 0 and 255, so I limit the outputs to this range at every step of the calculation.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
19
Followers
1
Author:scolton