Advertisement

Quick Links

Hummer-Bot-1.0
Instruction Manual
V.2.0

Advertisement

Table of Contents
loading

Summary of Contents for Keywish Hummer-Bot-1.0

  • Page 1 Hummer-Bot-1.0 Instruction Manual V.2.0...
  • Page 2 Data Version Description Author 2017/9/16 V-1.0 Create Baron.li 2017/9/23 V-1.1 modify Ken.chen V-1.2 Review Ken.chen 2017/10/18 V-1.3 Review Zach.zhou 2017/11/15 V-1.4 Review Baron.li 2017/12/8 V-1.5 Modifyir/blutooth module Ken.chen 2018/3/11 V-1.6 2018/4/20 Add device instructions Baron.li V-1.7 2018/5/3 Add installation details picture Baron.li 1.
  • Page 3: Table Of Contents

    3.1.2 Wheel and drive module installation ..................16 3.1.3 Tracking module installation ....................19 3.1.4 Lower acrylic plate copper column installation and motor wiring ......... 21 3.1.5 Keywish Uno R3 board installation ..................23 3.1.6 Battery box installation ......................24 3.1.7 Servo installation ........................25 3.1.8 Infrared obstacle avoidance module installation ..............
  • Page 4: Chapter1 Introduction

    Arduino via the serial port emulator. This manual is very suitable for students and electronic enthusiasts to learn, all course videos will be synchronized to https://github.com/keywish/keywish-hummer-bot,please real-time synchronization of the latest information 1.2 Product Introduction "Hummer-Bot"...
  • Page 5 ◆ Two 3000mZh, 3.7V rechargeable lithium battery with longer endurance ◆ Remaining capacity of battery real-time detection ◆ Infrared remote control ◆ Bluetooth app control ◆ PS2 handle control (optional) Product Device List...
  • Page 6: Chapter2 Preparations

    Chapter2 Preparations About Arduino uno r3 In "Hummer-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 7: 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 8 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,we need to connect to the Arduino mainboard,click“My Computer”→“Properties”→“Device Manager”→ “Viewing Ports (COM and LTP)”,If you can see as the Figure 2.1.4 Figure 2.1.4 Driver installation success interface That indicates the driver has been installed successfully.
  • Page 9 Figure 2.1.5 Driver is not successfully installed interface Note: 1)If you connect the controller board to the computer, the computer does not respond. Right-click "My Computer" and select Open Device Manager then find viewing port (com & lpt). If there is no com or lpt, or only an unknown device, there is a problem with the controller board or the USB cable.
  • Page 10 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 11 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 12 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 Note:...
  • Page 13 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, no need to install the driver by yourself, but in Win7 system, you need to manually install driver according to the above steps. 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 14 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 15 Figure 2.1.14 Tools interface Figure 2.1.15 USB serial port selection After the above steps, the Arduino IDE will work. You can 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 16: Chapter3 Experiments

    Chapter3 Experiments 3.1 Assembly of the Car 3.1.1 Motor installation Step1: You need to install the motor mount. Figure 3.1.1 Schematic diagram of motor mounting Note: You need to use the screw to pass through the front hole of the motor, the motor holder corresponds to the opposite position and use the nut to fix the motor holder.
  • Page 17 Figure 3.1.3 Effect diagram of solder the wire Step3: You need to fix the wire with a cable tie. Figure 3.1.4 Effect diagram of fixing the wire...
  • Page 18 Step4: You need to install motors. Figure 3.1.5 Schematic diagram of motor installation...
  • Page 19: Wheel And Drive Module Installation

    Figure 3.1.6 Effect diagram of motor installation 3.1.2 Wheel and drive module installation Step1: You need to install hexagonal coupling. Figure 3.1.7 Schematic diagram of hexagonal coupling installation Figure 3.1.8 Effect diagram of hexagonal coupling installation...
  • Page 20 Step2: You need to install wheel. Figure 3.1.9 Schematic diagram of wheel installation Note: The black top wire position of the hexagonal coupling is tightened against the plane of the motor drive shaft. Figure 3.1.10 Effect diagram of wheel installation...
  • Page 21 Step3:You need to install motor driver module. Figure 3.1.11 Shematic diagram of fixing motor driver board Figure 3.1.12 Shematic diagram of fixing motor driver board...
  • Page 22: Tracking Module Installation

    3.1.3 Tracking module installation Figure 3.1.15 Shematic diagram of copper column of tracking moduble installation Figure 3.1.16 Effect diagram of copper column of tracking moduble installation...
  • Page 23 Figure 3.1.17 Shematic diagram of tracking moduble installation Note: You need to screw the M3 nut to the bottom of the M3*10 screw and install it. Figure 3.1.18 Effect diagram of copper column of tracking moduble installation...
  • Page 24: Lower Acrylic Plate Copper Column Installation And Motor Wiring

    3.1.4 Lower acrylic plate copper column installation and motor wiring Figure 3.1.19 Shematic diagram of motor wiring Note: You need to insert the 4Pin DuPont cable into the motor drive board input. Figure 3.1.20 Effect diagram of motor wiring...
  • Page 25 Figure 3.1.21 Shematic diagram of copper column installstion Figure 3.1.22 Effect diagram of copper column installstion...
  • Page 26: Keywish Uno R3 Board Installation

    3.1.5 Keywish Uno R3 board installation Figure 3.1.23 Shematic diagram of Keywish Uno R3 board installation Figure 3.1.24 Effect diagram of Keywish Uno R3 board installation...
  • Page 27: Battery Box Installation

    3.1.6 Battery box installation Figure 3.1.25 Shematic diagram of battery box installation Figure 3.1.26 Effect diagram of battery box installation...
  • Page 28: Servo Installation

    3.1.7 Servo installation Figure 3.1.27 Shematic diagram of servo installation Figure 3.1.28 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 copy the following program (Lesson\ModuleDemo\Servo\ServoCorrect\ ServoCorrect.ino) into the compilation environment.
  • Page 29 #include <Servo.h> Servo myservo;// create servo object to control a servo = 90; // variable to store the servo position void setup() { myservo.attach(13);// attaches the servo on pin 13 to the servo object void loop() { myservo.write(pos);// tell servo to go to position in variable 'pos' delay(15);// waits 15ms for the servo to reach the position Figure 3.1.29 Schematic diagram of rudder wing and ultrasonic bracket installation Figure 3.1.30 Effect diagram of rudder wing and ultrasonic bracket installation...
  • Page 30: Infrared Obstacle Avoidance Module Installation

    3.1.8 Infrared obstacle avoidance module installation Figure 3.1.31 Shematic diagram of infrared obstacle module installation Figure 3.1.32 Effect diagram of infrared obstacle module installation...
  • Page 31: Voltage Display Module And Dc Head Installation

    3.1.9 Voltage display module and DC head installation Figure 3.1.33 Shematic diagram of voltage display module and DC head installation We need to use two power cables (the same as the wires used by the motor, one red and one black), and connect the two wires to the DC power supply head.
  • Page 32 Figure 3.1.35 Effect diagram of solder DC power supply head Figure 3.1.36 Effect diagram of voltage display module and DC head installation...
  • Page 33: Infrared Remote Control Receiver Installation

    3.1.10 Infrared remote control receiver installation Figure 3.1.37 Shematic diagram of infrared remote control receiver installation Figure 3.1.38 Effect diagram of infrared remote control receiver installation...
  • Page 34: Overall Assembly

    3.1.11 Overall assembly You should screw the battery box , the voltage display module and the DC head wire together (as shown in Figure 3.1.11.2), and connect the positive (red wire) to the +12V negative (black wire) to GND. Figure 3.1.39 Shematic diagram of Overall assembly Note: you need to take the infrared tracking wire and the driver board wire from the upper acrylic plate hole 1, plug the expansion board into the UNO R3 board and wire it.
  • Page 35: Expansion Board Wiring Diagram

    Figure 3.1.40 Effect diagram of Overall assembly 3.1.12 Expansion board wiring diagram Figure 3.1.41 Expansion Board Connection Diagram The full installation of the car is as shown below:...
  • Page 36 Figure 3.1.42 Assembly Connection Diagram So far, the basic assembly of car has been completed. Then you can achieve the corresponding functions only by downloading the program to the development board, each function has a corresponding program in CD. Let's go to the software section!
  • Page 37: Hummer Bot Module Experiment

    3.2 Hummer Bot Module experiment 3.2.1 Walking Principle of the Car In the "Hummer-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 38 ◆ Signal indicator ◆ The speed is adjustable ◆ The strong anti-interference ability with photoelectric isolation ◆ Overvoltage and overcurrent protection ◆ Controlling of two motors separately ◆ Controlling the stepper motor ◆ The speed control with PWM pulse width ◆...
  • Page 39 Figure .3.2.4 Schematic Diagram of Motor Drive Four DC motors with high power L298N drive enable "Hummer-Bot" to run faster than conventional two-wheel car, the acceleration time is shorter and the structure is more stable. In addition, we use PWM to control the speed of the motor(Note: PWM is a way to simulate the simulation output via square waves with different duty cycles.), Arduino PWM port outputs a series of square waves with fixed frequency, the power and current of the motor can be amplified after receiving the signal, thereby changing the motor’s speed.
  • Page 40 In Arduino, analog voltage can’t be output, only 0 or 5V digital voltage value, we can use high resolution counter and the duty cycles of the square wave modulation method to encode a specific level of analog signal. The PWM signal is still digital, because at any given time, the full amplitude of DC power supply is either 5V (ON) or 0V (OFF).
  • Page 41 Figure .2.4.7 Arduino and L298N driver board connection diagram and connection table The L298N and Arduino expansion board wiring is as follows: Figure.3.2.8 L298N and Arduino Expansion Board Connection Diagram After the wiring is completed, we need to do a simple test to check if the motor can run normally. So we need to copy 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 42 right 3s" are normal, the connection is correct, otherwise the polarities of the motor may be reversed, then you need to adjust slightly. Program flow chart is as follows: Figure 3.2.9 Motor Test Flow Chart 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.
  • Page 43 = 5; //PWMA = 9; //PWMA = 6; //PWMB = 10; //PWMB void setup() { void loop() { analogWrite(M1, 0); analogWrite(E1, 150); //the speed value of motorA is 150 analogWrite(M2, 0); analogWrite(E2, 150); //the speed value of motorB is 150 delay(5000);...
  • Page 44: Infrared Obstacle Avoidance

    //********************************************//stop analogWrite(M1, 150);//the speed value of motorA is 150 analogWrite(E1, 0); analogWrite(M2, 150);//the speed value of motorA is 150 analogWrite(E2, 0); delay(5000);//*********************************************//back analogWrite(M1, 0); analogWrite(E1, 0); //the speed value of motorA is 0 analogWrite(M2, 0); analogWrite(E2, 0); //the speed value of motorB is 0 delay(1000);...
  • Page 45 conveniently, it can be widely used in robot obstacle avoidance, car obstacle avoidance and the black&white line tracing and many other occasions. The sensor module possess strong anti-interference ability and wen the distance is moderate, the measurement accuracy is very high. It is widely used in many obstacles such as robot obstacle avoidance, pipeline counting and black and white line tracking.
  • Page 46 Figure .3.2.10 Infrared obstacle avoidance schematic diagram Figure .3.2.11 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 47 Manual adjustment is shown in the following diagram: Adjustable Potentiometer Figure .3.2.12 Diagram of Distance Detection Adjustment 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"...
  • Page 48 3.2.2.5 Experimental Procedures 1. Fixing the two sensors on the car and connecting them to Arduino with wires.(Already done) 2. Testing the sensitivity of module, namely opening the switch on the battery box and the indicator will light, placing obstacles the 10cm away from the infrared tubes, adjusting the potentiometer until the output indicator lights up.
  • Page 49 const int leftPin = A3; const int rightPin = A4; void setup() { Serial.begin(9600); pinMode(leftPin, INPUT); pinMode(rightPin, INPUT); delay(1000); void loop() { = analogRead(leftPin); = analogRead(rightPin); Serial.print("left:"); Serial.print(dl); Serial.print(" "); Serial.print("right:"); Serial.println(dr); Figure .3.2.14 Diagram of Data with Obstacles...
  • Page 50 Figure .3.2.15 Diagram of Data without Obstacles...
  • Page 51 3.2.2.5 Software Design 3.2.2.5.1 Program flow chart 3.2.2.5.2 Program code Next, we combined the above infrared obstacle avoidance module test program and the trolley motor driver program to complete the infrared obstacle avoidance experiment. The program of this experiment: “hummer-bot\Lesson\ModuleDemo\InfraredAvoidance\ InfraredAvoidance.ino”...
  • Page 52 = 5; //PWMA = 9; //DIRA****************************************left = 6; //PWMB = 10; //DIRB****************************************right /*Define 4 motor control terminals, connected to IN1-IN4 on the motor drive board。*/ const int leftPin = A3; const int rightPin = A4; // Define the two signal receiving ends of the sensor float float dr;// Define two margins to store the values read by both sensors...
  • Page 53 Serial.print(dl); Serial.print(" "); Serial.print(dr); Serial.print(" "); Serial.println("Turning left"); /*Through the "Serial Monitor" print the current status of the car and the value collected by the sensor*/ delay(300); analogWrite(M1,0); analogWrite(E1,0); analogWrite(M2,0); analogWrite(E2,0);/*As the car left after about 300ms stop, after measuring, 300ms time car just can rotate about 90 degrees, because the DC motor does not like the steering angle can be precisely controlled, so can only give a rough estimate, of course, different motor speed is not Similarly, the time used is not the same, so everyone in the experiment...
  • Page 54 <= && >= 38) /*If the left sensor is less than or equal to 38 and the right value is greater than or equal to 38, the following program in {} is executed (dl <= 38, indicating that there is an obstacle on the left, dr> = 38 shows that there is no obstacle on the left, so at this moment the car is turning to the side without obstacle, that is, turning to the right)*/ analogWrite(M1,...
  • Page 55: Infrared Tracing

    3.2.3 Infrared Tracing 3.2.3.1 Introduction of Infrared Tracing Sensor After infrared obstacle avoidance, let us learn the infrared tracing, their nature of work is the same, using basically the same module, just in different ways, to achieve different functions. In this section when we study, we have to pay attention to the color of the line we trace (the black line or white line), if your floor is black, you should trace the white line (pasting white line on the floor);...
  • Page 56 As is shown in the schematic diagram 3.2.17 (U1 is 74HC14D comparator), A and C are connected to the light emitting diode, C and E to the receiving diode. In the "Hummer-Bot" car, we use three modules, two in the left and right sides, one in the middle. Its installation is shown in Fig.3.2.18,the tracing sensors are in a straight line.
  • Page 57 3.2.3.3 Module Parameters ◆ Using TCRT5000 infrared reflection sensor ◆ The detection distance: 1mm~25mm, the focal distance is 2.5mm ◆ The comparator output signal waveform is clean, good-shape and it has more than 15mA strong drive ability. ◆ The working voltage: 3.3V-5V ◆...
  • Page 58 Figure .3.2.19 Wire connection diagram 3.2.3.5 Experimental Procedures 1, We need to connect 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 59 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". Demo test code: “hummer-bot\Lesson\ModuleDemo\InfraredTracingTest\InfraredTracingTest.ino”...
  • Page 60 void setup() { Serial.begin(9600); 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.20 Example of the Black Track...
  • Page 61 Fig. 3.2.21 The Data When the Sensor Does Not Detect the Black Line Figure 3.2.22 The Data When the Sensor Detects the Black Line From Fig.3.2.21 and Fig.3.2.22 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 62 3.2.3.5 Software Design 3.2.3.5.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. If the left sensor detects the black line, the car should turn the left;...
  • Page 63 = 5; //PWMA = 9; //DIRA****************************************left = 6; //PWMB = 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() left1, centre, right1; /*Define 3 sensors */ left1 = analogRead(A0);...
  • Page 64 customize the other values, if the use of digital port to receive the value of the sensor returns only "0" and "1", but to determine the same way. The reason why I did not use digital IO, because we use the digital IO port in other places. */ intval = 150;...
  • Page 65: 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 66 Figure .3.2.25 Physical Map of Steering Gear 2. The ultrasonic An ultrasonic sensor is a device that transforms other forms of energies into ultrasonic energy with desired frequency or transforms the ultrasonic energy into other forms of energy with the same frequency. The ultrasonic sensors are commonly classified into two categories, the acoustic type and the hydrodynamic type.
  • Page 67 Figure 3.2.26 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 68 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 69 Figure .3.2.27 Relationship between the Motor Output Angle and Input Pulse 2. The ultrasonic The most commonly used method of ultrasonic distance measurement is echo detection method, the ultrasonic transmitter launches ultrasonic toward a direction and starting the time counter at the same time, the ultrasonic will reflect back immediately when encountering a blocking obstacle and stopping the counter immediately as soon as the reflected ultrasonic is received by the receiver.
  • Page 70 receiving time interval of the ultrasonic, which can be recorded with the time counter, and don't forget to divided it with 2. The ultrasonic is a sound wave which will be influenced by temperature. If the temperature changes little, it can be approximately considered that the ultrasonic velocity is almost unchanged in the transmission process.
  • Page 71 Figure .3.2.30 Schematic Diagram of Ultrasonic Transmitting and Receiving 3.2.4.4 Experimental Procedures 1, Installing the steering gear, ultrasonic module to the car which has been completed in fourth step to the seventh step in 3.1.2) as shown in Fig.3.2.31. 2. Connecting the steering gear and ultrasonic module to the Arduino motherboard as shown in Fig.3.2.32. (you can choose other IO ports according to your own ideas).
  • Page 72 Figure .3.2.31 Installation Diagram of the Steering Gear and Ultrasonic Module Figure .3.2.32 Wiring of the Steering Gear and Ultrasonic Module...
  • Page 73 3.2.4.5 Wire connection As shown in the below figure, the servo's "S" is connected to pin 13, the ultrasonic "Trlg" is connected to pin 2, the "Echo" is connected to pin 3, the "VCC" pin is connected to VCC, and the "GND" pin is connected to GND.
  • Page 74 3.2.4.6.1 Program flow chart 3.2.4.6.2 Program Code Code path “hummer-bot\Lesson\ModuleDemo\UltrasonicAvoidance\UltrasonicAvoidance”...
  • Page 75 #include <Servo.h>/* In this section, we use the steering gear, so we need to call the steering gear library file. As for what is in the library file, we will not study it. Interested friends can drive for research. We have put this library files on the CD-ROM, we need to copy this folder to the Arduino IDE installation path "libraries"...
  • Page 76 right = analogRead(rightPin); analogWrite(TrigPin, 0); // Low high and low send a short pulse to TrigPin) delayMicroseconds(2); analogWrite(TrigPin, 255); delayMicroseconds(10); analogWrite(TrigPin, 0); = pulseIn(EchoPin, HIGH) / 58.0; // Convert the echo time to cm >= && <= 2000 && (left >= 38) &&...
  • Page 77 Serial.println("Turning right"); delay(200); analogWrite(M1, 0); analogWrite(E1, 0); analogWrite(M2, 0); analogWrite(E2, 0); //delay(1000); //********************************************//Turning right ((left >= 38) && (right <= 38) && >= && <= 1000)) { analogWrite(M1, 0); analogWrite(E1, 250); //the speed value of motorA is 180 digitalWrite(M2, HIGH); analogWrite(E2, 0);...
  • Page 78 Serial.print("Left distance = "); Serial.print(dl); Serial.print(" ");/* Ultrasonic acquisition of the left side of the car and obstacles distance, and then assigned to dl, then print on the "Serial Monitor" */ head.write(0);/* Servo steering from the original 180 degrees to 0 degrees, the right side of the car */ delay(1000);...
  • Page 79: Infrared Remote Control

    else if >= 1000) { digitalWrite(M1, 0); analogWrite(E1, 180); //the speed value of motorA is 180 digitalWrite(M2, 180); //the speed value of motorB is 180 analogWrite(E2, 0); Serial.println("Turning left2"); delay(200); // Special case If the return distance on the right is more than 1000, then the probe is blocked and turn left at this moment else if <=...
  • Page 80 Figure .3.2.34 Physical Map of Remote Control Suite Infrared remote control system is mainly divided into modulation, transmitting and receiving parts. The transmitting part is mainly composed of keyboard, remote control specific integrated circuit, exciter and infrared light emitting diode. The integrated circuit is the core part of the launch system which consists internal oscillation circuit, timing circuit, scanning signal generator, key input encoder, instruction decoder, user code converter, digital modulation circuit and buffer amplifier and so on.
  • Page 81 In the Hummer-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.35. Ceramic capacitors is a decoupling capacitor which can filter the output signal interference. The 1 end is the output of the demodulation signal which is directly connected to the number 12 port on the Arduino.
  • Page 82 3.2.5.3 Experimental Procedures 1, Installing the infrared receiving head on the development board (if it has been installed in the the eighth step in "3.1.2", please ignore. The complete installation is shown in Fig.3.1.37. 2, Referring to Fig.3.2.37 and connecting the infrared receiving module to the Arduino board (you can choose other IO ports according to your own ideas) Note: Do not reverse power line, otherwise the receiving head will burn up.
  • Page 83 Test code Path : “hummer-bot\Lesson\ModuleDemo\IrkeyPressed\ IrkeyPressed.ino”...
  • Page 84 #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"); delay(110);...
  • Page 85 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 86 3.2.5.5 Software Design 3.2.5.5.1 Program flow chart 3.2.5.5.2 Program code Code Path : “hummer-bot\Lesson\ModuleDemo\ IRremote\ IRremote.ino”...
  • Page 87 #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. We have put this library files on the CD-ROM, we need to copy this folder to the Arduino IDE installation path "libraries"...
  • Page 88 void loop() { (irrecv.decode ( &results) ) {/* Read the value received by the infrared */ (results.value == advence) {/* Judgment on the received value, if this value is advence, execute the following {} command, here is the forward instruction. */ = 150;...
  • Page 89 = 0; analogWrite (M1, 0); analogWrite(E1, val);//the speed value of motorA is val analogWrite (M2, 0); analogWrite(E2, val);//the speed value of motorB is val delay(500); irrecv.resume(); (results.value == left) {/* Judgment on the received value, if the value is left, execute the command in the following {}, here is the instruction to the left.
  • Page 90 analogWrite(E2, 0);//the speed value of motorB is 0 analogWrite(A2, 180); irrecv.resume(); (results.value == back) {/* Judgment on the received value, if the value is back, execute the command {} below, here for the back instruction. */ = 150; analogWrite (E1, 0); analogWrite(M1, val);//the speed value of motorA is val analogWrite...
  • Page 91: Mobile Phone Bluetooth Control

    3.2.6 Mobile Phone Bluetooth Control 3.2.6.1 Suite Introduction Hummer-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 92 3.2.6.2 Bluetooth 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 93 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 94 Fig.3.2.50 the Interface of Android APP In the above Figure.3.2.50: 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"...
  • Page 95 cathode of the DC power, the RXD port is connected to the TXD port on Arduino extended board, TXD port is connected to RXD port on the board, as shown in Fig.3.2.52. Note: Since Arduino UNO has only one serial port, the Bluetooth must be disconnected from the serial port when downloading the program, otherwise the download will fail.
  • Page 96 Figure .3.2.52 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 97 Figure .3.2.53. Diagram of APP Control In Fig.3.2.53, 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 98 3.2.6.6 Software Design 3.2.6.6.1 Program flow chart 3.2.6.6.2 Program Code Code Path “hummer-bot\Lesson\Advanced Experiment\Buletooth\ Buletooth.ino”...
  • Page 99 #include "protocol.h" #include "hummerbot.h" #include "process.h" = 5; //PWMA = 9; //DIRA --- left = 6; //PWMB = 10; //DIRB --- right byte readbuff[32] = {}; readlen = 0; ST_protocol recv; hummerbot hbot(E1, M1, E2, M2, 13, A0); void setup() { Serial.begin(9600);...
  • Page 100 ( !protocol_prase(readbuff, readlen, &recv)) { switch (recv.function) { case E_BATTERY: break; case E_LED: break; case E_INFO: break; case E_ROBOT_CONTROL: hbot.drive(protocol_prase_degree( &recv)); break; case E_ROBOT_CONTROL_SPEED: hbot.setSpeed(protocol_prase_speed( &recv)); break; case E_VERSION: break;...
  • Page 101: 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 102 "ANALOG" in different handles, but it will not affect the usefulness), you can choose "red light mode" or "green light mode". Some users see that the handle and receiver cannot match properly! Most of the problems are the incorrect wiring of the receiver and the program problems. Solution: The receiver should only be connected with power supply (power line must be connected correctly), not any data lines and clock lines.
  • Page 103 3.2.6.2 Experimental Procedure 1、In order to wire simply, we use the PS2 receiver head adapter board and Arduino connection as follows: As shown in the below figure, the six lines of the receiving head are connected to the following places respectively.
  • Page 104 Fix the receiver head to the cart with a cable tie (red frame area in Figure 3.2.55), as shown in Figure 2.3.56. Figure 3.2.55 Receive Head Fixed Bit Figure 3.2.56 Receiving head fixing diagram...
  • Page 105 3、Lead the wire according to the hole marked “1” in Figure 3.2.57, and connect the wire to the Aruino expansion board with reference to Figure 2.3.58. After the completion, as shown as Figure 2.3.57. Figure 3.2.57 Wire Connection Diagram Figure 3.2.58 Connection of Arduino and Receiving Head Wires 4、Open Lesson\ModuleDemo\PS2X\PS2X.ino on the CD Finally, download the program to the Arduino development board and turn on the PS2 remote control.
  • Page 106 receiver head is long, and the LED light is blinking. Finally, we open the "serial monitor", press any button on the remote control, you can see the corresponding data on the "serial monitor", as shown in Figure 3.2.59. Figure 3.2.59 "serial monitor" data display Test code path “hummer-bot\Lesson\ModuleDemo\PS2X\ PS2X.ino”...
  • Page 107 3.2.6.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 108 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); if(error == 0){ Serial.print("Found Controller, configured successful...
  • Page 109 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 110 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 111 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 112 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: Figure .3.2.60 Functions of PS2 Handle Buttons Mark UP: move forward Mark DOWN: move backward Mark LEFT: turn left...
  • Page 113 The program flow chart is as follows: Code path “hummer-bot-new\hummer-bot\Lesson\Advanced Experiment\PS2XControl\ PS2XControl.ino”...

Table of Contents