In one of the previous projects “Hand Gesture Controlled Wireless Robot”, it was discussed how remote controls with switches or buttons used for controlling wireless robots have a disadvantage in controlling the robot due to response time factor of the human handling it. As a solution to the problem, use of advanced human-computer interfaces like the gesture recognition, eye movement tracking, and brain waves was suggested. Of which, hand gestures were used in the previous project to control the robot. In this tutorial, a wireless robot will be designed that will be controlled by the joystick. A joystick is not a new input device but it provides better control over the subject. It is easier to use and handle by a human operator.
A joystick is not much different from the remote control developed in the previous project. A joystick works similar to an accelerometer sensor. Like an accelerometer sensor outputs the change in X-axis, Y-axis and Z-axis dimensions of the orientation of the sensor in space, similarly, a joystick sends the change in X-axis, Y-axis and Z-axis dimensions of the orientation of the stick mounted in it. Only X-axis and Y-axis changes are required to move the robot on a surface. In this project, the robot can move in forward, backward, left or right direction based on the tilt of the joystick module. The joystick module is interfaced with the AVR Atmega 32 microcontroller.
There is a 434 MHz RF module interfaced with the AVR circuit to connect the remote circuitry with the control circuitry of the wireless robot. In the robot circuitry, simply, an RF receiver circuit is interfaced with the motor driver IC. The robot is built on two-wheel and a castor body. There are two geared DC motors attached to the wheels and coupled with the L293D motor driver IC to move the robot.
An LCD is interfaced in the remote circuitry of the robot to monitor the change in axis values during the testing of the control circuitry. The robot must be calibrated for an appropriate sensitivity to the joystick movement. The LCD module interfaced in the remote circuitry flashes some initial messages in the starting and then start displaying the change in X and Y axis values along with the control command corresponding to them.
The control circuitry of the wireless robot does not have any controller. The robot is directly controlled by the digital data passed on the RF interface. The remote circuitry has AVR Atmega 32 as the sitting microcontroller. The code managing to interpret joystick signals and to pass appropriate digital data to the wireless robot is runs on the AVR controller. The AVR code is written and compiled using the AVR studio.
Fig. 1: Prototype of AVR based Joystick Controlled Wireless Robot
Components Required –
Fig. 2: List of components required for AVR based Joystick Controlled Wireless Robot
Block Diagram –
The remote circuitry is built by assembling together the following building blocks –
Fig. 3: Block Diagram of Transmitter Side of AVR based Joystick Controlled Wireless Robot
Fig. 4: Block Diagram of Receiver Side of AVR based Joystick Controlled Wireless Robot
The control circuitry of the wireless remote is built by assembling together the following building blocks –
Circuit Connections –
There are two circuits that make up the project – one is the remote circuitry based on AVR microcontroller and other is the receiver circuit mounted on the robot. The remote circuitry has the AVR Atmega 32 as the sitting microcontroller. The LCD module, ADXL335 joystick module, Encoder IC and RF transmitter are interfaced to the AVR controller in the remote circuitry. The circuit connections of the remote circuitry are as follow –
Fig. 5: Image of Transmitter Circuit of AVR based Joystick Controlled Wireless Robot
Power Supply – The remote circuitry requires a 5V supply for its operation. The AVR Atmega 32 microcontroller, RF transmitter, Encoder IC, character LCD and Joystick module, all work on 5V DC. For supplying power to the remote circuitry, a 12V NIMH battery is used. the power from the battery is regulated to 5V DC using 7805 voltage regulator IC. The pin 1 of the voltage regulator IC is connected to the anode of the battery and pin 2 of it is connected to the ground. The regulated voltage output is drawn from pin 3 of the IC. An LED along with a 10K Ω pull-up resistor is also connected between common ground and output pin to get a visual hint of supply continuity.
AVR Atmega 32 – This is an 8-bit AVR RISC based microcontroller. It comes in a 40-pin package and has 2KB RAM, 32KB flash memory, 1KB EEPROM, 32 General Purpose Input Output (GPIO) pins, 8 10-bit ADC channels, One SPI, one UART and one TWI interface on-chip. The controller has three inbuilt timers of which 2 are 8-bit timers and one is a 16-bit timer. The controller operates up to a clock frequency of 16 MHz. By executing powerful instructions in a single clock cycle, the Atmega 32 achieves throughputs approaching 1 MIPS per MHz allowing the system designers to optimize power consumption versus processing speed. The controller comes available in 40-pin Dual Inline (DIP) Package. Check out the pin diagram and pin configuration of this AVR controller here.
In this project 17 GPIO pins of the controller are used of which 11 pins are used to interface the character LCD, 2 pins are used to interface joystick module and 4 pins are used to connect the data pins of the encoder IC.
16X2 LCD: The 16X2 LCD display is used to monitor the sensor values. It is interfaced with the AVR microcontroller by connecting its data pins to port B of the controller. The data pins DB0 to DB7 of the character LCD are interfaced to pins PB0 to PB7 of the AVR Atmega 32 respectively. The RS, RW, and E pins of the LCD are connected to pins PD0, PD1 and PD2 of the AVR respectively. The circuit connections of the character LCD with the AVR controller are summarized in the following table –
Fig. 6: Table listing circuit connections between Arduino Uno and Character LCD
Joystick module – A custom built joystick module is used in the project. The module has five terminals for ground, VCC, X-axis Analog output, Y-axis Analog Output and Z-axis Analog Output. The VCC and ground are connected to common VCC and ground respectively. The X-axis Analog Output and Y-axis Analog Output of the sensor module are utilized and interfaced to Port A Pin 0 and Port A pin 1 of the AVR controller respectively.
RF Transmitter – The RF transmitter is used to transmit the control signals for motor control. The RF transmitter module is a small PCB sub assembly. The RF module, as the name suggests, operates at Radio Frequency. The corresponding frequency range of such modules varies between 30 kHz & 300 GHz. In this RF system, the digital data is represented as variations in the amplitude of carrier wave. This kind of modulation is known as Amplitude Shift Keying (ASK). This RF module operates over 433 MHz frequency and uses ASK modulation technique. The pin configuration of transmitter module is as follow-
Fig. 7: Table listing pin configuration of RF Transmitter
The serialized data from the encoder is received at pin 2 of the module and passed on to the antenna from pin 4 of the module.
HT12E IC – The HT12E IC converts the parallel data into serial data for passing it to the RF transmitter. HT12E encoder IC belongs to the 212 series of encoders. It is paired with 212 series of decoders having the same number of addresses and data format. HT12E is capable of encoding 12 bits, out of them 8 are address bits and 4 are data bits. Thus the encoded signal is a serialized 12-bit parallel data comprising of 4-bit data to be transferred appended with the address byte.
The data pins D0, D1, D2 and D3 of the IC are connected to the pins PC0, PC1, PC2, and PC3 of the AVR controller respectively. All the address pins of the encoder IC are hardwired to ground, so it has an address byte of 0x00. The pin 17 of the IC is connected to pin 2 of the RF transmitter. So, the serialized data is passed from pin 17 of the IC to data input pin of the RF transmitter.
HT12E has a transmission enable pin which is active low. When a trigger signal is received on TE pin, the programmed addresses/data are transmitted together with the header bits via an RF or an infrared transmission medium. HT12E begins a 4-word transmission cycle upon receipt of a transmission enable. This cycle is repeated as long as TE is kept low. As soon as TE returns to high, the encoder output completes its final cycle and then stops.
The control circuitry of the robot consists of RF receiver, RF decoder IC and L293D motor driver IC. The circuit connections of the receiver circuit are as follow –
Fig. 8: Image of Receiver Circuit of AVR based Joystick Controlled Wireless Robot
RF Receiver – The RF receiver detects the radio signal carrying the motor control signals. The RF receiver module has 8 pins and has following pin configuration –
Fig. 9: Table listing pin configuration of RF Receiver
The RF receiver passes the serial data received over RF frequency from its pin 2 to pin 16 of the decoder IC.
HT12D Decoder – The signal detected by the RF receiver is passed to the HT12D decoder. It converts the serial data back to the parallel data after separating data and addresses. HT12D belongs to the 212 series of decoders and can be paired with 212 series of encoders having the same number of addresses and data format. HT12D is capable of decoding 12 bits, out of them 8 are address bits and 4 are data bits. The 4-bit data is of latch type and when passed to the output data pins it remains unchanged until the new data is received.
The serial data received by the RF receiver is parallel output from its data pins as it is. The data pins of the decoder IC are interfaced with input pins of the L293D motor driver IC. So the digital logic at the data pins of the decoder controls the rotation of the DC motors. All the address pins of the decoder IC are connected to ground to match the address byte to 0x00 same as of the transmitter circuit.
L293D DC Motor Driver IC – The L293D is a dual H-bridge motor driver integrated circuit (IC). The Motor drivers act as current amplifiers since they take a low-current control signal and provide a higher-current signal. This higher current signal is used to drive the motors. It has 16 pins with following pin configuration:
Fig. 10: Table listing pin configuration of L293D Motor Driver IC
There are two DC motors used for making the robotic car. The DC motors are interfaced between pins 3 and 6 and pins 14 and 11 of the motor driver IC.
The L293D IC controls the DC Motors according to the following truth tables:
Fig. 11: Truth Table of L293D Motor Driver IC
The pin 4, 5, 13 and 12 of the L293D are grounded while pin 1, 16 and 9 are connected to 5V DC and pin 8 is connected to 12V DC. The pins 2, 7, 10 and 15 of the motor driver IC are connected to data pins D0, D1, D2 and D3 of the decoder IC. The DC motor attached to right wheel is connected to pins 11 and 14 while motor attached to the left wheel is connected to pins 3 and 6 of the motor driver IC.
Geared DC Motors – In this robot, 12V geared DC motors are attached to the wheels. Geared DC motors are available with wide range of RPM and Torque, which allow a robot to move based on the control signal it receives from the motor driver IC.
Power Supply – In the receiver circuit, the motor driver IC needs 12V DC while the RF receiver and decoder IC need 5V DC for their operation. A 12V NIMH battery is used as the primary source of power in the circuit. The supply from the battery is regulated to 5V and 12V using 7805 and 7812 ICs. The pin 1 of both the voltage regulator ICs are connected to the anode of the battery and pin 2 of both ICs is connected to ground. The respective voltage outputs are drawn from pin 3 of the respective voltage regulator ICs. An LED along with a 10K Ω pull-up resistor is also connected between common ground and output pin to get a visual hint of supply continuity. Despite using the 12V battery, 7812 is used to provide a regulated and stable supply to the motor driver IC.
Fig. 12: Image showing AVR based Joystick Controlled Wireless Robot
How the circuit works –
As the battery is attached to the robot, the RF receiver is configured to pair with the RF transmitter and it starts receiving the data. On the transmitter side, first the initial messages are flashed on the LCD screen and the AVR microcontroller starts reading the X-axis and Y-axis data from the joystick module in the form of analog voltage. The voltage is sensed by the analog input pins and converted to a digitized reading using inbuilt ADC channels. The ADC channels are 10-bit long, so, the digitized reading of module’s X-axis and Y-axis output varies from 0 to 1023.
The digitized values are displayed on the LCD module along with the control command passed for the respective axis values. The reading is manipulated to determine whether the joystick has tilted forward, backward, left side or right side. Depending upon the tilt of the joystick, the controller passes on appropriate data bits to the RF encoder to drive DC motors for forward, backward, left or right movement of the robot.
The same digital logic is reflected at the data pins of the decoder IC as it is. The robot can be moved forward, backward, left or right by implementing the following input logic at the motor driver pins –
Fig. 13: Logic Table of L293D Motor Driver IC for AVR Robot
Check out the programming guide to learn how the AVR controller reads data from the joystick module and manipulate X-axis and Y-axis values to determine control commands. Learn from the code how digital data is passed on to the RF module for controlling the robot.
Programming Guide –
In order to program Atmega 32 microcontroller, AVR studio 4 and GCC compiler are the software tools required. For learning how AVR studio 4 is used see the following tutorial –
Working with AVR Studio
First of all, separate header files are imported for the Initialization of lcd, ADC and joystick module. The lcd.h, adc.h and joystick.h are included for the LCD programming, ADC and joystick module respectively.
#include <avr/lcd.h>
#include <avr/adc.h>
#include <avr/joystick.h>
In order to make header files work, they must be copied to the following folder – C > WinAVR-20090313 > avr > include > avr and paste the downloaded header files in the folder.
Note that in the path WinAVR-20090313, 20090313 is a number appended to the installation folder. This number can be different in a different installation of the AVR Studio.
Fig. 14: Screenshot of Initialization in AVR Code for Joystick Controlled Wireless Robot
Next, the ports are defined which are connected with the LCD and Joystick module. They are initialized for the maximum and minimum values of x and y axis at the range where robot has to be controlled.
Fig. 15: Screenshot of Main function in AVR Code for Joystick Controlled Wireless Robot
The main function provides logic for the entire operation of the remote circuitry. In this function, the pins are declared as input or output pin for the port that are already initialized.
Fig. 16: Screenshot of Infinite Loop in AVR Code for Joystick Controlled Wireless Robot
The while loop inside the main() function is an infinite loop, where the sensor data is read and the conditions are implemented to make the robot run. check out the complete AVR code.
You may also like:
Project Source Code
###
//Program to #ifndef _ADC_H_ #define _ADC_H_ 1 #include#include void adc_init(void); // This function is declared to read the digital value of the ADC conversion int read_adc_channel(unsigned char channel); /*Function definations*/ void adc_init(void) { ADCSRA=(1< ADMUX=(1< _delay_ms(1); temp=ADCL; adc_value=ADCH; adc_value=(adc_value<<8)|temp; return adc_value; } #endif //**************************************************************// //Microcontroller :ATmega32 //System Clock :1MHz //Project :joystick controlled wireless robot //Software :AVR Studio 4 //LCD Data Interfacing :8-Bit //Date :July 2017 //**************************************************************// //Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers #include//Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz) #define F_CPU 1000000 //Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay) #include //Defines a macro for the lcd.h header File. LCD_DATA_PORT is the microcontroller PORT Register to which the data pins of the LCD are connected. Default PORT Register for data pins in lcd.h header file is PORTA #define LCD_DATA_PORT PORTB //Defines a macro for the lcd.h header File. LCD_CONT_PORT is the microcontroller PORT Register to which the control pins of the LCD are connected. Default PORT Register for control pins in lcd.h header file is PORTB* #define LCD_CONT_PORT PORTD //Defines a macro for the lcd.h header file. LCD_RS is the microcontroller Port pin to which the RS pin of the LCD is connected. Default Port pin for RS pin in lcd.h header file is PB0 #define LCD_RS PD0 //Defines a macro for the lcd.h header file. LCD_RW is the microcontroller Port pin to which the RW pin of the LCD is connected. Default Port pin for RW pin in lcd.h header file is PB1 #define LCD_RW PD1 //Defines a macro for the lcd.h header file. LCD_EN is the microcontroller Port pin to which the EN pin of the LCD is connected. Default Port pin for EN pin in lcd.h header file is PB2 #define LCD_EN PD2 //Includes lcd.h header file which defines different functions for all Alphanumeric LCD(8-Bit Interfacing Method) #include //Includes adc.h header file which defines different functions for Analog to Digital Converter. #include //Includes joystick.h header file which defines different functions for joystick #include //Defines the lower threshold for the x-axis value of joystick #define X_MIN 100 //Defines the upper threshold for the x-axis value of joystick #define X_MAX 900 //Defines the lower threshold for the y-axis value of joystick #define Y_MIN 100 //Defines the upper threshold for the y-axis value of joystick #define Y_MAX 900 int main() { //All the 8 pins of PortB are declared output (data pins of LCD are connected) DDRB=0xff; //PD0, PD1 and PD2 pins of PortD are declared output (control pins of LCD are connected) DDRD=0x07; //PC0,PC1,PC2 and PC3 pins of PortC are declared output ( i/p1,i/p2,i/p3,i/p4 pins of DC Motor Driver are connected ) DDRC=0x0f; //Variable declarations int x_axis,y_axis; //ADC initialization adc_init(); //LCD initialization lcd_init(); //String display in 1st row of LCD lcd_string_write("EngineersGarage"); //Cursor moves to 2nd row 1st column of LCD lcd_command_write(0xc0); //String display in 2nd row of LCD lcd_string_write("EG LAB"); //Display stays for 2 second _delay_ms(500); _delay_ms(500); _delay_ms(500); _delay_ms(500); //Clear screen*/ lcd_command_write(0x01); //String display in 1st row of LCD lcd_string_write("Tilt your Hand:"); //Cursor moves to 2nd row 1st column of LCD lcd_command_write(0xc0); //Start of infinite loop while(1) { //Reading x-axis value of joystick x_axis=read_joystick_x_value(0); //Reading y-axis value of joystick y_axis=read_joystick_x_value(1); //Cursor moves to 2nd row 1st column of LCD lcd_command_write(0xc0); //Checking the joystick movement to move the robot in different direction if(x_axis>X_MAX) { //Robot will move forward direction PORTC=0x0A; //String display in 2nd row of LCD lcd_string_write("Moving Forward "); } else if(x_axis Y_MAX) { //Robot will move in right direction PORTC=0x08; //String display in 2nd row of LCD lcd_string_write("Moving Right "); } else if(y_axis ###
Circuit Diagrams
Circuit-Diagram-Transmitter-Side-AVR-Joystick-Controlled-Wireless-Robot | |
Circuit-Diagram-Receiver-Side-AVR-Joystick-Controlled-Wireless-Robot |
Project Video
Filed Under: Electronic Projects, Featured Contributions
Filed Under: Electronic Projects, Featured Contributions
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.