Here is a simple way to program your CrustCrawler Smart Arm in BASIC. I modified a version of Michael Green's FemtoBasic (from the Parallax Propeller Object Exchange) to include five new variables. They are used to control the position of the five Smart Arm joints.
- BASE - base servo (ID 1)
- ELBOW - elbow servos (ID 2,3)
- WRIST - wrist servo (ID 4,5)
- WRISTR - wrist rotate servo (ID 6)
- GRIP - gripper servo (ID 7)
You can set or read these variables from (0 to 1023) like so:
BASE = 511 Print BASE
The variable ARMINMOTION indicates if any of the servos are currently moving (0 = stop or 1 = moving).
The command HOME will place the arm into a resting position.
Here is an example of a simple program that moves the base from far left to right and then back to center:
10 HOME 20 BASE =0: GOSUB 100 30 BASE =1023: GOSUB 100 40 BASE =511: GOSUB 100 50 PRINT "Done" 60 STOP 100 IF ARMINMOTION = 1 THEN GOTO 100 110 RETURN
I built my controller using a Parallax Proto Board. The proto board support a PS2 keyboard and VGA monitor. I added a TV interface which I used instead of the VGA monitor. FemtoBasic supports the interface to an SD card so I wired in a SD breakout board I got from SparkFun Electronics. This will allow you to save your programs. See the schematic for all the details.
Even if you don't want to write complex programs in BASIC this project will allow you quickly test new ideas by writing some simple code or you can also try things out right from the command line.
|