# Manual control

### Overview

In general, the job of the control system is to turn high level instructions from the software system, and turn them into instructions for the hardware. This is done by having a positions in 3d space (x, y z), a final gripper angle (respective to the ground), controls for the rotation, controls for opening and closing the gripper, and a deltaTime as an input, and turning those into control signals for the motors:

[![image.png](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/scaled-1680-/ESiimage.png)](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/ESiimage.png)

The control system also has feedback from the motors with variables with a name ending with ActualPosition, and the old positions of the motors, representing the position of the motors before the movement starts.

[![image.png](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/scaled-1680-/pzJimage.png)](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/pzJimage.png)

The movement starts whenever the input variables are changed, the old positions must come from an external source, and stay constant throughout the movement.

### Inverse kinematics

Starting of the process is the inverse kinematics, which is a Matlab function block that calculates the necessary angles that the joints need to make given a final position.

[![image.png](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-04/scaled-1680-/a55image.png)](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-04/a55image.png)

<span style="white-space: pre-wrap;">More information about how the inverse kinematics are done can be found in </span>[Kinematics](https://bookstack.roboteamtwente.nl/books/robotic-arm/page/kinematics "Kinematics").

After that, angles will be sent to the different motor control systems, where they will be processes as a desired position.

[![image.png](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/scaled-1680-/eWBimage.png)](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/eWBimage.png)

Most of the values are sent straight to the motor drivers, as they are processes by them.

#### Control signals

#### DC motors

The DC motors of the robotic arm are all controlled by sending the desired position to them incrementally.

#### Stepper motors

The stepper motor control works fairly similar, but instead of sending control signals with a PI controller, it just sends the absolute position in terms of steps and the frequency at which the PWM signal should pulse.

[![image.png](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/scaled-1680-/3Ytimage.png)](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-07/3Ytimage.png)

Before getting the desired position though, three gain block are used beforehand, to convert the angle gotten from the inverse kinematics to the position the motor should go to. In this process a, pi/2 gets added to the angle because of how they are calculated.

The gain blocks are here for this reason: 160 is because of the gear ratio between the motor and the actual movement, 180/pi is to convert from radians to degrees, and 1/1.8 is to convert from degrees to steps (these could have been one gain block, but it is more clear why they are here like this).

To confirm the robotic arm has reached the final position it has to, a forward kinematics function is used to get the projected position, which is then compared to the desired position.

[![image.png](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-04/scaled-1680-/9rVimage.png)](https://bookstack.roboteamtwente.nl/uploads/images/gallery/2026-04/9rVimage.png)

It does forward kinematics on the read values from the encoders, for that reason they have been scaled down to account for the gear ratios (pi/2 is subtracted from theta1 and theta4 because how the encoders are calibrated).

<span style="white-space: pre-wrap;">More on how the forward kinematics actually works in </span>[Kinematics](https://bookstack.roboteamtwente.nl/books/robotic-arm/page/kinematics "Kinematics").