-
1Step 1
Please write the program to the Raspberry Pi and Arduino first, test it, and then install the circuit board into the robot.
-
2Step 2
The programming of the robot can be divided into two main parts; the Arduino code, and the web server on the Raspberry Pi.
1.Download/clone the folder wall-e from the online repository. (To add a voice recognition module, use our modified wall-e.ino main program, in the walle-replica-3.0 - modified version program folder) Open wall-e.ino in the Arduino IDE;. In addition, the MotorController.hpp and Queue.hpp files will also automatically open on different tabs in the IDE. Install the Adafruit_PWMServoDriver.h library Go to Sketch -> Include Library -> Manage Libraries Search for Adafruit PWM Servo Driver. Install the latest version of the library Connect the computer and the controller with a USB data cable. Make sure to select the correct board and port in the "Tools" menu.
2.Upload the wall-e.ino main program Test Upload the main program to the Arduino. While the Arduino is still connected to the computer, connect a 12V (3S) battery and power it on. Open the serial port detection (the button on the upper right of the Arduino IDE), set the baud rate to 115200. Now test the movement of Wally, send characters "w", "a", "s" or "d", which respectively represent Wally moving forward, left, backward or right. Sending 'q' can stop the movement. Now test the head movement of Wally, send letters "j", "l", "i" or "k" to tilt the head left or right, and raise or lower the eyes. At this stage, the joints controlled by the servo motors may have a wider range than the actual due to the lack of setting for the stroke. This problem will be solved by performing the following servo calibration steps. Servo Calibration Download/clone the "wall-e_calibration" folder from the online repository. Open wall-e_calibration.ino in the Arduino IDE. Upload the program to the Arduino, open the serial monitor, and set the baud rate to 115200. This program is used to calibrate the movement range required to move each servo motor to the corresponding position, the maximum and minimum PWM pulse widths. The standard LOW and HIGH positions of each servo are as follows. Before installing the servo motors, it is necessary to ensure that the angles of the servo motors are correct, and then install the servo arms. Since the servo motors can only rotate 180 degrees, if they are fixed at the wrong angle, they will not be able to control the joints correctly. -
3Step 3
After starting the program, open the serial monitor. After 2-3 seconds, a message should appear indicating that the LOW position of the first servo motor (head rotation) is ready for calibration. Send the characters "a" and "d" to control the robot's movement forward and backward, within the range of -10 to +10. If more precise control is needed, use the characters "z" and "c" to move the robot, within the range of -1 to +1. Once the servo is positioned at the correct position, send the character "n" to continue the calibration steps. It will move to the HIGH position of the same servo, and then the 7 servos in the robot will repeat this process. When all the joints have been calibrated, the program will output an array containing the calibration values to the serial monitor. Copy this array and paste it into lines 144 to 150 of the wall-e - ino program.
-
4Step 4
The resistor (voltage divider) reduces the 12V voltage to below 5V, allowing the Arduino to measure the voltage using its analog pins. The recommended resistor values are R1 = 100kΩ and R2 = 47kΩ. In Arduino, remove line 54 of the main program wall-e.ino. If you use different resistor values, please change the value of the voltage divider gain factor in line 54 of the program according to the formula: POT_DIV = R2 / (R1 + R2). The program should now automatically check the battery level every 10 seconds, and this level will be displayed in the "Status" section of the Raspberry Pi network interface.
Bunn Wu
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.