Simulation
Simulink
The main simulation used for testing the control system of the robotic arm is made with Simulink, using the different parts of the Simscape suite to simulate the robotic arm.
The simulation works by using a main control block that sends instructions to different simulated motors, which are then connected to a 3d model of the robotic arm.
Motors
There are two main types of motors used for simulation, DC motors and stepper motors. All of these parts are simulated using the Simscape suite.
DC motors
The parts controlled by DC motors are the base rotation, gripper pitch, gripper rotation, and gripper jaw (opening and closing).
The DC motors are controlled with a control signal that ranges from 0V-5V, which is then converted to a 0V-24V signal that the motor can use. The voltage and amperage going to the motor are measured and sent to outputs to get estimations of how much power the motors will use.
The resulting rotational force is then sent to a gearbox, after which the torque sensor and angular velocity source are used to connect the motor to the model of the arm. The toque sensor is connected to the torque inputs of the joints, and the velocity source is connected to the speed output of the joints.
The position of the motor is measured before the gearbox, as this is where the encoder would be on the actual motors.
Since the jaw motors is not currently simulated to move the model of the arm, it has its own simple implementation that takes into account the resistance of the springs that are on the jaws of the gripper.
It uses a worm gear and a spring to simulate how the jaws would move without anything in them.
Stepper motors
The two motors in the shoulder joint, actuating the parallelogram construction are stepper motors. These are controlled in two stages, first determining the desired position in terms of steps and the frequency at which the steps should happen, and then generating the steps to make the stepper motors move.
The role of the stepper signal generators is to generate a PWM signal as the STM32's would do given the absolute position and frequency of the steps.
Simply what it does is send pulses at the specified frequency whenever the error between the desired step position is different from the real one.
Note: this way of generating pulses is only for this specific simulation, and would be a bad implementation for anything else.
The stepper motors work by connecting the ENA and REV connections from the previous block to the ENA and REV from a stepper motor driver, which makes the stepper motor move.
The rotational movement from the stepper motor is read both before and after the gearbox, before to get the encoder values from the motor, and after to use as output to the robotic arm model.
3d model
To show a 3d simulation of the robotic arm, a simplified version of the arm is used. Most of the part models are ported from SolidWorks, using STEP files to render the models. Apart from the gripper, which uses an altered version of the gripper model, and uses two obj files, one for the base and one for the claw, to allow for rotation of the gripper in the simulation.

This model is connected to the simulated motors by connecting the physical torque signals the motors produce, and connecting the output speed from the joints back to the motors. This allows the control system to send instructions to the motors, and let the motors then manipulate the arm.
In Simulink, the simulation of the robotic arm by connecting different Simscape parts together with different types of joints.
Each of the white blocks are parts, and the joints, due to the nature of the arm, are all revolute joints.
The different parts work by having a rigid transform from one attachment point to the other, as well as a reference point and a model file, to show how the arm would actually look like.
The actuated joints are connected to connection points that connect to the motors from outside of the model block.
The model also includes a red ball that is moved to the desired position of the end effector, which in this case is the tip of the gripper.











