This post is the second part of the previous tutorial we have started about making Soccer robot for RoboCup. In the first part, we have discussed the mechanical parts.In this post, we will see about the Electronics part.
ELECTRONIC DESIGN
Electronic Parts
- Battery
- Power distribution circuit
- H-bridge
- Arduino
- NRF-module
- Boost Converter
- Ball detector circuit
- Solenoid
Battery
The battery is providing source to each component and it is selected as per requirement of
the current. We have selected the lipo battery for our robot because it’s a light weight and
provide us our required current. Our Battery consist of 5 lipo cells each cell having
3.7volts total of 18.5volts battery having 5000mAh current.
- Output voltage 18.5V
- Initial Current 5A Max
- Discharge (c) 25
- Max Charge Rate (C) 2
- Weight (g) 640
- Length(mm) 146
- Height(mm) 51
- Width(mm) 42
Power Distribution circuit
In the robot we needed 3 different voltages to operate our devices first our battery contains 18.5 volts which are needed to operate motors secondly we needed 12 volts to operate our motor driver IC IR2104, dribbler motor and for booster circuit because the input of our booster is 12 volts. In last we needed 5 volts to operate our controller Arduino and for ball detector
circuit.
For this purpose, we design two regulators for step down voltages by using LM7812 and
LM7805 the circuit diagram are as follow.
12-volt regulator circuit consists of
- LM7812
- diode
See the Circuit Diagram:

