Wireless Robot V2 (Support WiFi & Bluetooth)

by Husham Samir in Circuits > Microcontrollers

60831 Views, 279 Favorites, 0 Comments

Wireless Robot V2 (Support WiFi & Bluetooth)

Wifi Robot V2 a.JPG
Wifi Robot V2.JPG
Wifi Robot V2 b.JPG

Car Structure

1.JPG
2.JPG
3.JPG
5.JPG
6.JPG
7.JPG
91.JPG
93.JPG
94.JPG
95.JPG
I get The motors ,gear box and tires from two broken car kids toys from Scrap market nearby , they cost me about 10$ and I connect them using din rail and plastic as shown in the pictures.

Connection Digram

Full Digram.jpg
Using the Serial pins of ATMEGA16 MCU is The Concept of this circuit and it consist from :

1- H-Bridge Motor driver using two L298.
2- Atmega16 MCU.
3- LEDs Driver using ULN2003.
4- Serial Bluetooth Module.
5- Serial-To-Ethernet converter.
6- WiFi Wireless access point.
7- Easy N surveillance IP cam.
8- 12 Volt battery with 7809 & 7805 voltage regulator  for router and IP cam .
9- 6 Volt Battery for motors. 

H-Bridge Circuits

DSC04307.JPG
DSC04311.JPG
L298-M2.jpg
L298-M1.jpg
two L298 dual H-bridge driver connected as shown in the pictures .
the motors working on 6 volt with 2.4 Amp. maximum current for each.
L298 Data sheet attached.

Downloads

LED Driver

ULN2003A-circuits.jpg
ULN2003 Darlington transistor arrays is a fast solution  and provide 7 output.
The circuit shown in attached picture.
Datasheet attached.
.

Downloads

Controller Circuit

MCU.JPG
Atmega16 Stepper PCB bluetooth.jpg
Frequency resonator.JPG
The source code debugged by ATMEL AVR studio 4 with AVR MKII ISP .
The Scenario of the code depending on:
1-Enabling the RX/TX of ATMEGA16 MCU.
2-Sending the ASCII code from  the PC or Tablet .
3-Translate the ASCII code by the MCU  to a specific output in port A and port C.

The fuse bit  for 16 Mhz external frequency resonator  should be set to :High: 0xC9 , Low: 0xFF as shown in the attached picture. 

Code: 

/*
ATmega16  16MHz external frequency resonator
Baud Rate 9600 No Parity,1 Stop Bit,Flow Control:None
*/

#include <avr/io.h>
#include <inttypes.h>
#include <util/delay.h>


void USARTInit(uint16_t ubrr_value)
{

   //Set Baud rate
   UBRRL = ubrr_value;     
   UBRRH = (ubrr_value>>8);

   UCSRC=(1<<URSEL)|(3<<UCSZ0);   // Set Asynchronous mode,No Parity ,1 StopBit 
   UCSRB=(1<<RXEN)|(1<<TXEN);     //Enable The receiver and transmitter


}


char USARTReadChar()
{
while(!(UCSRA & (1<<RXC)))
{
   // do nothing
  }
return UDR;
}

void USARTWriteChar(char data)
{
while(!(UCSRA & (1<<UDRE)))
{
  //do nothing
  }
UDR=data;
}

void main()
{
DDRC=0xff;
DDRA=0xff;
char data;
USARTInit(103);  //for 16Mhz and baud 9600 UBRR = 103 and for  baud 19200 UBRR = 51 

while(1)
{
data=USARTReadChar(); 
if (data==0x71){PORTC=0b10000000;USARTWriteChar('Q');} //q in ascii
if (data==0x77){PORTC=0b00001001;USARTWriteChar('w');} //w in ascii Forward
if (data==0x65){PORTC=0b01000000;USARTWriteChar('e');} //e in ascii
if (data==0x61){PORTC=0b00000011;USARTWriteChar('A');} //a in ascii Left
if (data==0x73){PORTC=0b00000000;USARTWriteChar('s');} //s in ascii Stop
if (data==0x64){PORTC=0b00001100;USARTWriteChar('d');} //d in ascii Right
if (data==0x7A){PORTC=0b00100000;USARTWriteChar('z');} //z in ascii
if (data==0x78){PORTC=0b10000110;USARTWriteChar('x');} //x in ascii Backward
if (data==0x99){PORTC=0b11110000;USARTWriteChar('c');} //c in ascii

if (data==0x69){PORTC=0b00001001;_delay_ms(200);PORTC=0b00000000;} //i in ascii Forward
if (data==0x6A){PORTC=0b00000011;_delay_ms(200);PORTC=0b00000000;} //j in ascii Left
if (data==0x6C){PORTC=0b00001100;_delay_ms(200);PORTC=0b00000000;} //l in ascii Right
if (data==0x6B){PORTC=0b00000110;_delay_ms(200);PORTC=0b00000000;} //k in ascii Back

if (data==0x31){PORTA=0b00000001;USARTWriteChar('1');} //1 in ascii //2 LED On
if (data==0x32){PORTA=0b00000010;USARTWriteChar('2');} //2 in ascii //4 LED on
if (data==0x33){PORTA=0b00000111;USARTWriteChar('3');} //3 in ascii //6 LED on
if (data==0x34){PORTA=0b00001000;USARTWriteChar('4');} //4 in ascii //Red LED on
if (data==0x35){PORTA=0b00010000;USARTWriteChar('5');} //5 in ascii
if (data==0x36){PORTA=0b00100000;USARTWriteChar('6');} //6 in ascii
if (data==0x37){PORTA=0b01000000;USARTWriteChar('7');} //7 in ascii
if (data==0x38){PORTA=0b10000000;USARTWriteChar('8');} //8 in ascii
if (data==0x39){PORTA=0b00000000;USARTWriteChar('9');} //9 in ascii //All Off 
   else {}
}
}

Serial to Ethernet Converter

Eth.JPG
Eyh2.JPG
setting.JPG
I get the module from below website :
http://en.usr.cn/USRCN/RS232-serial-to-ethernet-converter-tcp-ip-module

Connect:
VDD to 5 Volt.
GND to negative.
RX to TX of ATmega16.
TX to RX of Atmega16.
CFG :Normal Mode when connected to positive , Configuration mode when connected to negative.

Also RS232 to TTL module required  to configure this module .

You can download all the documents from the mentioned website.

For this Project I configure the setting for the converter  as below:
Work Mode   : TCP/IP clinet.
Module IP     : 192.168.1.2 
Subnet Mask:255.255.255.0
Default gateway :192.168.1.1  (Access point IP).
Parity/data/stop  :None /8/1
Destination IP    :192.168.1.3  (Laptop IP).
Destination Port: 8234.
Baud Rate    : 9600




Com-Redirector Software

Com redirector1.jpg

Com-Redirector software used to create Virtual com in the Laptop because there is no direct physical connection to the laptop ,you can also use virtual serial ports emulator software from http://www.eterlogic.com/Downloads.html

Putty or hyper terminal software can be used to send information through this virtual serial port.
please watch the video for more information .

Serial Bluetooth Module

Blue.JPG
SC20130104-220407.jpg
SC20130104-220414.jpg

I get the Slave Mode Serial Bluetooth module from below web site(all document included):
Pass Key:1234

http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=90_91&products_id=603

About the software you can download android Bluetooth Controller  software from android market ,its amazing software and easy to use.
https://play.google.com/store/apps/details?id=apps.BT&hl=en



Switch Selector

Selector.JPG
in the end I connect a selector switch  to select the wireless  mode (WiFi or Bluetooth).