Controlling Robot Arm With TLV493D, Joystick And, Arduino
by sabas1080 in Circuits > Robots
1538 Views, 4 Favorites, 0 Comments
Controlling Robot Arm With TLV493D, Joystick And, Arduino
An alternative controller for your robot with a TLV493D sensor, a magnetic sensor with 3 degrees of freedom (x,y,z) with these you could controller your new projects with I2C communication on your microcontrollers and electronic board that Bast Pro Mini M0 with a SAMD21 microcontroller on Arduino IDE.
The objective is to have an alternative joystick to controller your projects, in this case, a robot arm with 3 degrees freedom. I used a MeArm Robot Arm this is an open-source project and you can make it easy and you can find it here. Can make your own controller arm or other application with this knowledge that I’m happy to share with you.
All electronic components have links to acquire on the store, files to 3d printer, and code for Arduino IDE.
TLV493D can be a Joystick The 3D magnetic sensor TLV493D-A1B6 offers accurate three-dimensional sensing with extremely low power consumption in a small 6-pin package. With its magnetic field detection in x, y, and z-direction the sensor reliably measures three-dimensional, linear, and rotation movements.
Applications include joysticks, control elements (white goods, multifunction knops), or electric meters (anti-tampering), and any other application that requires accurate angular measurements or low power consumptions. The integrated temperature sensor can furthermore be used for plausibility checks. Key features are 3D magnetic sensing with very low power consumption during operations.
The sensor has a digital output via a 2-wire based standard I2C interface up to 1 MBit/sec and 12-bit data resolution for each,measurement direction (Bx, By and Bz linear field measurement up to +-130mT). TLV493D-A1B6 3DMagnetic is a standalone break outboard.
You can connect it easily to any microcontroller of your choice which is Arduino IDE compatible and has a 3.3V logic level. In this project, we use the Electronic Cats breakout and a development board that I will explain later.
https://electroniccats.com/store/tlv493d-croquette...
The advantage of using a TLV493D
sensor is that only two cables with I2C are used to receive the information, so it is a very good option when we have very few pins available on the card, also thanks to the benefits of I2C we can connect more sensors. You can find the repository for this project here. For this project, we will use a joystick that you can print on a 3D printer or have it printed at your nearest 3D printing store.
The .STL files are appended at the end of the project.
Its assembly is very simple, you can see it in video
Build your own robot
In this case, I build the robot Mearm v1 that you can find this project on the page of the author here https://www.thingiverse.com/thing:993759.
This is an easy robot to make and controller because it has servomotors at 5 volts. You can build or use any robot of your choice, this project will focus on control with the TLV493D sensor.
Supplies
Connecting the Sensor With Bast Pro Mini M0
To control the robot arm, an Electronic Cats development board is used, a Bast Pro Mini M0 with a SAMD21E ARM Cortex-M0 microcontroller.
This chip operates at 48MHz, with 256KB programming memory, 32KB SRAM and operates at a voltage of 1.6v to 3.6v. Thanks to its specifications we can use it for low consumption with good performance and also program it with CircuitPython or some other language that allows microcontrollers.
https://electroniccats.com/store/bast-pro-mini-m0/
If you are interested in knowing more about this card, I will leave you the link of its repository.
https://github.com/ElectronicCats/Bast-Pro-Mini-M0...
In order to control the movement of the servomotors, the magnetic sensor TLV493D is used which will send the signal to position the servomotor to the corresponding degrees.
With a single sensor, we can move two servomotors, in this example, we will only use a single sensor and a push button to control the gripper.
Another proposal you can make is to add another TLV493D sensor and move the third servo motor and the gripper. If you do, leave your experience in the comments and I invite you to share the project.
The image shows the armed circuit on a protoboard.
- The first servomotor is for the gripper and connects to pin 2
- The second servomotor is for the robot base and connects to pin 3
- The third servomotor is for the robot shoulder and connects to pin 4
- The fourth servomotor is for the robot elbow and connects to pin 5
- The first push-button is to stop any movement of the robot and connects to pin 8 in pull-down with a resistance of 2.2Kohms.
- The second push-button is for the opening and closing movement of the gripper and is connected to pin 9 in pull-down with a resistance of 2.2Kohms.
In the circuit image, the TLV493D sensor does not appear because it was not added to fritzing but a 4-pin connector was added to simulate its VCC, GND, SCL, SDA connectors. In the image, they are placed in the same order.
- The first pin connects to 3.3 volts on the board
- The second pin connects to GND
- The third SCL pin connects to pin A5 on the board
- The fourth SDA pin connects to the board's A4 pin
Thanks to the advantage of the SAMD21 chip we can use any of its digital pins as PWM outputs, which will serve us to send the correct pulse width to move the servomotor.
Another important piece of information that must be considered is the external power supply for the servomotors, in the circuit you can see a plug connector that connects to a 5volts at 2Amp source, to avoid overloading the board and damaging it.
Also do not forget to join the common signal GND of the card and the external source, otherwise, you would have problems controlling the servo motors since they would not have the same reference.
Downloads
Coding the Arduino IDE to Bast Pro Mini M0
The first thing will be to install the Bast Pro Mini M0 card in the
Arduino IDE, the steps can be found in the Electronic Cats repository and they are important for its operation.
https://github.com/ElectronicCats/Arduino_Boards_I...
When you have ready the Arduino IDE it is necessary to install the official library of TLV493D sensor, enter to https://github.com/Infineon/TLV493D-A1B6-3DMagnet... and go to Releases.
In the first part of the code, the libraries used are declared, in this case, Servo.h for the servomotors and TLV493D.h for the sensor.
When using the Servo.h library it is important to declare the number of servomotors, although the robot has 4 at this time only 3 are used.
The pins are declared for the push buttons that will stop any movement of the robot and the opening and closing of the gripper. Some global variables are declared that will serve to know the state of the gripper and if there is movement.
In the second part of the code, we will show in the serial monitor the value of the degree in which the motors are. Another important point is to establish the limit of the degrees in your servomotors, for this, the map () function is used that converts the value of the movements of the TLV493D sensor to the range of 0 to 180 degrees of the servomotor.
For the last part of the code, the conditions are established to activate the movement of the servomotors with the push-button and to know what state the gripper is in for its next movement when the second push-button is pressed. As you can see in the previous images the code is not difficult to implement and understand, at the end of the project you can find the code.
Are you learning to use Circuit Python?
If you are interested in learning how to use this IDE, you can find the Bast Pro Mini M0 card in the following link to download the bootloader and start programming it with Python.
3D Pieces
If you are interested in making the project, you can download the pieces in .stl and print them.
You'll find the files for the base and the rotary stick.