Advertisement

Beetle-Bot
Instruction Manual
V.1.3
Github https://github.com/keywish/keywish-beetle-bot
1

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Beetle-Bot and is the answer not in the manual?

Questions and answers

Summary of Contents for Keywish Beetle-Bot

  • Page 1 Beetle-Bot Instruction Manual V.1.3 Github https://github.com/keywish/keywish-beetle-bot...
  • Page 2: Revision History

    Revision History 日期 版本号 描述 作者 2018-11-19 V.1.0 Create a document 2019-2-12 V.1.1 Optimize servo installation steps Abbott.chen V.1.2 Carl 2019-2-13 Change wire V.1.3 Fixed picture Abbott.chen 2019-2-28...
  • Page 3: Table Of Contents

    3.1.3 Motor Driver Board Installation ..................... 20 3.1.4 Tracing module and copper column installation ..............23 3.1.5 Battery box and Keywish Uno R3 motherboard installation ..........25 3.1.6 Installation of the Servo and ultrasonic .................. 29 3.1.7 Infrared obstacle avoidance module installation ..............35 3.1.8 Voltage display module installation..................
  • Page 4: Chapter1 Introduction

    Arduino and the car development through written examples step by step. This manual is a specifications for "Beetle-Bot" , the file whose format is PDF which is in the CD along with our product requires the corresponding software to open. It contains detailed schematic diagrams and complete source codes for all instances, the codes won't have any mistake under our strict test.
  • Page 5 ◆ Two groups of infrared obstacle avoidance module ◆ Ultrasonic obstacle avoidance ◆ Four DC motor drive ◆ Two 1865mZh, 3.7V rechargeable lithium battery with longer endurance ◆ Remaining capacity of battery real-time detection ◆ Infrared remote control ◆ Bluetooth app control ◆...
  • Page 6 Product device list:...
  • Page 7: Chapter2 Preparations

    About Arduino uno r3 In "Beetle-Bot", we used the Arduino uno r3 as the main control board, which has 14 digital input/output pins (6 of which can be used as PWM output), 6 analog inputs, and a 16 MHz ceramic resonator, 1 USB connection, 1 power socket, 1 ICSP head and 1 reset button.
  • Page 8: Development Environment Arduino Ide

    2.1 Development environment Arduino IDE 2.1.1 Install the IDE AduinoIDE is an open source software and hardware tool written by open source software such as Java, Processing, and avr-gcc. It is an integrated development environment that runs on a computer. It can write and transfer programs to the board.
  • Page 9 anti-virus software during the installation process, otherwise it may affect the installation of the IDE. After the installation is complete, click "arduino.exe" again to enter the IDE programming interface. Figure 2.1.2 Arduino IDE Installation Package Figure 2.1.3 Extracted files When finish the installation of the IDE,connect to the Arduino motherboard,click“My Computer”→ “Properties”...
  • Page 10 that indicates the driver has been installed successfully,At this time we open the IDE, select the corresponding development board model and port in the toolbar to use normally. If you see Figure 2.1.5, it means that the computer does not recognize the development board and you need to install the driver yourself.
  • Page 11 Figure 2.1.6 Updated Driver Interface 2)Next, select the "Browse my computer for driver software" option. Figure 2.1.7 Driver Update Selection Screen...
  • Page 12 3)Finally select the driver file named "FTDI USB Drivers" located in the "Drivers" folder of the Arduino software download. Figure 2.1.8 Driver file selection interface 4)If you have already installed, the following figure will automatically inform you that the driver was successful.
  • Page 13 Figure 2.1.9 Driver Installation Successful Interface At this time, we return to the "Device Manager" interface, the computer has successfully identified Arduino, as shown in the below Figure 2.1.10 .then open the Arduino compilation environment, you can open the Arduino trip. Figure 2.1.10 Driver Success Recognition Interface...
  • Page 14 Notice In Win10 system, some Arduino are connected to the computer (non-genuine chips are difficult to identify), the system will automatically download the corresponding driver, so you can not install the driver yourself, but in the Win7 system, you have to do it yourself. In addition, we can see that the USB serial port is identified as COM15 in the above figure, but it may be different with different computer, you may be COM4, COM5, etc., but USB-SERIAL CH340, this must be the same.
  • Page 15 Figure 2.1.12 Arduino IDE Interface 2.There are 5 menus on the menu bar, but we mainly introduce File and Tools. Click File, the interface as shown in Figure 2.1.13 will be displayed, you can see the Examples and Preference options. The Examples are some of the Arduino's own programs, these are compiled without errors, the normal use of the program, a great help for beginners.
  • Page 16 Figure 2.1.14 Tools interface 图2.4.14 USB串口选择 So far, we have basically completed all the work. The next step is actual experiments. Open any program in Examples. First compile the program. If it is compiled correctly, it can be directly downloaded to the development board and the corresponding device of the connection number.
  • Page 17: Chapter3 Experiments

    Chapter3 Experiments 3.1Beetle Bot Assembly Base board universal wheel installation 3.1.1 Firstly, we open the box, take out all the components and put it on the table lightly. (Note: There are many devices, be careful when installingto prevent some devices from being lost) Note: The universal wheel is fixed by using its own two screws.
  • Page 18: Install Motor And Wheel

    3.1.2 Install motor and wheel Step 1: Weld the wire to the motor Note: The motor pin is marked with positive and negative poles, positive welding red wire and negative welding black wire. Figure 3.1.2.1 Effect diagram of motor welding Step 2: Install the tire Note: Align the motor drive shaft flat section with the tire hole Figure 3.1.2.2 Effect diagram of Tire installation...
  • Page 19 Step 3: Install the motor Figure 3.1.2.3 Effect diagram of motor mounting bracket installation Note: Hole 1 corresponds to the nut 1", tightened from the bottom with an M2*9 Phillips screw, and so on. Figure 3.1.2.4 Motor installation diagram...
  • Page 20: Motor Driver Board Installation

    Figure 3.1.2.5 Motor installation effect diagram 3.1.3 Motor Driver Board Installation Step 1: motor drive board pillar installation Figure 3.1.3.1 Schematic diagram of motor drive board pillar installation...
  • Page 21 Figure 3.1.3.2 Effect diagram of motor drive board pillar installation Step 2: motor drive board installation Note: Hole 1 corresponds to 1", hole 2 corresponds to 2", tightened with M3*5screw and so on Figure 3.1.3.3 Schematic diagram of Motor Driver Board Installation...
  • Page 22 Figure 3.1.3.4 Effect diagram of Motor Driver Board Installation Note: The left motor positive pole is connected to OUT1, the negative pole is connected to OUT2; the right motor positive pole is connected to OUT3, and the negative pole is connected to OUT4. Figur 3.1.3.5 Motor and drive board connection diagram...
  • Page 23: Tracing Module And Copper Column Installation

    3.1.4 Tracing module and copper column installation Step 1: Tracing module installation Figure 3.1.4.1 Tracing module installation checklist...
  • Page 24 Figure 3.1.4.2 Schematic diagram of the tracing module installation Figure 3.1.4.3 Effect diagram of the tracing module installation Step 2: the upper acrylic plate pillar installation Figure 3.1.4.4 Schematic diagram of the installation of the upper acrylic plate pillar...
  • Page 25: Battery Box And Keywish Uno R3 Motherboard Installation

    Figure 3.1.4.5 Effect diagram of the installation of the upper acrylic plate pillar 3.1.5 Battery box and Keywish Uno R3 motherboard installation Step 1: Keywish Uno R3 Motherboard pillar installation Note: This side is the front of the acrylic plate Figure 3.1.5.1 Schematic diagram of Keywish Uno R3 Motherboard pillar installation...
  • Page 26 Figure 3.1.5.2 Effect diagram of Keywish Uno R3 Motherboard pillar installation Step 2: Battery box installation Figure 3.1.5.3 Schematic diagram of Battery box fixed...
  • Page 27 Figure 3.1.5.4 Effect diagram of Battery box fixed Figure 3.1.5.5 Schematic diagram of Battery box installation...
  • Page 28 Figure 3.1.5.6 Effect diagram of Battery box installation Step 3: Keywish Uno R3 motherboard installation Note: 1 corresponds to 1" 2 corresponds to 2" 3 corresponds to 3" 4 corresponds to 4", fixed with M3*5 screw. Figure 3.1.5.7 Schematic diagram of Keywish Uno R3 motherboard installation...
  • Page 29: Installation Of The Servo And Ultrasonic

    Figure 3.1.5.8 Effect diagram of Keywish Uno R3 motherboard installation 3.1.6 Installation of the Servo and ultrasonic Step 1: Servo Installaion Note: Firstly, place the servo base on the corresponding position of the acrylic plate and then put the servo and fix it with screws. The holes 1 and 2 are fixed with M2*12 screws, and the 3 and 4 holes are...
  • Page 30 Figure 3.1.6.1 Schematic diagram of steering gear installation Figure 3.1.6.2 Effect diagram of servo installation In order to reduce the angle adjustment of the servo, we need to adjust the servo to 90 degrees. First, we should (Lesson\ModuleDemo\ServoTest\ServoTest.ino) Download it to the control panel, and the three wires of the steering gear are the signal wire (orange), power wire (red), and ground wire (brown), and then connect the signal wire of the steering gear (orange) to port 13 of Arduino, and install the rudder propeller without fixing screws, as shown in figure 3.1.6.3.
  • Page 31 After burning the program to the UNO board, do not unplug the USB cable and plug the battery plug into the UNO board to power it, then open the serial port monitor for the Arduino IED, as shown in figure 3.1.6.4 Figure 3.1.6.4 Open the serial monitor schematic diagram After the serial port monitor is opened, the serial port monitor receives 0,90,180,90 successively, such steering gear Angle value, as shown in figure 3.1.6.5...
  • Page 32 keep don't turn the steering gear and pitman arm will be removed, and then reinstall into figure 3.1.6.6, such calibration is completed, the steering gear can be screwed good steering gear, for the next step of operation Figure 3.1.6.6 Calibration diagram of Servo ServoPin = 13;...
  • Page 33 //Continue to determine the serial port there is no data, know all the data read // Determine whether the temporary variable is empty (temp != "") { angle = temp.toInt(); //Convert variable string type to integer Serial.print("Servo degree: "); SetServoDegree(angle); //Control the servo to rotate the corresponding angle.
  • Page 34 Note: When fixing, please put the rudder paddle in the middle of the ultrasonic bracket to fix it. Figure 3.1.6.8 Effect diagram of the rudder propeller fixed ultrasonic bracket After using the rudder propeller to fix the ultrasonic bracket, you can add the ultrasonic bracket to the servo,copied into the compilation environment, then connect servo signal line (orange) is to the Arduino No.
  • Page 35: Infrared Obstacle Avoidance Module Installation

    Figure 3.1.6.10 Diagram of ultrasonic connection 3.1.7 Infrared obstacle avoidance module installation Figure 3.1.7.1 Schematic diagram of infrared obstacle avoidance module installation...
  • Page 36 Figure 3.1.7.2 Effect diagram of infrared obstacle avoidance module installation Figure 3.1.7.3Wiring diagram of infrared obstacle avoidance module...
  • Page 37: Voltage Display Module Installation

    3.1.8 Voltage display module installation Figure 3.1.8.1 Schematic diagram of voltage display module installation Figure 3.1.8.2 Effect diagram of voltage display module installation...
  • Page 38 3.1.9 Infrared remote control receiver installation Figure 3.1.9.1 Schematic diagram of infrared remote control receiver installation Figure 3.1.9.2 Effect diagram of infrared remote control receiver installation...
  • Page 39: Welding Power Cord

    图 3.1.9.3 Schematic diagram of upper board wiring 3.1.9 Welding power cord Connect the power cable: Firstly, find the matching two power cables (the same as the wires used by the motor, one red and one black) and connect the two cables to the DC power head. The DC power connector is shown in Figure3.1.10.1.
  • Page 40: Whole Assembly

    Figure 3.1.9.2 Schematic diagram of wire welding 3.1.10 Whole Assembly For the whole assembly, first insert the “4Pin wire” into the “IN1—IN4” on the motor drive, and thread the other end of the tracing module from the bottom of the trolley to the top, as shown in Figure 3.1.10.1. Then screw the battery box and the voltage display module and the DC head wire together (as shown in Figure 3.1.10.2), connect the positive pole (red line) to +12V, and the negative pole (black line) to GND.
  • Page 41 Figure 3.1.10.2 Battery connection diagram Figure 3.1.10.3 Schematic diagram of motor drive board wiring...
  • Page 42: Expansion Board Wiring Diagram

    Figure 3.1.10.4 Integral wiring diagram Figure 3.1.10.4 Schematic diagram of wiring completion 3.1.11 Expansion board wiring diagram Through the previous steps, we have completed the installation of the main structure of the car. Now we wire the car to connect the cable. The connection method is as shown in the following figure. For the...
  • Page 43 specific experiment of a certain module, we will introduce it in detail through the following chapters. Figure 3.1.11.1 Expansion board connection diagram Figure 3.1.11.2 Extension board wiring diagram...
  • Page 44 Figure 3.1.11.3 Overall wiring diagram The full installation of the car is as shown below...
  • Page 45 Figure 3.1.11.4 Complete the assembly diagram So far, the basic assembly of car has been completed. We believe you have some basic knowledge of your car’s structure, function and some modules through a short period of time, then you can achieve the corresponding functions only by downloading the program to the development board, each function has a corresponding program in CD, so please enjoy playing.
  • Page 46: Beetle Bot Module Experiment

    3.2.1 Walking Principle of the Car In the "Beetle-Bot" car, we choose the L298N as the motor driver chip for it is a high voltage and current full-bridge driver chip, the chip uses 15 pins package. It is a special motor driven integrated circuit (two H bridges) with high voltage and current full-bridge driver.
  • Page 47 Controlling the stepper motor ◆ The speed control with PWM pulse width ◆ Positive and negative rotation Motor status Forward Reversal Quick stop Stop Figure .3.2.1.2 Logic Function Chart Fig.3.2.1.3 Module Physical Map Detailed L298N chip data please refer to “Beetle-Bot\Document\L298N_datasheet.pdf”...
  • Page 48 Figure .3.2.1.4 Schematic Diagram of Motor Drive Four DC motors with high power L298N drive enable "Beetle-Bot" to run faster than conventional two- wheel car, the acceleration time is shorter and the structure is more stable. However, in the actual...
  • Page 49 Figure 3.2.1.6Relation between Pulse and Voltage In the "Beetle-Bot" car experiment, we use Arduino UNO R3 as the main control board. By referring to the chip data, we will know that Arduino UNO has 6 PWM pins, namely digital interfaces 3, 5, 6, 9, 10, 11, and we select 5, 6, 9, 10 as the motor control IO, the connection is shown in Fig3.1.2.7...
  • Page 50 Figure 3.1.2.7Arduino and L298N driver board connection diagram and connection table The L298N and Arduino expansion board wiring is as follows:...
  • Page 51 Figure.3.1.2.8 L298N and Arduino Expansion Board Connection Diagram After the connection, we do not know whether the motor can work normally or not, so we need to do a simple test by copying the following code (You can also open the program in the CD directly.) into the IDE development environment and downloading to the development board.
  • Page 52 Note: This test and IO selection are only for reference, you can choose other IO ports or use other wiring methods according to your own ideas. Test demo path: Lesson\ModuleDemo\Motor Test\MotorTest\MotorTest.ino INPUT3_PIN = 5; //PWMA INPUT4_PIN = 9; //PWMA INPUT1_PIN = 6;...
  • Page 53: Infrared Obstacle Avoidance

    analogWrite(INPUT2_PIN, 0); analogWrite(INPUT1_PIN, 0); analogWrite(INPUT3_PIN, 0); analogWrite(INPUT4_PIN, 150);//the speed value of motorA is 150 delay(3000); //*******************************************//left analogWrite(INPUT2_PIN, 0); analogWrite(INPUT1_PIN, 0); //the speed value of motorA is 0 analogWrite(INPUT3_PIN, 0); analogWrite(INPUT4_PIN, 0); //the speed value of motorB is 0 delay(1000); //*******************************************//stop analogWrite(INPUT2_PIN, 0);...
  • Page 54 arduino Uno Infrared Obstacle Avoidance Module The left module The right module Chart 3.2.2.1 Pin Wiring Definition 3.2.2.3 Module Parameters The working principle of infrared obstacle avoidance sensor is very simple, that is the reflection property of objects. In a certain range, if there is no obstacle, the infrared ray emitted will gradually weaken because of the farther distance of transmission, and finally disappear.
  • Page 55 Figure 3.2.2.3 Connection of Arduino and Sensor Note: This module can adjust the detection distance by the potentiometer, the detection distance is 2- 30cm, if it is found that the distance detection is not very sensitive, you can use the potentiometer to achieve the desired results (rotating the potentiometer clockwise will increase the detection distance;...
  • Page 56 3.2.2.4 Wire connection As the figure shown below, the upper column is the "GND" interface, the middle column is the "VCC" interface, and the lower column is the "OUT" interface, where "A3" corresponds to the "OUT" of the left infrared obstacle avoidance, and "A4" corresponds to the right infrared obstacle avoidance. "OUT". Figure 3.2.2.5 Wire connection diagram 3.2.2.5 Experimental Procedures 1, Fixing the two sensors on the car and connecting them to Arduino with wires.(Already done)
  • Page 57 Note: Here we connect the infrared obstacle avoidance signal output port to the analog port on Arduino (A0-A5), so the serial port prints out analog value, you can connect it to digital port (2-13), and the serial port will only print out "0" and "1". Program flow chart is as follows: Test demo path::Lesson\ModuleDemo\InfraredAvoidanceTest\ InfraredAvoidanceTest.ino const int...
  • Page 59 Figure .3.2.2.6 Diagram of Data with Obstacles Figure .3.2.2.7 Diagram of Data without Obstacles...
  • Page 60 3.2.2.5 Software Design 3.2.2.5.1 Program flow chart 3.2.2.5.2 Program code In the above steps, we have tested the car’s driving and obstacle avoidance module respectively, they have achieved the desired results, here the "infrared obstacle avoidance" actually has been explained in this section, but we have not put the programs of two parts together, so we now integrate the program of the two parts and complete this great "infrared obstacle avoidance"...
  • Page 61 INPUT2_PIN //DIRB****************************************Left /*Define 4 motor control terminals, connected to IN1-IN4 on the motor RightValueive board。*/ const int leftPin = A3; const int rightPin = A4; // Define the two signal receiving ends of the sensor float LeftValue; float RightValue;// Define two margins to store the values read by both sensors void setup() { Serial.begin(9600);...
  • Page 62 analogWrite(INPUT1_PIN, 100); /*Set a PWM value, the maximum PWM is 255, but the speed of the car should not be too fast when walking, otherwise it can not hit the obstacle in time when the obstacles are suddenly encountered.*/ Serial.print(LeftValue); Serial.print("...
  • Page 63 delay(1000);//*********************************//Turning around (LeftValue <= && RightValue >= 38) /*If the left sensor is less than or equal to 38 and the RightValue value is greater than or equal to 38, the following program in {} is executed (LeftValue <= 38, indicating that there is an obstacle on the left, RightValue>...
  • Page 64: Infrared Tracing

    In the "Beetle-Bot" car, we use the TCRT5000 sensor as tracing module, TCRT5000 infrared reflection sensor is a photoelectric sensor which consists of an infrared emitting diode and an NPN infrared photoelectric transistor.
  • Page 65 Figure .3.2.3.1 Physical Map of the Module 3.2.3.2 Working Principle In the above, we talked about two patterns of tracing-the white line and the black line. In fact, either the black line or the white line, we usually adopt the infrared detection method. Infrared detection method means that different objects with different colors have the different infrared reflection characteristics.
  • Page 66 Using wide voltage comparator 74HC14D, digital output (0 and 1) ◆ Easy-to-install fixed bolt holes Detailed parameters please refer to “Beetle-bot\Document\ TCRT5000.pdf” Note: between positive and negative poles. Connecting the VCC to 3.3V or 5V, the OUT output port to the...
  • Page 67 otherwise it can’t be used. As for other MCU, such as ARM or more advanced control boards, if the I/O ports need to be used as the input and output mode, they have to be set to the input mode / receiving mode. The 51 series microcontrollers can be used directly, there is no need to set the input and output mode.
  • Page 68 Figure .3.2.3.4 Wire connection diagram 3.2.3.5 Experimental Procedures 1, Fixing the sensor on the car (the assembly is completed) and connecting it to the Arduino as shown in Fig.3.2.19. 2, Making the track.If your floor is white, then you could stick a black tape to form a loop, otherwise stick a white tape, the shape of track is based on your own desires, the best width of the tape is 13-18mm.
  • Page 69 Note: Here we connect the signal output port of infrared obstacle avoidance to the analog port on Arduino (A0-A5), so the serial port monitor prints analog values, you can connect it to the digital port (2- 13), then the serial port monitor will print out only "0" and "1". Test demo path:Lesson\ModuleDemo\InfraredTracingTest\InfraredTracingTest.ino...
  • Page 70 void setup() { Serial.begin(9600); pinMode(A0,INPUT); pinMode(A1,INPUT); pinMode(A2,INPUT); void loop() { left, centre, right; left = analogRead(A0); centre = analogRead(A1); right = analogRead(A2); Serial.print("right:"); Serial.print(right); Serial.print(" "); Serial.print("centre:"); Serial.print(centre); Serial.print(" "); Serial.print("left:"); Serial.print(left); Serial.println(" "); Figure .3.2.3.5 Example of the Black Track...
  • Page 71 Fig 3.2.3.6 The Data When the Sensor Does Not Detect the Black Line Fig 3.2.3.7 The Data When the Sensor Does Not Detect the Black Line From Fig.3.2.3.6 and Fig.3.2.3.7 we can see that the output is high level when the sensor does not detect the black line, low level when detects the black line.
  • Page 72 3.2.3.6 Software Design 3.2.3.6.1. Program flow chart When the car enters the tracing mode, it keeps scanning the I/O port of the MCU connected to the sensors, once detecting the changes in signal at the I/O port, the corresponding procedure will be implemented, the corresponding signal will be sent to the motor so as to correct the status of the car.
  • Page 73 3.2.3.6.2. Program Code demo path:Lesson\Advanced experiment\Beetle_InfraredTracing\Beetle_InfraredTracing.ino INPUT3_PIN = 5; //PWMA INPUT4_PIN = 9; //DIRA****************************************left INPUT1_PIN = 6; //PWMB INPUT2_PIN = 10; //DIRB****************************************right /*Define 4 motor control terminals, connected to IN1-IN4 on the motor drive board.*/ void setup() { Serial.begin(9600); /*Set the baud rate to 9600 */ void loop() left, centre, right;...
  • Page 74 else if ((right >= 975) && (centre >= 975) && (left <= 8)) { /* Judge the collected value, if center > = 975 and right > = 975 are greater than 975, indicating that the middle and right sensors did not detect the black line, left <= 8 shows that the left sensor detects the black line, then the car Has been to the right deviation, or the black line has turned to the left, so the car should turn left at this time.
  • Page 75: Ultrasonic Obstacle Avoidance

    3.2.4 Ultrasonic Obstacle Avoidance In this product, we will integrate the ultrasonic module and steering engine together and make the two parts working at the same time, which greatly increases the effectiveness of the data and the flexibility of the car, the main working flow: When the power is on, steering engine will automatically rotates to 90 degrees, the MCU will read data from the reflected ultrasonic.
  • Page 76 Distance measurement with the ultrasonic is also a hot spot. In the "Beetle-Bot" car, we use HC-SR04 ultrasonic module which has the 2cm-400cm non-contact distance sensing function, the measurement accuracy can achieve to 3mm; the temperature sensor can correct the measured results using the GPIO communication mode, the module has a stable and reliable watchdog.
  • Page 77 Figure 3.2.4.3 Physical Map of Ultrasonic Module 3.2.4.2 Suite Parameters 1. Steering gear The steering gear has three input wires as shown in Fig.3.2.25, the red is power wire, while the brown is the ground, which guarantee the basic energy supply for the steering gear. The power supply has two kinds of specifications (one is 4.8V, the other is 6.0V)which are corresponding to different torque standards, the 6.0V torque is higher than the 4.8V torque;...
  • Page 78 temperature value; the 2 data started with 0x77 are the illumination values. 0x55\0x66\0x77 are the data headers in order to distinguish the 3 data; 8, Supporting the following 2 detection methods: 1, continuous detection; 2, controlled intermittent detection; 9, Distance data format: using mm as the smallest data unit, double byte 16 hexadecimal transmission; 10, Temperature data format: using Celsius degree as the smallest unit, single byte hexadecimal transmission;...
  • Page 79 output shaft will maintain certain corresponding degrees if providing the steering gear with certain pulse width. No matter how the external torque changes, it only changes position until a signal with different is provided as shown in Fig.3.2.4.4. The steering gear has an internal reference circuit which can produce reference signal with 20MS period and 1.5MS width, there is a comparator which can detect the magnitude and direction of the external signal and the reference signal, thereby produce the motor rotation signal.
  • Page 80 Figure .3.2.4.5 the Ultrasonic Working Sequence Let us analyze the working sequence, first the trigger signal starts the HC-RS04 distance measurement module, which means the MCU sends an at least 10us high level to trigger the HC-RS04,the signal sent inside of the module is responded automatically by the module, so we do not have to manage it, the output signal is what we need to pay attention to.
  • Page 81 through the reverser to the one electrode on the ultrasonic transducer, the second wave is transmitted to another electrode on ultrasonic transducer, this will enhance the ultrasonic emission intensity. The output end adopts two parallel inverters in order to improve the driving ability. the resistance R1 and R2 on the one hand can improve the drive ability of the 74LS04 outputting high level, on the other hand, it can increase the damping effect of the ultrasonic transducer and shorten the free oscillation time.
  • Page 82 3.2.4.4 Experimental Procedures Connecting the steering gear and ultrasonic module to the Arduino motherboard as shown in Fig.3.2.4.8(you can choose other IO ports according to your own ideas). Figure .3.2.4.8 Wiring of the Steering Gear and Ultrasonic Module 3.2.4.5 Wire connection As shown in the below figure, the servo's "S"...
  • Page 83 Figure 3.2.4.9 Wiring diagram of steering gear, ultrasonic wave and expansion board...
  • Page 84 3.2.4.6 Software design 3.2.4.6.1 Program flow chart 3.2.4.6.2 Program Code Code path:Lesson\Advanced experiment\Beetle_Ultrasound\Beetle_Ultrasound.ino #include "Ultrasonic.h" #define INPUT2_PIN 10 // PWMB #define INPUT1_PIN 6 // DIRB --- right #define INPUT4_PIN 9 // PWMA #define INPUT3_PIN 5 // DIRA --- left #define SERVO_PIN 13 #define ECHO_PIN 3 #define TRIG_PIN 2 #define INFRARED_AVOIDANCE_LEFT_PIN A3...
  • Page 85 #define INFRARED_AVOIDANCE_RIGHT_PIN A4 #define IA_THRESHOLD 40 #define UL_LIMIT_MIN 50 #define UL_LIMIT_MID 40 #define UL_LIMIT_MAX 2000 Ultrasonic Ultrasonic(TRIG_PIN, ECHO_PIN, SERVO_PIN);/*Define ultrasonic and servo pins*/ void setup() Serial.begin(9600); pinMode(INFRARED_AVOIDANCE_LEFT_PIN, INPUT); pinMode(INFRARED_AVOIDANCE_RIGHT_PIN, INPUT); pinMode(INPUT1_PIN, OUTPUT); pinMode(INPUT2_PIN, OUTPUT); pinMode(INPUT3_PIN, OUTPUT); pinMode(INPUT4_PIN, OUTPUT); Ultrasonic.SetServoBaseDegree(90);/*Adjust the initial angle of the steering gear according to the steering gear error*/ Ultrasonic.SetServoDegree(90);/*Set the servo angle*/ void...
  • Page 86 analogWrite(INPUT4_PIN, 200); else if ((RightValue > IA_THRESHOLD) && (LeftValue < IA_THRESHOLD)) /*The data collected by the infrared obstacle avoidance module determines whether there is an obstacle on the right side. If not, turn right.*/ analogWrite(INPUT2_PIN, 0); analogWrite(INPUT1_PIN, 150); analogWrite(INPUT3_PIN, 0); analogWrite(INPUT4_PIN, 0);...
  • Page 87 analogWrite(INPUT1_PIN, 0); analogWrite(INPUT3_PIN, 0); analogWrite(INPUT4_PIN, 0); Ultrasonic.SetServoDegree(0);/*Servo rotation to 0 degrees*/ UlRightDistance Ultrasonic.GetUltrasonicRightDistance();/*The ultrasonic module collects the right side*/ Ultrasonic.SetServoDegree(180);/*Servo rotation to 180 degrees*/ UlLeftDistance Ultrasonic.GetUltrasonicLeftDistance();/*The ultrasonic module collects the left side*/ ((UlRightDistance > UL_LIMIT_MIN) && (UlRightDistance < UL_LIMIT_MAX) && (UlRightDistance >...
  • Page 88: Infrared Remote Control

    3.2.5.1 Suite Introduction Infrared remote control is widely used in every field which is known to everyone, since it can control other electrical appliances, naturally it can control the Beetle-Bot car. Let us take a look at the infrared remote control first:...
  • Page 89 In the Beetle-Bot car, the integrated infrared receiving head has three pins, including the power supply pin, grounding and signal output pin. The circuit is shown in Fig.3.2.5.1. Ceramic capacitors is a decoupling capacitor which can filter the output signal interference.
  • Page 90 Figure .3.2.5.1 Circuit Diagram and Physical Map of Infrared Receiving Head 3.2.5.2 Working Principle The remote control system in general composed of the remote controller (transmitter), and receiver, when you press any button on the remote control, it will generate the corresponding encoding pulse and output various control pulse signals based on the infrared, infrared monitor diode sends the signal to the the amplifier and the pulse amplitude limiter, the limiter controls the pulse amplitude at a certain level, regardless of the distance of infrared transmitter and receiver.
  • Page 91 Figure .3.1.5.3 Infrared Module Connection Diagram 3, Copying the following program to IDE (you can also directly open the matching program in the CD), and downloading to the development board, pulled out the transparent plastic sheet marked as "1" in the Fig.3.2.33.
  • Page 92 Code Path:Lesson\ModuleDemo\IrTest\ IrTest.ino #include "IRremote.h" IRremote ir(12); unsigned char keycode; char str[128]; void setup() { Serial.begin(9600); ir.begin(); void loop() (keycode = ir.getCode()) { String key_name = ir.getKeyMap(keycode); sprintf(str, "Get ir code: 0x%x key name: %s \n", keycode, (char *)key_name.c_str()); Serial.println(str); else Serial.println("no key");...
  • Page 93 The key mapping table is as follows: ST_KEY_MAP irkeymap[KEY_MAX] = { {"1", 0x45}, {"2", 0x46}, {"3", 0x47}, {"4", 0x44}, {"5", 0x40}, {"6", 0x43}, {"7", 0x07}, {"8", 0x15}, {"9", 0x09}, {"0", 0x19}, {"*", 0x16}, {"#", 0x0D}, {"up", 0x18}, {"down", 0x52}, {"ok", 0x1C}, {"left", 0x08}, {"right", 0x5A} 3.2.5.4 Wire connection...
  • Page 94 3.2.5.5 Software Design 3.2.5.5.1 Program flow chart 3.2.5.5.2 Program code Code Path : Lesson\Advanced experiment\ Beetle_IR\ Beetle_IR.ino #include "IRremote.h"/*In this section, we use infrared remote control, so we need to call the corresponding library file, as for what is in the library file, we will not study, and interested friends can drive research.
  • Page 95 byte right = 90; IRremote *mIrRecv; static byte value = 0; void setup() { Serial.begin(9600); pinMode(INPUT1_PIN, OUTPUT); pinMode(INPUT3_PIN, OUTPUT); pinMode(INPUT4_PIN, OUTPUT); pinMode(INPUT2_PIN, OUTPUT); mIrRecv IRremote(RECV_PIN); mIrRecv->begin();// Initialize the infrared receiver void loop() { byte irKeyCode; (irKeyCode = mIrRecv->getCode()) {/* Read the valueue received by the infrared (irKeyCode == advance) { /* Judgment on the received valueue, if this valueue...
  • Page 96 delay(200); (irKeyCode == stop) { /* To judge the valueue received, if this valueue is stop, execute the command in the following {}, here is the stop instruction. */ analogWrite(INPUT4_PIN, 0); analogWrite(INPUT3_PIN, 0);//the speed valueue of motorA is value analogWrite(INPUT2_PIN, 0); analogWrite(INPUT1_PIN, 0);//the speed valueue of motorB is value delay(500);...
  • Page 97: Mobile Phone Bluetooth Control

    3.2.6 Mobile Phone Bluetooth Control 3.2.6.1 Suite Introduction Beetle-Bot supports Bluetooth mobile phone Bluetooth remote control function is JDY-16 BLE (Bluetooth Low Energy).JDY-16 transparent transmission module is based on the Bluetooth 4.2 protocol standard, operating frequency range is 2.4GHZ range, modulation mode is GFSK, maximum transmission power is 0db, maximum transmission distance is 80 meters, adopts original imported chip design, and supports users to modify device by AT command.
  • Page 98 Fig 3.2.6.1 JDY-16 Module 1) JDY-16 function introduction 1:BLE high speed transparent transmission supports 8K Bytes rate communication. 2:Send and receive data without byte limit, support 115200 baud rate continuously send and receive data. 3:Support 3 modes of work (see the description of AT+STARTEN instruction function). 4:Support (serial port, IO, APP) sleep wake up.
  • Page 99 3.2.6.2 JDY-16 Module test “hummer-bot\JDY-16\JDY-16 Module Test.pdf” JDY-16 module test method see 3.2.6.3 Bluetooth protocol Using Bluetooth to control the car means we use the Android app to control the Bluetooth sending instructions to the Arduino serial port, so as to control the motor's forwarding, reversing, speed and so on. Since the wireless communication is involved, one of the essential issues is the communication problem between the two terminals.
  • Page 100 typedef enum E_BATTERY = 1, E_LED = 2, E_BUZZER = 3, E_INFO = 4, E_ROBOT_CONTROL = 5, E_ROBOT_CONTROL_SPEED = 6, E_TEMPERATURE = 7, E_IR_TRACKING = 8, E_ULTRASONIC = 9, E_VERSION = 10, E_UPGRADE = 11, }E_CONTOROL_FUNC The data means the specific control value of a car, such as speed, angle. “Checksum”...
  • Page 101 In the above Figure.3.2.6.2: The "A, B" sections are the acceleration and deceleration buttons. The "C" section includes the dashboard and the digital display area, and the two parts displaying synchronously. They represent the current speed. The "D" section is a gravity remote sensing switch which can be switched to the gravity remote sensing mode.
  • Page 102 Figure .3.2.6.4 Installation of Bluetooth Module 2, Open the mobile phone Bluetooth and the APP (There is a software installation package on the CD, latter we will launch the IOS version.) You will see that the flashing of the Bluetooth module indicator slows down after successful connection.
  • Page 103 Figure .3.2.6.5. Diagram of APP Control In Fig.3.2.6.5, we can see the logo "1" and "2". When the Bluetooth connection is successful, sliding green dot marked as "1" in any direction, the car will move towards the corresponding direction. Switching on the gravity sensor marked in "2", the APP is switched to the gravity induction mode, and you can control the movement direction of the car by shaking the mobile phone.
  • Page 104 3.2.6.6 Software Design 3.2.6.6.1 Program flow char 3.2.6.6.2 Program Code Code path:Lesson\Advanced experiment\Beetle_Bluetooth\Beetle_Bluetooth\Beetle_Bluetooth.ino #include "Beetlebot.h" #include "ProtocolParser.h" #include "KeyMap.h" #include "debug.h" #define INPUT2_PIN 10 // PWMB #define INPUT1_PIN 6 // DIRB --- right #define INPUT4_PIN 9 // PWMA...
  • Page 105 #define INPUT3_PIN 5 // DIRA --- left ProtocolParser *mProtocol ProtocolParser(); Beetlebot beetle(mProtocol, INPUT2_PIN, INPUT1_PIN, INPUT3_PIN, INPUT4_PIN); void setup() Serial.begin(9600); beetle.init(); beetle.SetControlMode(E_BLUETOOTH_CONTROL); void HandleBluetoothRemote() (mProtocol->ParserPackage()) switch(mProtocol->GetRobotControlFun()) case E_INFO: break; case E_ROBOT_CONTROL_DIRECTION: beetle.Drive(mProtocol->GetRobotDegree()); break; case E_ROBOT_CONTROL_SPEED: beetle.SetSpeed(mProtocol->GetRobotSpeed()); break case E_VERSION: break; void loop() mProtocol->RecevData();...
  • Page 106: Ps2 Handle (Optional)

    3.2.7 PS2 Handle (Optional) 3.2.7.1 Suite Introduction PS2 handle is SONY game remote control handle, SONY series game host is very popular in the world. Someone has come up with the idea of the PS2 handle, cracked the communication protocol, so that the handle can be connected to other devices for remote control, such as remote control of our familiar four wheeled vehicles and robots.
  • Page 107 The receiver is powered by the Arduino as shown in Fig.3.2.7.2, in the absence of pairing, the green light flashes. When the handle switch is opened, the handle and receiver will pair automatically, and the light will be always on, and the handle is matched successfully. Button "MODE" (The above logo may be "ANALOG"...
  • Page 108 CS/SEL: Providing trigger signals for handles, the level is low during communication; CLK: The clock signal is sent by the host to maintain data synchronization; NC: Empty port; ACK: The response signal from the handle to the host. This signal changes to low in the last cycle of each 8- bit data sending, and the CS remains low.
  • Page 109 Figure 3.2.7.3 Figure 3.2.7.4 PS2 Receiver Fixed Overall Effect Diagram Connect the wires to the Aruino expansion board as shown in Figure 2.3.58. Upon completion, as shown in Figure 3.2.7.5.
  • Page 110 Figure 3.2.7.5 Connection of Arduino and Receiving Head Wires 4、Open “Lesson\ModuleDemo\PS2XTest\PS2XTest.ino” Finally, download the program to the Arduino development board and turn on the PS2 remote control. If the receiver head is connected to the remote controller (or the pairing is successful), the indicator light on the receiver head is long, and the LED light is blinking.
  • Page 111 3.2.7.3 Software Design #include "PS2X_lib.h" //for v1.6 /****************************************************************** * set pins connected to PS2 controller: - 1e column: original - 2e colmun: Stef? * replace pin numbers by the ones you use ******************************************************************/ #define PS2_DAT #define PS2_CMD #define PS2_SEL #define PS2_CLK /****************************************************************** * select modes of PS2 controller: - pressures = analog reading of push-butttons...
  • Page 112 void setup() { Serial.begin(9600); delay(500); //added delay to give wireless ps2 module some time to startup, before configuring it //CHANGES for v1.6 HERE!!! **************PAY ATTENTION************* //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble);...
  • Page 113 switch(type) { case Serial.println("Unknown Controller type found "); break; case Serial.println("DualShock Controller found "); break; case Serial.println("GuitarHero Controller found "); break; case Serial.println("Wireless Sony DualShock Controller found "); break; void loop() { /* You must Read Gamepad to get new values and set vibration values ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255) if you don't enable the rumble, use ps2x.read_gamepad();...
  • Page 114 if(ps2x.Button(UP_STRUM)) //will be TRUE as long as button is pressed Serial.println("Up Strum"); if(ps2x.Button(DOWN_STRUM)) Serial.println("DOWN Strum"); if(ps2x.Button(PSB_START)) //will be TRUE as long as button is pressed Serial.println("Start is being held"); if(ps2x.Button(PSB_SELECT)) Serial.println("Select is being held"); if(ps2x.Button(ORANGE_FRET)) { // print stick value IF TRUE Serial.print("Wammy Bar Position:");...
  • Page 115 vibrate = ps2x.Analog(PSAB_CROSS); //this will set the large motor vibrate speed based on how hard you press the blue (X) button (ps2x.NewButtonState()) { //will be TRUE if any button changes state (on to off, or off to on) if(ps2x.Button(PSB_L3)) Serial.println("L3 pressed");...
  • Page 116 In the above program, we instructed to read the test button. In this experiment we want to implement the PS2 remote control car function. We firstly define all the button functions as follows: 图3.2.34 PS2手柄功能按键示意图 Mark UP: move forward Mark DOWN: move backward Mark LEFT: turn left Mark RIGHT: right Mark A: speed up...
  • Page 117 The program flow chart is as follows:...

Table of Contents