How to Make a Wireless Path Tracking System Using Mouse, XBee and Arduino
The applications of microcontroller are not limited to control simple electrical or electronic device but they are widely used in robotics and automotive industries nowadays. From simple rear view mirror control to complex engine control functions are done by the microcontroller. The microcontroller can even implement to automatically controlling the vehicle without a human driver inside it and such kinds of vehicles are called Unmanned Vehicles (UV). The UVs are commonly used research, military, rescue and agriculture fields. For any UVs the real time tracking of their path is necessary to ensure that they are moving through the proper way.
This project demonstrates how it is possible to make a simplest path tracking device for a ground vehicle with the help of optical mouse. The optical mouse is a device which has a very small camera inside it which can sense the movement of the ground below it and communicate the change in the X-Y coordinate with an external device through simple serial communication protocols.
This project makes use of an optical mouse which works on PS2 protocol and is interfaced with an Arduino board to read the data from it. The data from the mouse is then transmitted wirelessly using anXbee transceiver pair to a distant computer where the data is displayed graphically as a track in which the mouse movement occurs.
The Xbee is the brand name a wireless transceiver device which works on the ZigBee protocol. The ZigBee is the name of a wireless protocol maintained by the IEEE 802.15 standard. This is a protocol specified for wireless Personal Area Network (PAN) using low powered wireless transceivers. They can be used for simple point to point communication systems also.
Two Xbee S1 series transceivers modules are used in this project and the image of the same module shown in the following figure. Since the pitch of the pins of the modules are not breadboard compatible one can use the Xbee based design boards which comes with breadboard compatible pins.
Since the Xbee modules communicate using serial communication protocol with the interfacing devices they can be connected to a microcontroller using a minimum of four pins, Power supply, and Ground, UART Data Out, and UART Data In pins. The pin number 2, UART Data Out is connected to the RX1 pin of the Arduino pro mini board and pin number 3 UART Data In is connected to the TX0 pin.
In this project the Arduino pro-mini board is used which is pre-programmed with the Arduino boot-loader.The programming IDE used for this project isArduino IDE version 1.0.3 on windows operating system. The image of the Arduino pro-mini board and the Arduino IDE is shown in the following:
Another hardware which can perform the USB to TTL conversion is used to upload the program into the arduino board. This board can be also when it is required to perform serial communication between the PC and the Arduino board.
It is assumed that the reader has gone through the project how to get started with the arduino and done all the things discussed in it.
The PS2 mouse uses a synchronous communication with the PC which is very much similar to the Two Wire Interface protocol. The PS2 connector has a pin for Data and another pin for Clock and using only these two pins the mouse communicate with the host device. The mouse always has 6 pin mini-DIN male connector for PS2 interface and the host device always has the corresponding female pin. The images and the pin-outs of the PS2 male and female connectors are shown in the following image:
When it comes to connecting the female connector with the circuit board one should be able to identify the pins at the bottom of the PS2 connector and the following image will be helpful.
The code written for this project uses the custom PS2 library file called “PS2Mouse.h” which has all the necessary routines for accessing a PS2 mouse. There are two functions which the user can directly make use in their code and are namely “mouse.initialize()” and “mouse.report(data)”.The method of reading the data from the PS2 mouse using the above functions and decoding them to get the X-Y coordinates are explained in a previous project on how to interface a PS2 mouse with the Arduino.
The implementation of the project which can receive the data from PS2 mouse and transmit the X-Y coordinate extracted from the mouse data through Xbee is represented using the following block diagram:
The code written for this project on Arduino reads the PS2 mouse data continuously and writes the data to the Xbee for transmission with the help of serial communication functions provided by the Arduino IDE. The functions like Serial.begin() which helps to initialize the serial port with a given baud rate, Serial.write() to send a data to the serial port, Serial.available() and Serial.read() functions to read data from the serial port are used in this project and they are already discussed in previous projects on how to do serial communication with the Arduino, how to send and receive serial data using arduino and how to do serial debugging with the Arduino. The method of getting the required X-Y data from the PS2 mouse is explained in the previous project on how to interface a PS2 mouse with the Arduino. The method of interfacing an Xbee module and transmission of data using it is discussed in as previous project on how to interface Xbee module with Arduino.
The code reads hundred data sets from the mouse at once and calculates the average change in the X value from those data. This average value of the change in X coordinate is then used to offset the position of a character ‘*’ in a line that has to be transmitted and displayed in the distant computer. Thus as the mouse moves the average value of change in X direction varies which varies the position of the character ‘*’ in the serial monitor window in the distant PC. As the character ‘*’ is printed continuously each time in a new line with a position according to the movement of the mouse one can find it similar to the track drawn which follows the movement of the mouse in X direction.
When the coding is finished one can verify and upload the code to the Arduino board as explained in the project how to get started with the Arduino. As soon as the board is powered up the Xbee in the Arduino board automatically establishes communication with another Xbee which is connected to the serial port of a PC. The second Xbee board can be connected to the PC using the same USB to TTL converter board which has been used to program the Arduino board. Move the mouse and the change in track can be observed using any serial monitoring software or using the Arduino IDE’s serial monitoring software itself as explained in the project how to do serial debugging with the Arduino.
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w