Lesson 6 - Robotic arms examples - SCARA
Programming Spike Prime SCARA robot - Step by step
1. Install and open the Spike App.
2. Select to work with Spike Prime set.
3. Close splash window and select NEW PROJECT on next screen.
4. Create new WORD BLOCKS project
5. Click on 3 dots on Project name balloon and select RENAME PROJECT…
6. Name it SCARA_robot and click on SAVE to save it.
7. From the block palette select VARIABLES and click on Make a Variable. Name it speed.
8. Repeat this and make 3 more variables: J1, J2, J3. It will be used for displaying the motor positions.
9. Set the speed variable value to 15 and assign it to all 3 motors. Note that motors are connected to ports A, B and C as shown in last step of the assembling part of this example. From now on we will use the following notation: M1 = motor A, M2 = motor C, M3 = motor B. Move the motor A and motor C to starting position (360/0 degrees) using the shortest path option.
10. From the block palette choose MY BLOCKS and click on Make a Block button to create a new block. Name it move.
11. Click on Add an input icon 4 times to add 4 input parameters.
12. Name the parameters: M1 D1 M2 D2 and click on SAVE to save it.
13. Let’s define the move block. First we will check the D1 and D2 parameters if it is c (clockwise) or cc (couter-clockwise).
14. When we read the direction we will apply it to motors A and C.
M1 and M2 values are angles in degrees. Note that motor A has opposite rotating directions from convention. This is because it’s placed upside-down so we have to switch the directions.
15. After the movement is done we read and transfer the position of the motors to variables J1 (1st joint) and J2 (2nd joint)
16. Let’s make the effector block. It will be used to move motor B (or M3) block using the same procedure as in previous step. We have 2 inputs - degrees (M3 parameter) and direction (D3 parameters)
17. Define the effector block as follows. Note that we are using up and down keywords instead of c and cc as D3 input. At the and we transfer the position (angle) to variable J3.
18. Let’s finish the main part using defined blocks and try some movements.
19. Connect your Spike Prime Hub to computer with USB micro cable and turn on the Hub by long pressing the middle button. You will be notified that Hub is connected and Hub icon is displayed with green checkmark in upper left corner of the screen. Note that also all 3 motor positions are visible there. Press PLAY button (yellow) in lower right corner and try the code. Open variable panel (right) to monitor the motor positions J1 - motor A (M1), J2 - motor C (M2), J3 - motor B (M3).
You can transfer the code in Spike Prime Hub and start it directly from there.