5volt regulator circuit consists of
- LM7805
- diode
- capacitor
Arduino Development Board
I am not going to discuss the basics of Arduino here.you can read about Arduino in these following posts.
Getting-started-with-Arduino-microcontroller
Wireless Communication using nRF24L01
The wireless communication is done between various nodes. Since we are at the node of between receiving data from GUI, therefore wireless module is used. The controlling of the robot is being done by using a joystick. The module which we used for wireless communication is nRF24L01.
I already discussed complete details about Nrf and Arduino interfacing.Read the detailed post of nrf24Lo1+. Arduino codes for Nrf are also available in that post.
Wireless Communication using Arduino and nrf24lo1+
Solenoid
A solenoid consists of a coil of insulated wire. We have to design solenoid to provide strong inner the magnetic field in order to fulfill our purpose of the kicking mechanism. For this purpose Teflon the material is used on which copper is wounded when current flows through the coil then strong the magnetic field is produced within the core due to which kicking mechanism of the robot will
work.One more post is available for kicker mechanism and solenoid.You can get the design files from there.
specification of the solenoid:
- Wire gauge 30 AWG
- Input voltage 230 V
- Number of turns of Cu wire 1800
- Resistance/meter of Cu wire 0.339
- Diameter of Teflon 8mm
Ball Detector Circuit
To start the dribbler we have designed the ball detector circuit which is mounted on the sides of dribbler by using IR sensor. When there is no object the receiver receives the signal from the transmitter and when the ball comes to our robot the signal will be disconnected the receiver will not generate the output signal and then this logic is inverted through using the NOT gate and it will generate a signal to operate the motor driver for the dribbler. The circuit is shown in the figure.
Booster
For the kick, we have to energize our coil and to energize the coil we needed high voltages for this purpose we have designed the boost converter which converts the 12 volts into 220 volts.
See the Detailed post about Booster
Booster circuit for solenoid mechanism
Motor Driver
To control the direction and speed of motor we have to use motor drivers.
I have done this part using L298 is and also with L298 module.
See the related post on this part.
motor-drivers-and-dual-h-bridge-l298
PROGRAMMING AND ALGORITHMS
The first step was to control robot manually by using remote and wireless communication this step was done by using Arduino and Nrf we first manually control the robot and check its parts are properly working and seeing its direction by controlling motors.
Here is the Code for Arduino boards:
Soccer Robot Code
Transmitter Code(TX):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> #define CE_PIN 9 #define CSN_PIN 10 #define JOYSTICK_X A0 #define JOYSTICK_Y A1 #define JOYSTICK_A A2 #define JOYSTICK_B A3 const uint64_t pipe = 0xF2E4F3F6E9LL; RF24 radio(CE_PIN, CSN_PIN); int joystick[4]; void setup() { Serial.begin(9600); radio.begin(); radio.openWritingPipe(pipe); } void loop() { joystick[0] = analogRead(JOYSTICK_X); joystick[1] = analogRead(JOYSTICK_Y); joystick[2] = analogRead(JOYSTICK_A); joystick[3] = analogRead(JOYSTICK_B); radio.write( joystick, sizeof(joystick) ); } |
Receiver Code(RX):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> #define CE_PIN 9 #define CSN_PIN 10 const uint64_t pipe = 0xF2E4F3F6E9LL; RF24 radio(CE_PIN, CSN_PIN); int joystick[4]; int x,y,a,b; // Motor A int dir1PinA = 36; int dir2PinA = 37; int speedPinA = 5; // Motor B int dir1PinB = 34; int dir2PinB = 35; int speedPinB = 4; // Motor C int dir1PinC = 24; int dir2PinC = 25; int speedPinC = 2; // Motor D int dir1PinD = 26; int dir2PinD = 27; int speedPinD = 3; void setup() { Serial.begin(9600); pinMode(dir1PinA,OUTPUT); pinMode(dir2PinA,OUTPUT); pinMode(speedPinA,OUTPUT); pinMode(dir1PinB,OUTPUT); pinMode(dir2PinB,OUTPUT); pinMode(speedPinB,OUTPUT); pinMode(dir1PinC,OUTPUT); pinMode(dir2PinC,OUTPUT); pinMode(speedPinC,OUTPUT); pinMode(dir1PinD,OUTPUT); pinMode(dir2PinD,OUTPUT); pinMode(speedPinD,OUTPUT); 43 delay(1000); Serial.println("Nrf24L01 Receiver Starting"); radio.begin(); radio.openReadingPipe(1,pipe); radio.startListening();; } void loop() { if ( radio.available() ) { bool done = false; while (!done) { done = radio.read( joystick, sizeof(joystick) ); //Serial.print("X = "); Serial.print(joystick[0]); //x=joystick[0]; //Serial.print(" Y = "); Serial.println(joystick[1]); //y=joystick[1]; //Serial.print(" A = "); Serial.print(joystick[2]); //a=joystick[2]; //Serial.print(" B = "); Serial.print(joystick[3]); //b=joystick[3]; if(joystick[0]<2){ // Forward analogWrite(speedPinA, 180); analogWrite(speedPinB, 180); analogWrite(speedPinC, 150); analogWrite(speedPinD, 150); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); digitalWrite(dir1PinB, HIGH); digitalWrite(dir2PinB, LOW); digitalWrite(dir1PinC, LOW); digitalWrite(dir2PinC, HIGH); digitalWrite(dir1PinD, HIGH); digitalWrite(dir2PinD, LOW);} /downward else if(joystick[0]>1022){ analogWrite(speedPinA, 180); analogWrite(speedPinB, 190); analogWrite(speedPinC, 150); analogWrite(speedPinD, 150); digitalWrite(dir1PinA, HIGH); digitalWrite(dir2PinA, LOW); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); digitalWrite(dir1PinC, HIGH); digitalWrite(dir2PinC, LOW); digitalWrite(dir1PinD, LOW); digitalWrite(dir2PinD, HIGH);} //ccw else if(joystick[3]>1021){ analogWrite(speedPinA, 120); analogWrite(speedPinB, 135); analogWrite(speedPinC, 60); analogWrite(speedPinD, 60); digitalWrite(dir1PinA, HIGH); digitalWrite(dir2PinA, LOW); digitalWrite(dir1PinB, HIGH); digitalWrite(dir2PinB, LOW); digitalWrite(dir1PinC, HIGH); digitalWrite(dir2PinC, LOW); digitalWrite(dir1PinD, HIGH); digitalWrite(dir2PinD, LOW);} //cw else if(joystick[3]<2){ analogWrite(speedPinA, 120); analogWrite(speedPinB, 120); analogWrite(speedPinC, 60); analogWrite(speedPinD, 60); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, HIGH); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, HIGH); digitalWrite(dir1PinC, LOW); digitalWrite(dir2PinC, HIGH); digitalWrite(dir1PinD, LOW); digitalWrite(dir2PinD, HIGH);} 45 else {// Stop (Freespin) analogWrite(speedPinA, 0); analogWrite(speedPinB, 0); analogWrite(speedPinC, 0); analogWrite(speedPinD, 0); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, LOW); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, LOW); digitalWrite(dir1PinC, LOW); digitalWrite(dir2PinC, LOW); digitalWrite(dir1PinD, LOW); digitalWrite(dir2PinD, LOW);} //kick if(joystick[2]<2){ digitalWrite(40,HIGH);} else{ digitalWrite(40,LOW);} } } else { analogWrite(speedPinA, 0); analogWrite(speedPinB, 0); analogWrite(speedPinC, 0); analogWrite(speedPinD, 0); digitalWrite(dir1PinA, LOW); digitalWrite(dir2PinA, LOW); digitalWrite(dir1PinB, LOW); digitalWrite(dir2PinB, LOW); digitalWrite(dir1PinC, LOW); digitalWrite(dir2PinC, LOW); digitalWrite(dir1PinD, LOW); digitalWrite(dir2PinD, LOW); Serial.println("No radio available"); } } |
Concluding Statement
After these steps, we proceed to the Artificial intelligence, after controlling manually robot. First, we serially communicate it with GUI through NRF module. One end of NRF is interfaced with Arduino UNO R3 and on another end we used Arduino MEGA 2560.
in SSL vision the camera captures the image of the robots playing and ball by using color pattern embed on them. This information is broadcasted through WIFI modem. This then is received by our PCs and this information extracted from the file provided by management of the event named as ‘protobuf.’ This information is further utilized to calculate and make the strategy for our robots on the field and predict the movement of opponent and ball using Line equations and orientation. This smart intelligence is used to make a strategy. This strategy is used to calculate the directions and PWMs of all the motors mounted on each robot. Then transmitted to our robot through NRF modules. For this AI server, we are using multi threading in C# to process for 2 robots at the same time. I hope you understand the method and sequence of steps.Half of the things I have covered in separate posts so that’s why I didn’t discuss everything here.
In coming post, we will see how to setup the field for an autonomous robot.Installation of SSL software and testing with example code.
Follow for upcoming updates as still there is much more left about an autonomous robot.so we will cover up everything in coming posts.
I hope you enjoyed it.keep making robots.
Follow for upcoming updates as still there is much more left about an autonomous robot.so we will cover up everything in coming posts.
I hope you enjoyed it.keep making robots.
I need this code of robo soccer
I need this code of robo soccer
Here is the download google drive link:
https://drive.google.com/open?id=0B4GUEE3lRFIJR1c2RW5IeWd3U1k
I did not understand how u used ai in it.software pheripherals integration camera to computer from computer to robot with best optimised path.best direction to kick the ball and kick force parameters