Remote Gyroscopically Controlled Articulated Arm

by danielgass in Circuits > Arduino

391 Views, 2 Favorites, 0 Comments

Remote Gyroscopically Controlled Articulated Arm

Photo robot 2.png
Remote control articulated arm by bluetooth and gyroscope

This project has been developed for educational purposes.

This is another way to program an articulated arm.

I explain in this project the simple way how to:

  • Pair and make two Bluetooth modules talk to each other.
  • Read and write to an Eeprom memory module.
  • Drive several servomotors.
  • Use of a gyroscope.
  • Control a robot remotely.

Some programs (different from the first project) describe the operation of the various modules.

The project uses a commercially available articulated arm. Once the components assembled, they will be coordinated by Arduino IDE programs. These programs are the focus of the project.

The development is done around two boards driven by an Arduino UNO controller (Slave board connected to the robot) and an Arduino NANO controller (Master board connected to the gyroscope). These two boards communicate via Bluetooth.

The tilt of the gyroscope will move the arm in various directions.

It is also possible to memorize the arm movements to replay the recorded sequence.

All the project files are available for download here.

Supplies

Matériel slave.png
Matériel Master.png

The hardware (Slave board)

The complete articulated arm kit can be found for less than 50$. Unfortunately, if the mechanical parts are of good quality, the MG996 servos are not. During testing two servos burned out. They were replaced by more expensive and robust DS3225MG servos. The assembly of the arm does not pose any problem. Having noticed that some screws were unscrewing under the effect of vibrations I advise to add some self-locking washers.

The PWM controller PCA9685 allows the connection of 16 servos. The arm will use 6 servos. It is connected to the Arduino UNO using the I2C Bus.

The power supply must be efficient and allow current peaks of up to 2.5 amps. The display of the current consumption allows to control the drifts. For example, if a servomotor is blocked, the current will rise sharply and the voltage may fall below 4V, which could lead to erratic movement of the servomotors. A visual check of the power supply becomes essential.

A Bluetooth HC05 module is used to communicate with the Master board.

The hardware (Master board)

To control the arm, we will use a gyroscope module gy521 connected to an Arduino NANO controller.

The communication with the Slave board is done by the Bluetooth HC05 module.

The arm's memory is made up of a module containing an Eeprom AT24C256. This memory is used to store information after the Arduino is switched off. This information is available after restarting the Arduino. It is possible to store the movement of the arm and replay this movement afterwards. The module is connected to the Arduino using the I2C Bus.

A dip switch circuit allows to control some functions (recording and reading on Eeprom, restarting the robot)

Wiring Diagrams

Appairage.png
Câblage slave.png
Câblage master.png

Here are the three wiring diagrams easy to assemble.

Pairing the HC05 Bluetooth Modules

P-HC05-config.png

The two HC05 modules can be easily configured with a simple program.

Lines 3 to 17: Declarations and constants to be used.

Lines 19 to 22: The "setup" part starts the equipment. Pin 7 is set to 1 to put the HC05 module in configuration mode and accept AT commands.

Lines 47 to 54: Function that sends an AT command to the HC05 module. A variable containing the command is passed as a parameter (lines 6 to 17)

Lines 25 to 43: The main program consists of 3 parts. The first and the third are identical. They display the parameters read in the HC05 module. The second part (when uncommented) changes values stored in the HC05 module.

To start programming the modules, they must be labelled with the letters S and M to differentiate them.

When the module S is connected, and the program is started. Then the information (displayed on the serial monitor) will replace the one of lines 14 and 16. The coding of line 16 is special and must be respected because the format of the Information read may differ. The numbers must be placed around the commas as shown on line 16.

Then replace module S with module M. Uncomment line 35 and restart the program. The display on the serial monitor shows the status before and after the configuration.

To test the pairing, both modules are just powered up. After a few seconds, both modules will flash every five seconds to indicate successful pairing.

Master Program

P-Robot-proj1-gy521-hc05-eeprom-master.png
P-GY521-functions.png
P-EEPROM-functions.png

The principle of exchange between the two boards is based on the transmission of a single character per robot command. This greatly facilitates programming.

The "setup" part initiates the dialogue with the modules.

The "loop" part reads the position of the gyroscope and transmits it to the "Slave" board via Bluetooth. 

In this part the position of the switches is also read. In this way, the information in the Eeprom memory can be read or stored, or the "O" character can be sent to the slave board, which is then interpreted as a request to reposition the arm.

The gy521read function returns a character indicating the position of the gyroscope. 8 positions are used. 4 positions for left-right and front-back tilt and 4 positions for angle tilt. This gives us 8 commands to manipulate the arm.

The functions writeI2CByte and readI2CByte allow exchanges with the Eeprom memory. In our context the exchange is done on a character. But it is possible for other applications to exchange many characters at the same time. These functions allow this with a slight adaptation (for future use).

Slave Program

P-Robot-proj1-hc05-slave.png
P-SERVO-functions.png

Thanks to the use of functions the program remains simple.

Line 8 to 24: Declarations and definitions part. For details about the servo part please refer to my other project.

Lines 28 to 40: Module start-up

Lines 43 to 60: "Loop" program that takes care of getting the Bluetooth inputs and transforms them into servo-motor commands. The "tabserpos" table contains the current position of the servos. The servos are moved in steps of 1 except for servo 3 where the movement will be larger. Lines 51 and 52 move two servos at a time. This trick allows a coherent movement and ensures the verticality of the clamp.

You will notice that servo 5 (clamp rotation) is not used in this project.

The "servowrite" function moves a given servo. To move the arm smoothly, the servo is moved in steps of 5. This is useful when using the "servohome" and "servomove" functions which are called to return the arm to its resting position.

Gyroscope Movements and Actions on the Articulated Arm

Explication gyro.png

The GY521 module continuously gives the tilts of the Master PCB. A letter is assigned to the tilt intervals. The program uses these letters to simplify the actions to be carried out by the articulated arm.

  • "F" to lower the forearm and wrist.
  • "B" to raise the forearm and wrist.
  • "L" to turn the robot to the left.
  • "R" to turn the robot to the right.
  • "1" to close the clamp 
  • "2" to open the clamp.
  • "3" to lower the arm.
  • "4" to raise the arm.

Conclusion

This project was developed for educational purposes and can be used as a basis for developing other projects. There are some examples and tips