Robô controlado por toque capacitivo usando módulo X-Bee

Capacitive touch controlled robot using X-Bee module

Robotic cars are commonly used for outdoor operations. They are designed for different purposes and applications. These robotic vehicles are intended to move over a surface and reach a location to carry out the intended application or perform specific tasks. Robotic cars can be controlled with a remote control that can be connected to the robot via a wired connection or a wireless interface. Wireless connectivity is typically provided by Wi-Fi, Bluetooth, RF, or mobile networks. One of the RF technologies available to provide wireless connection is Zigbee.
Zig Bee is a standard wireless communications technology that transfers data in ISM radio bands. Operates on 2.4 GHz worldwide and on other ISM frequencies in selected countries. The communications protocol is commonly used to create personal area networks for applications such as home automation, wireless office networks, and sensor-based data networks. Zig-Bee modules are commonly used to connect low-power embedded devices that need to operate in a small area with low data rates. A Zig-Bee module operating in the 2.4 GHz band has a data rate of 250 Kbps. X-bee is a Zigbee module from Digi International. In this project, a wireless robot is designed that connects to the remote control using the X-Bee module.
The remote has capacitive sensors to power user input instead of typical buttons. Capacitive sensors are touch-based sensors that use capacitance to detect the user's touch. Being sensitive to touch, these sensors respond quickly and allow you to control the robot more accurately and quickly. Due to touch sensitivity, the response time when controlling the robot by a human operator is considerably reduced. The capacitive sensors in the remote control for this project are used to move the robot forward, backward, left or right or to stop the robot. Thus, the capacitive touch sensor receives information from the user to control the robot's navigation.
A capacitive touch sensor feeds back user input in the form of analog voltage to a microcontroller pin. The sensor works on the principle of capacitance. Any parallel plate capacitor has a capacitance given by the formulas –
C = εA/d
Where;
C is the capacitance
A is the area of ​​the plates
d is the distance between the plates
ε is the permittivity of the dielectric.
Capacitance is related to voltage by the formulas –
C = Q/V
or V = Q/C
Thus, as the distance between the plates increases, the capacitance decreases and the voltage between the plates increases. A capacitive sensor can be made by a single metal plate connecting two terminals. The user's finger serves as the other plate of the capacitor and the air between the finger and the metal plate serves as the dielectric. The input voltage is supplied to one terminal and received at a microcontroller input pin of the other terminal. When the finger approaches the metal plate or physically touches the metal plate, the distance between the metal plate and the finger is reduced, which decreases the capacitance and increases the output voltage at the receiving terminal.
The voltage input from the metal plate – finger capacitor can be read from the microcontroller pin, digitized through the ADC and compared with a reference value to operate it like a switch. This concept of capacitive touch is used to make touch or proximity sensors in the project that function as control buttons.
Capacitive sensors are used in the remote control. The remote control is connected to the robot using Zigbee wireless technology, for which two X-bee modules are used. Therefore, there are two circuits – one is the remote circuit and the other is the receiver circuit mounted on the robot. The robot is constructed using two wheels and a caster body and the DC motors attached to the wheels are controlled using L293D motor driver IC.
Protótipo de robô controlado por toque capacitivo baseado em XBee
Fig. 1: XBee-based capacitive touch controlled robot prototype
Required components –
Lista de componentes necessários para robô controlado por toque capacitivo baseado em XBee
Fig. 2: List of components required for XBee-based capacitive touch controlled robot
Block diagram –
The remote circuit has the following block diagram –
Diagrama de blocos do circuito remoto de toque capacitivo do robô Arduino baseado em XBee
Fig. 3: Block diagram of capacitive touch remote circuit of XBee-based Arduino robot
The receiver circuit mounted on the robot has the following block diagram –
Diagrama de blocos do robô controlado por toque capacitivo baseado em XBee
Fig. 4: Block diagram of XBee-based capacitive touch controlled robot
Circuit Connections –
There are two circuits that make up this project – one is the remote circuit built using Arduino UNO, capacitive sensors and X-Bee module. The other is a receiver circuit mounted on a robot built using Arduino UNO, X-bee module and motor driver IC L293D.
The remote circuit is constructed using the following components –
Imagem do circuito remoto de toque capacitivo para robô Arduino baseado em XBee
Fig. 5: Image of capacitive touch remote circuit for XBee-based Arduino robot
Arduino UNO – Arduino UNO is one of the most popular prototyping boards. It is often used in robotic applications because it is small and packed with advanced features. The board comes with an integrated Arduino bootloader. It is an Atmega 328 based controller board that has 14 GPIO pins, 6 PWM pins, 6 analog inputs and integrated UART, SPI and TWI interfaces. In this remote circuit, 8 pins on the board are used. There are six pins used to interface the capacitive sensors. Out of these five pins are used as analog input pins. The two pins RX and TX on the board are used to interface the X-bee module and establish serial communication via USART. Learn more about the Arduino UNO here.
X-Bee Module – X-Bee is a Zigbee module from Digi International. Zigbee is a wireless communication module that uses the IEEE 802.15.4 standard. 802.15.4 is an IEEE standard for low-power radio frequency applications. It is used in many products for wireless communication functionality. It can be used as a transmitter and receiver. It uses serial communication to send and receive data. It has two series, series 1 and series 2. Series 1 is comparatively easy to use and is recommended for beginners. In this project, the X-bee Series 1 module is used. The Zigbee Series 1 module cannot work in a mesh network. This means that it cannot talk to more than one Zigbee at the same time. Learn more about Zigbee technology.
X-bee series 1 is a 20-pin module with the following pin configuration –
Tabela de listagem de configuração de pinos do módulo Xbee Série-1
Fig. 6: Table listing the Xbee Series-1 Module pin configuration
The module can be connected to a controller board using UART. The module can be connected to Arduino by connecting its DOUT (UART Data Out) or TX pin with RX pin of Arduino and DIN (UART Data In) or RX pin with TX pin of Arduino. The module's VCC and Ground pins must be connected to common VCC and ground. The X-Bee module used in the remote circuit is configured to function as an RF data transmitter.
Capacitive Sensors – Capacitive sensors are built with five metal plates. One terminal on each metal plate is connected to pin 2 on the Arduino board. The other terminals of the capacitive boards are connected to pins 7, 8, 9, 10 and 11 of the Arduino. These pins are used to detect the voltage of the capacitive sensors. A 1M Ω sensitivity resistor is connected in series across the common terminal of each board. The resistor provides the voltage across the board. The higher the value of this resistance, the greater the sensitivity. During testing of the sensors, it was found that when connecting 1M Ω of resistor and maintaining a reference voltage at half the width of the ADC channel, the sensor responded to the touch of the finger. When connecting a 10M Ω resistor and maintaining a reference voltage at half the width of the ADC channel, the sensor was responding from 4 to 6 inches away and when connecting a 40M Ω resistor and maintaining a reference voltage at half the width from the ADC channel, the sensor was responding from 12 to 24 inches away.
Diagrama de circuito do sensor de toque capacitivo
Fig. 7: Capacitive touch sensor circuit diagram
The sensors connected to pins 7, 8, 9, 10 and 11 of the Arduino control the movement of the robot forward, backward, left and right and stop the robot respectively.
Power supply – All remote circuit components require a 5V DC supply. The Arduino board is powered by 5V via a USB cable. The voltage input for the X-bee module is taken from the Arduino's 5V Vout pin. The voltage for the operation of the capacitive sensors is supplied by pin 2 (common pin connected to the sensors) of the Arduino.
The receiver circuit mounted on the robot consists of the following components –
Imagem do robô controlado por toque capacitivo baseado em XBee
Fig. 8: Image of XBee-based capacitive touch controlled robot
Arduino UNO – The receiver circuit also uses Arduino UNO as a controller board. The Arduino used in the receiver circuit has 6 pins used. The GPIO pins of this Arduino are used to interface with the L293D motor driver IC. These pins are connected to the input pins of the motor driver IC. The two Arduino pins are used to interface the X-Bee Series 1 module.
X-Bee Module – The X-Bee module used in the receiver circuit is configured to function as an RF data receiver. The module interfaces with the Arduino by connecting its DOUT (UART Data Out) or TX pin with the Arduino's RX pin and DIN (UART Data In) or RX pin with the Arduino's TX pin. The module's VCC and Ground pins must be connected to common VCC and ground.
L293D Motor Driver IC – The L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as current amplifiers in that they receive a low current control signal and supply a higher current signal. This higher current signal is used to drive the motors. It has 16 pins with the following pin configuration:
Tabela de listagem de configuração de pinos do IC do driver do motor L293D
Fig. 9: Table listing the pin configuration of the L293D motor driver IC
There are two DC motors used to make the robotic car. DC motors interface between pins 3 and 6 and pins 14 and 11 of the motor driver IC.
IC L293D controls DC motors according to the following truth tables:
Tabela verdade do IC do driver do motor L293D
Fig. 10: Truth table of L293D motor driver IC
Pins 4, 5, 13 and 12 of the L293D are grounded while pins 1, 16 and 9 are connected to 5 VDC and pin 8 is connected to 12 VDC. Pins 15, 2, 7 and 10 of the motor driver IC are connected to pins 5, 2, 3 and 4 of the Arduino board. The DC motor connected to the right wheel is connected to pins 11 and 14, while the motor connected to the left wheel is connected to pins 3 and 6 of the motor driver IC. The IC enable pins (pins 1 and 9) are physically connected to the 5 VDC source.
Geared DC Motors – In this robot, 12V geared DC motors are attached to the wheels. Geared DC motors are available with a wide range of RPM and Torque, which allows a robot to move based on the control signal it receives from the motor driver IC.
Power supply – The Arduino UNO, X-Bee module, and motor driver IC logic power pins require 5V DC, while the driver IC power pin requires 12V DC. A 12V NIMH battery is used as the primary power source. The battery power is regulated to 5V and 12V using 7805 and 7812 ICs. Pin 1 of both voltage regulator ICs is connected to the battery anode and pin 2 of both ICs is connected to ground. The respective voltage outputs are taken from pin 3 of the respective voltage regulator ICs. An LED along with a 10K Ω pull-up resistor is also connected between the common ground and the output pin to get a visual cue of power continuity. Despite using a 12V battery, the 7812 is used to provide a regulated and stable power supply to the motor driver IC.
How the circuit works –
The wireless robot is powered by a battery and as soon as the battery is connected to the robot's control circuit, it starts operating. When energized, the X-Bee module interfaced in the receiver circuit is configured as an RF data receiver and starts awaiting commands from the remote control. Commands are transmitted in the form of single character sequences by the remote control. The following sequences are passed through the remote circuit to the receiving circuit to move the robot forward, backward, left and right and stopping the robot –
Tabela listando strings de comando para controlar o robô Arduino sem fio
Fig. 11: Table listing command strings to control the Arduino robot wirelessly
Command strings are read by the Arduino board using the UART port. On receiving a command, the Arduino board compares it with the above-mentioned command strings and changes the digital logic on the pins connected to the input pins of the motor driver IC to perform the desired operation. The robot is moved forward, backward, left or right by implementing the following input logic on the motor driver pins –
Tabela lógica do driver de motor L293D IC para robô Arduino sem fio
Fig. 12: Logic table of L293D motor driver IC for wireless Arduino robot
The input pins of the motor driver IC are connected to the Arduino pins and by changing the digital logic on the Arduino pins, the respective logic is implemented on the input pins of the motor driver IC.
The remote circuit has capacitive sensors to obtain information from the user by touch. When a capacitive sensor is not touched, the sensor has no effective capacitance and the voltage drop across the sensitivity resistor has no effect on the other terminal of the sensor. When the sensor is touched by a finger, there is an effective capacitance across the sensor and a voltage is induced at the output terminal of the sensor due to this capacitance. The voltage is read by the microcontroller pin and converted into a digitized reading. The Arduino UNO has a 10-bit ADC channel, therefore, the digitized reading has a maximum value of 1023. The reference value for voltage comparison is taken as 900.
Upon detecting touch on a capacitive sensor, command sequences are passed serially by the Arduino to the X-Bee module. Capacitive sensors are connected to the following Arduino pins and have the following command sequences and intended operations associated with them –
Tabela de listagem de conexões de circuito entre Arduino e teclado com sensor de toque capacitivo
Fig. 13: Table listing circuit connections between Arduino and keyboard with capacitive touch sensor
To activate the wireless connection between the robot and the remote circuit, it is important to configure the X-Bee modules on both sides. The CoolTerm terminal application is used to configure the X-Bee modules. To make PC communicate directly with Xbee, even Arduino board can be used by removing the controller IC or a simple sketch can be uploaded to Arduino boards which makes Xbee enabled to communicate with computer directly and not with the Arduino board. The first of the circuit connections between the X-Bee module and the Arduino must be made as mentioned above.
Now follow the following steps –
Open the CoolTerm app and navigate to connection -> options -> serial port and select the COM port. Set the baud rate and go to the Terminal option and select the Local Echo checkbox to display the entered commands and click OK to save the changes.
Captura de tela do aplicativo CoolTerm
Fig. 14: Screenshot of the CoolTerm application
To configure X-Bee, the following AT commands must be used.
First make X-Bee enter command mode by typing +++ in the terminal, when OK, follow with the other AT commands
Firstly, XBEE radios only operate at a certain baud rate, this is the number of bits per second that the X-Bee can send. A brand new X-Bee has a default baud rate of 9600 bps, which is quite slow. The baud rate can be changed by changing the ATBD register. Both X-Bee modules must have the same baud rate to communicate with each other. The available baud rates (and corresponding ATBD value) are as follows –
Tabela listando valores ATBD para diferentes taxas de transmissão do módulo Xbee
Fig. 15: Table listing ATBD values ​​for different Xbee Module baud rates
Therefore, to set the baud rate to 9600, the following command must be passed –
ATBD3
The next important parameter is the Personal Area Network ID. This is a number shared between each XBEE on a network. Here, there are only 2 X-Bee modules, but there can be many X-Bee modules in a network (for which X-Bee Series 2 modules must be used). X-Bee modules on different networks do not “see” each other. The default PAN is 3332, so avoid using this number. The PAN ID is stored in the ATID record. The registry can be changed by passing the following command –
ATID1001
Once both X-Bee modules are on the same network, they must each be assigned an address number indicated by the ATMY record. The destination address can also be set, which is the address number to communicate with and is indicated by the ATDL register (for low destination, there is no need to use the high bytes if the address numbers are less than 16 bits of lenght). An example configuration of two X-Bee modules that will communicate directly with each other at 38.4 kbps can be done by passing the following commands –
ATMY10
ATDL11
Therefore, both the X-Bee modules are configured by passing the following AT commands –
X-BEE Module 1:
ATID1001
ATMY10
ATDL11
ATBD3
X-BEE 2 Module:
ATID1001
ATMY11
ATDL10
ATBD3
One important thing to note is that the changes you make are stored in temporary memory. if the X-Bee modules are turned off, the settings will be lost. Send ATWR to write changes to non-volatile memory so they are not lost during shutdown.
Captura de tela dos comandos AT para o módulo Xbee do aplicativo CoolTerm
Fig. 16: Screenshot of AT commands for the CoolTerm application Xbee Module
Once the X-Bee modules are configured, the Arduino sketch for the remote circuit and receiver circuit can be uploaded to the respective controller board.
Imagem do robô Arduino sem fio controlado por toque capacitivo baseado em XBee
Fig. 17: Image of XBee based capacitive touch controlled wireless Arduino robot
Check the Arduino Sketch loaded on the Arduino connected to the remote circuit to see how the Arduino detects sensor touch using the capacitive sensor library and uses the sensor reading to send command strings serially to the X-bee module. Check the Arduino Sketch loaded on the Arduino connected in the receiver circuit to see how the command strings are read through the X-Bee module and the motor driver IC is controlled according to the received commands.
Programming guide –
Remote Circuit Program: Arduino code loads CapacitiveSensor.h to handle capacitive sensors. Five capacitive sensor type objects are instantiated with mapping to the connected pins using the CapacitiveSensor method in which the first parameter determines the sensitivity resistance and the second parameter determines the pin that connects the sensor. A set of variables to maintain voltage levels across capacitive sensors are declared followed by a set of variables that maintain the status of the devices. A variable to maintain the reference voltage level is declared. The baud rate for serial communication with the X-bee module is set to 9600 bits per second using the Begin method in the Serial class.
Captura de tela da inicialização no código Arduino no lado do transmissor do robô sem fio
Fig. 18: Screenshot of initialization in Arduino code on the transmitter side of the wireless robot
The loop function is called in which the voltage level of the capacitive sensors is read and stored in variables declared for it using the capacitiveSensor method with a number of samples passed as a parameter. With the voltage value compared with the reference value following the condition and the respective data is sent to the X-bee using the pritln function.
Captura de tela da função Loop no código Arduino no lado do transmissor do robô sem fio
Fig. 19: Screenshot of the loop function in the Arduino code on the transmitter side of the wireless robot
Receiver Circuit Program: – In receiver side coding, the character variable is initialized to store the received data. Motor pins are defined and connected between Arduino and motor driver IC. In the setup function, the Begin function is used to set the baud rate to 9600 to receive the serial data from the X-bee. The Arduino pins connected to the input pins of the motor driver IC are configured for digital output using the pinMode function.
Captura de tela da inicialização no código Arduino no lado do receptor do robô sem fio
Fig. 20: Screenshot of initialization in Arduino code on the receiver side of the wireless robot
The loop function is called and continuously checks the received serial data. If serial data is available, the data is read using the serial.read function and stored in the variable. Then the stored data is checked with the mentioned condition. Then, with respect to the conditions, the function call for robot movement is performed.
Captura de tela da função Loop no código Arduino no lado do receptor do robô sem fio
Fig. 21: Screenshot of the loop function in the Arduino code on the receiver side of the wireless robot
The move_forward function is called to move the robot in the forward direction. The move_backward function is called to move the robot backwards. The turn_left function is used to turn the robot in the left direction and the turn_right function is used to turn the robot in the right direction. The robo_stop function is used to stop the robot.
Check out the complete Arduino codes and get your hands dirty quickly with an Arduino IDE. It will be fun to make this robot.

