Configure and Test DC Motors of the Robot | Arduino Engineering Kit: The Drawing Robot, Part 2 - MATLAB
Video Player is loading.
Current Time 0:00
Duration 8:42
Loaded: 1.90%
Stream Type LIVE
Remaining Time 8:42
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 8:42

    Configure and Test DC Motors of the Robot | Arduino Engineering Kit: The Drawing Robot, Part 2

    From the series: Arduino Engineering Kit: The Drawing Robot

    In part 2, learn how to set up, configure, and calibrate DC motors of the Arduino Engineering Kit drawing robot. See MATLAB® code in tasks 1-4 of the example. These tasks control the hardware and servo and DC motors. They also illustrate the methodology to convert motor inputs into cartesian coordinates, test the bot by moving it to a specific position on the whiteboard, and define the accessible drawing region on the whiteboard.

    Published: 2 Sep 2021

    Welcome back to the second video of this video series. In the last video, you saw the general workflow to implement the drawing robot using Arduino Engineering Kit. Let's now look at the provided task files which will guide us from start to end. In Task 1, we'll connect to the hardware and control the servo and the DC motors.

    First, connect your Arduino Nano 33 IoT board to your computer and execute the Arduino set up command at the MATLAB command prompt. Followed through the steps in the launched Arduino hardware set up interface to connect Arduino with your MATLAB. Once finished, execute the first section of the live script to connect MATLAB to the Arduino and the motor carrier.

    The following section allows you to establish a control to the servo motor that you can figure out the server position corresponding to the raise and lower state of the markers. After that, in the control the DC motor section, you will control the DC motors with the help of the encoders. Alongside, you will also initialize the parameters such as the maximum and the target voltage of the battery, which will determine the speed of the DC motors.

    Next, year will run the motors for three seconds and will read the values from the encoders. Another way of achieving the closed loop control of the DC motors is the PID controller, which doesn't require us to connect to the encoders.

    In the closed loop control section, you will configure the PID controller to command motors to rotate to a specific angular position or maintain a constant speed. This takes us to the end of the Task 1 where you have learned to control the servo and the DC motors. In the following task, that is Task 2, you will convert the motor inputs given it to the DC motors into the Cartesian coordinates on the whiteboard.

    To do that, we would first need to define the robot's starting position on the whiteboard. This requires us to input Base, Z1 and Z2 values, where Base is the distance between the two mounted pulleys and Z1 and Z2 are the distances between the pulleys and the pen position. Finally, using the famous Pythagorean Theorem, one can quickly compute the robot's starting position that is x and y. Now we will use MATLAB app called SimplePlotterApp to move the robot around.

    After moving the robot using the SimplePlotterApp, we will now want to compute the new x and y position of the robot. Or in other words, we will convert to motor positions given in units of counts to an xy position. To do the same, we first need to calculate the angular position from the position in counts.

    We already know the number of counts per revolution of the output motor shaft from the motor specification sheet, which is 1,200. And we can get the counts per radians from the counts per revolution. By simply dividing the counts per radians by the total number of counts, we can get the angle position. The amount of string spooled or unspooled by the motors is directly related to the angle it has rotated.

    The delta l string equals the product of the radius of the spool and the angular position of the motor. On the robot, the string loops over the pulley and then back to the robot body. Since the string is double in the length, the resulting change in the distance from the pulleys equals the half the change in the total string length. Therefore, the consequent change in the distance from the pulleys is equal to the half the change in the total string length.

    We can then get the new Z1 and Z2 by adding these changes in distances from the pulley to the initial Z1 and Z2. Finally, we can use the Pythagorean Theorem to compute the new x and y coordinates in the same day as we did earlier. After successfully controlling the DC motors and computing the new x and y position, in Task 3 we will go one step further and test the robot by moving it to a specific location on the whiteboard.

    Remember, previously in Task 2 we converted encoder counts to an xy position. Here, we need to do the same thing in the reverse order to get the angular displacement from xy coordinates as shown in this section. For simplification, all the steps in this section are encapsulated into the xyToRadians function.

    Finally, we move the robot to the given xy coordinate using the pre-built moveToRadians function, which takes computed theta as the input and moves the robot to the desired position on the whiteboard. Following the same concept, you can move the robot to some other position and can also move to a sequence of positions. Awesome. You have successfully mastered the art of moving your drawing robot. But note that there are limits to the area on the whiteboard where you can move the robot.

    You cannot move it too close to the pulleys or move to the top of the whiteboard.

    In Task 4, let's now determine the region on the whiteboard where the robot can reach and can avoid moving to. To compute the available area for the robot, we first need to determine the load the motors are under at any point on the whiteboard. And then, we want to make sure that the robot will only move to those regions where the load is within the limits.

    Starting off, we will first define some motor specifications, including motor's rated voltage, w_free, which is the motor's rotational speed when no load is applied, and TauStall, which is the model load when the load is so high such that the motor cannot spin. Using these specifications, we'll then compute the motor constant k and the motor resistance r.

    Then, with the help of these motor parameters, we'll calculate the maximum TauMax that can be applied to the motors. Next, to define the area accessible by the robot, first we need to determine the dimensions of the whiteboard. We have already defined our base dimension in the previous task. Here, we need to define the height, which you can measure through a tape or a meter stick.

    Following this, we will define a grid of coordinates on which we will calculate the torque and we also need to define some robot parameters such as the radius of the spool and the weight of the robot, which would be constant for your kit.

    To understand the mechanics behind the torque calculations, check out the documentation which explain each step using a free body diagram. Note that it is a simple force balance in the vertical and horizontal direction. Once you have the tension on the string, you can then calculate the torque by multiplying the tension with the radius of the spool.

    Finally, you can plot the torque to visualize it at every point on the whiteboard using the surf function in MATLAB. In the subsequent section, we will remove the regions where the robot should not move to. This includes areas where the torque is too high and regions where the robot cannot go because it's either too close to the pulleys or too close to the bottom of the whiteboard.

    To eliminate the bad regions, we will define a transparency mask for the plot where only the accessible area will be visible. We will remove the positions where the torque is greater than the TauMax or where the robot is too close to the pulleys and also where the robot is close to the bottom of the board.

    Wonderful. We have built a good understanding of the Tasks from 1 to 4. In the final video of the series, we will give the commands to the robot to draw an image on the whiteboard. See you in the following video.