Controlling Arduino Robot Arm With Arm Link Software

Minimal Code

The folder SnapperArmPlaybackMinimal contains a sketch with the minimum amount of code to play the arm sequence one time. This code may assist you if you wish to integrate the arm playback code into existing projects/code. If you want to add your own sequence into this file, add the contents of the do loop in armSequence.h into the setup loop in SnapperArmPlaybackMinimal.ino

IKSequencingControl() Overview

The armSequence.h file works by making several calls to the IKSequencingControl() function. This function allows you to easily move the arm to a specific position.

The IKSequencingControl() function takes parameters.The snapper arm only uses 8 of these parameters. The ‘Wrist Roate’ parameter should be set to a ‘0’ value.

Parameter #Cartesian ModeCylindrical ModeBackhoe Mode1X-Axis Base Servo Rotation 2Y-Axis Coordinate Shoulder Servo Rotation 3Z-Axis Coordinate Elbow Servo Rotation4Wrist Angle ° Wrist Servo Rotation 5Wrist Rotate6Griper Servo Rotation7Delta Value (milliseconds)8Pause Value (Milliseconds)9Enable

For example, in cartesian mode, the following line will move the arm to (0,150,150) (X,Y,Z) with a 0° wrist angle, and the gripper closed. It will move over a period of 2 seconds and wait for one second after pose completion.

IKSequencingControl(0 , 150 , 150 , 0 , 0 , 0 , 2000 , 1000, 1);

Adjusting Timing

You can fine tune each pose by adjusting the 7th and 8th parameters in the IKSequencingControl() function. Changing the 7th parameter, the delta value will effect the time it takes for the arm to move from its current position to the next position. The previous examples has the arm moving over 2000 milliseconds. If you want the arm to move over 5000 milliseconds, change the code to

IKSequencingControl(0 , 150 , 150 , 0 , 512 , 0 , 5000 , 1000, 1);

Changing the 8th parameter, the pause value will effect the time the arm waits after the pose is completed. The previous examples has the arm waiting for 1000 milliseconds. If you want the arm to move to the next position immediately, change the code to

IKSequencingControl(0 , 150 , 150 , 0 , 512 , 0 , 2000 , 0, 1);

Manually Adjusting Values

Using the Arm Link Software is the best way to generate values for the arms, as it will check limits and let you try out the arm. However it is possible to manually create your own poses from scratch. See the Arm Limits tables to see the ranges of values you can use for each arm/parameter. NOTE:The delta value listed in the previous tables does not apply to the IKSequencingControl() function. See ‘Adjusting Timing’ above for instructions on adjusting the delta value.

Interrupting Sequences

Once you have sent an command for the arm to move and it has begun moving, the individual pose cannot be interrupted – it will always complete the pose.

The SnapperArmPlayback code can stop a sequence after any pose via the pushbutton. This is because the pushbutton is attached to an interrupt pin. When a change is made to this pin (such as the pushbutton being activated), the currently running code is paused and special interrupt code is executed. This code sets the playState variable to 0. Any further IKSequencingControl() calls do not execute arm movements because this enable is turned off.

It is also possible to insert additional code in the IKSequencingControl() function to check for additional conditions. This will allow you to interrupt the sequence based on other conditions (like serial events, analog data, and other non-interrupt digital pins).

Advanced Pushbutton Options

If you are NOT using a pushbutton (and instead are relying on the serial terminal or automated sequences) you will need to change line 41 from

#define USE_BUTTON true

to

#define USE_BUTTON false

This will disable the code from trying to read the digital pin (and possible reading noise/activating the arm)

If you are using a Pushbutton with Jumper Wires or any other 2-wire momentary switch, change line 45 should be

#define BUTTON_TRUE LOW

Changing this #define will set the logic up and the pull up resistor for your pushbutton.

If you are using a RobotGeek Pushbutton or a pushbutton with a built in pull-down resistor, you can leave the define as-is.

#define BUTTON_TRUE HIGH

Xổ số miền Bắc