Starting from:

$25

ME615 - Applications in in Mechatronics - Project 1  - Solved

For this exercise you will using the two DRV8838 on the power distribution board to control the right and left motors of your robot.  Locate the 6-pin header you soldered to the power distribution board. You will be connecting the associated DIR and PWM pins to pins on your Arduino Mega.  An image of the connectors is shown below.

  

For simplicity I will refer to the DIR and PWM pins for the left motors as LDIR and LPWM.  I will refer to the DIR and PWM for the right motor as RDIR and RPWM.  As such, Connect PIN 41 of the Arduino to LDIR, PIN 42 of the Arduino to RDIR, PIN 45 to LPWM, and PIN 46 to RPWM.

The expected operation is as follows: Applying 5V to LDIR and 5V to LPWM results in the left motor turning in forward direction at full speed. Applying 5V to RDIR and 5V to RPWM results in the right motor turning in forward direction at full speed.  

You will also need to mount your servo arm to the chassis and connect the power for all three servos to the VREG pin on your power distribution board.  The digital line of the lift servo must be attached to Arduino pin 3, the digital line of the wrist servo must be attached to Arduino pin 11, and the digital line of the gripper servo must be attached to Arduino pin 10.  The following information is extremely important!!  The servo library uses timer5 by default and this interferes with the PWM output on pins 44, 45, and 46.  Modify the file  C:\arduino-1.8.9\libraries\Servo\src\avr\ServoTimers.h and change the following: 

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define _useTimer5

#define _useTimer1

#define _useTimer3 #define _useTimer4

typedef enum {_timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t;
to the following (changes displayed in red):

if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //#define _useTimer5 

#define _useTimer1

#define _useTimer3 #define _useTimer4

typedef enum {_timer1, _timer3, _timer4, _timer5, _Nbr_16timers } timer16_Sequence_t;
You will be using the Dabble gamepad interface to control the operation of the motors for this exercise.  A basic image of the Dabble gamepad interface is shown below:

  

You must implement code to use the gamepad interface to control the motion of your robot and the robotic arm.  Your application must meet the requirements listed below:

Requirements 

1.    Create a sub directory named “project1a”, and an associated Arduino sketch file named “project1a.ino”, in your Arduino directory.  

2.    Create a program that includes a setup() and loop() routine.  Add code to the setup() routine that opens a connection to the serial port at a baud rate of 115,200 bits/second.  You must also set the baud rate to 9600 bits/second for communication between the Dabble Bluetooth interface and the Bluetooth module.   

2.    Within the loop() routine implement the following code when the push button is depressed: 

a.    By default, the duty cycle should be set to 50% until it changed by the end user. 

b.    If the select button is pressed increase the duty cycle of both motors by 10%.   

c.    If the start button is pressed decrease the duty cycle of both motors by 10% 

d.    If the up button is pressed, then interface with your motors using the builtin motor drivers to move both motors in the forward direction. 

e.    If the down button is pressed, then interface with your motors using the builtin motor drivers to move both motors in the reverse direction. 

f.     If the right button is pressed, then interface with your motors using the builtin motor drivers to move the left motor in the forward direction.  At the same time move the right motor in the reverse direction 

g.    If the left button is pressed, then interface with your motors using the builtin motor drivers to move the right motor in the forward.  At the same time move the left motor in the reverse direction. 

h.    If the up, down, right, and left buttons are not pressed, then interface with your motors to set the duty cycle to 0% for both motors.  This should stop movement of the robot. 

i.      If the triangle is pressed, then implement code to raise the robotic arm.  Do not do this in one step.  The lift should be gradual so that the arm does not suddenly jump to the up position. 

j.      If the cross is pressed, then implement code to lower the robotic arm.  Do not do this in one step.  The lowering of the arm should be gradual so that the arm does not suddenly jump to the down position. 

k.    If the square is pressed, then implement code to close the gripper.  Do not do this in one step.  The closing motion should be gradual so that the arm does not suddenly jump to the closed position. 

l.      If the circle is pressed, then implement code to open the gripper.  Do not do this in one step.  The opening motion should be gradual so that the arm does not suddenly jump to the open position. 

m.  Attach the feedback line (i.e., the green wire) of the gripper servo to Arduino Pin A0 so you can determine if the gripper did not close completely.  If the gripper servo did not close completely when commanded to close, then your code should automatically lift the robotic arm. 

n.    The wrist servo should be commanded to a position that is roughly parallel to the ground when the robotic arm is the down position. 

3.    In your project notebook provide pertinent spec sheets and detailed pictures that show your connections to the Arduino, connections to the motors, connections to the Bluetooth modules, connections to the servo arms, and connections to the Romi chassis.  Clearly label connection points in your pictures.  Supporting diagrams are also suggested. 

More products