Project source code

###

 //Program to
 char msg = ' ';

 //defining the arduino pin number for arduino
 #define L_motor1 2
 #define L_motor2 3
 #define R_motor1 4
 #define R_motor2 5

 // function prototype
 void move_forward ;
 void move_backward ;
 void turn_right ;
 void turn_left ;

 void setup
 {
 //For enabling serial data transfer at rate of 9600
  Serial.begin(9600);

  //pin modes of motor connected with arduino 
pinMode(L_motor1, OUTPUT);
 pinMode(L_motor2, OUTPUT);
 pinMode(R_motor1, OUTPUT);
 pinMode(R_motor2, OUTPUT);

 digitalWrite(L_motor1, LOW);
 digitalWrite(L_motor2, LOW);
 digitalWrite(R_motor1, LOW);
 digitalWrite(R_motor2, LOW);
 }

 void loop
 {
 //checking for serial data receiving
 if(Serial.available > 0)
 {
 //if reading the serial data
 msg = Serial.read;

 //with respect to the data received controlling the direction of motor
 if(msg == 'R')
 {
 turn_right;
 }
 if(msg == 'L')
 {
 turn_left ;
 }
 if(msg == 'F')
 {
 move_forward ;
 }
 if(msg == 'B')
 {
 move_backward ;
 }
 if(msg == 'S')
 {
 robo_stop;
 }
 }
 delay(80);
 }

 void move_forward
 {
 digitalWrite(L_motor1, HIGH);
 digitalWrite(L_motor2, LOW);
 digitalWrite(R_motor1, HIGH);
 digitalWrite(R_motor2, LOW);
 }

 void move_backward
 {
 digitalWrite(L_motor1, LOW);
 digitalWrite(L_motor2, HIGH); 
digitalWrite(R_motor1, LOW);
 digitalWrite(R_motor2, HIGH);
 }

 void turn_left
 {
 digitalWrite(L_motor1, LOW);
 digitalWrite(L_motor2, LOW);
 digitalWrite(R_motor1, HIGH);
 digitalWrite(R_motor2, LOW);
 }

 void turn_right
 {
 digitalWrite(L_motor1, HIGH);
 digitalWrite(L_motor2, LOW);
 digitalWrite(R_motor1, LOW);
 digitalWrite(R_motor2, LOW);
 }

 void robo_stop
 {
 digitalWrite(L_motor1, LOW);
 digitalWrite(L_motor2, LOW);
 digitalWrite(R_motor1, LOW);
 digitalWrite(R_motor2, LOW);
 }

###

Circuit diagrams

Circuit Diagram-Capacitive Touch Sensor-Keyboard-Wireless Robot
Circuit Diagram-XBee-Capacitive-Touch Controlled Robot

Project video

Conteúdo Relacionado

A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
ESP32-CAM is a compact camera module that combines the...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.