1 Introduction
In order to increase the interest of MCU enthusiasts in learning MCU, Lingyang Technology Education Promotion Center launched an intelligent robot using SPCE061A as the main controller and an external motor drive circuit. The robot uses specific human voice recognition to control the robot, and can complete functions such as walking forward, backward, turning left, turning right, dancing two dances, aiming left, aiming right, firing, and continuous firing. On this basis, in conjunction with the ultrasonic ranging module launched by Lingyang Technology Education Promotion Center, the robot has added functions such as real-time detection of obstacles in front during activities, stopping movement when encountering obstacles, and firing frisbees to the front, further enriching the functions of the robot, which can greatly increase the interest of students in school in learning MCU.
2 Introduction to module features
2.1 Introduction to SPCE061A features
SPCE061A is a 16-bit single-chip microcomputer with a high cost performance developed and produced by Lingyang Technology. It can be used to implement a voice recording and playback system very conveniently and flexibly. The chip has 8 10-bit precision ADCs, one of which is an audio conversion channel, and has a built-in automatic gain circuit. This provides convenient hardware conditions for voice recording. Two 10-bit precision DACs only require an external power amplifier (SPY0030A) to complete voice playback. In addition, Lingyang's 16-bit single-chip microcomputer has a set of easy-to-learn and easy-to-use high-efficiency instruction systems and integrated development environments. In this environment, standard C language is supported, and mutual calls between C language and Lingyang assembly language can be realized. In addition, library functions for voice recording and playback are provided. As long as you understand the use of library functions, it will be easy to complete voice recording and playback. These provide convenient conditions for software development:
Features:
16-bit μ'nSP microprocessor;
Working voltage: core working voltage VDD is 3.0~3.6V (CPU), IO port working voltage VDDH is VDD~5.5V (I/O);
CPU clock: 0.32MHz~49.152MHz;
built-in 2K word SRAM;
built-in 32K flash ROM;
programmable audio processing;
crystal oscillator;
when the system is in standby state (clock is in stop state), the power consumption is less than
2μA@3.6V
;
2 16-bit programmable timer/counters (the initial count value can be automatically preset);
2 10-bit DAC (digital-to-analog conversion) output channels;
32-bit general-purpose programmable input/output ports;
14 interrupt sources can come from timer A/ B, time base, 2 external clock source inputs, key wake-up;
with touch key wake-up function;
uses Lingyang audio encoding SACM_S240 mode (2.4K bits/second), can accommodate 210 seconds of voice data;
phase-locked loop PLL oscillator provides system clock signal;
32768Hz real-time clock;
7-channel 10-bit voltage analog-to-digital converter (ADC) and single-channel sound analog-to-digital converter;
sound analog-to-digital converter input channel has built-in microphone amplifier and automatic gain control (AGC) function;
with serial device interface;
low voltage reset (LVR) function and low voltage monitoring (LVD) function;
built-in online emulation board (ICE, In-Circuit Emulator) interface.
2.2 Introduction to Ultrasonic Module
2.2.1 Introduction to Functions
Three distance measurement modes are selected by jumper J1 (short distance, medium distance, and adjustable distance):
Short distance: about 20cm to 100cm (determined by the surface material of the object being measured), with an accuracy of 1cm;
Medium distance: about 70cm to 400cm (determined by the surface material of the object being measured);
Adjustable: The range is determined by the adjustable parameters. When adjusted to the appropriate value, the maximum distance is about 700cm;
2.2.2 Electrical parameters
Ultrasonic sensor resonant frequency: 40KHz
Module sensor operating voltage: 4.5V~9V
Module interface voltage: 4.5V~5.5V
2.2.3 Schematic diagram of ultrasonic transmitting circuit
Figure 2-1 Schematic diagram of ultrasonic resonant frequency conditioning circuit
The 40KHz square wave is generated by the microcontroller and sent to the module's CD4049 through the module interface (J4). The CD4049 at the back conditions the 40KHz frequency signal to make the ultrasonic sensor resonate.
2.2.4 Ultrasonic echo receiving and processing circuit
Figure 2-2 Ultrasonic echo receiving and processing circuit
The front stage of the ultrasonic receiving and processing circuit uses NE5532 to form a 10000 times amplifier to amplify the received signal; the back stage uses LM311 comparator to adjust the received signal. The comparison voltage is the input of pin 3 of LM311. Different comparison voltages can be selected by jumper J1 to select different ranging modes.
2.2.5 Power Interface
Figure 2-3 Power interface circuit of ultrasonic module
It is an external power interface, and the maximum voltage should not exceed 12V. J2 is a power selection jumper. VCC_5 is the power supply introduced into the module by the 61 board through the 10PIN cable; VCC is the power supply for the amplifier and conditioning circuit of the module. When the user uses the 61 board to power it, VCC and VCC_5V should be short-circuited; when using an external power supply, VCC and VCC_IN should be short-circuited.
2.2.6 Ranging Mode Selection Jumper
Figure 2-4 Ultrasonic ranging mode selection jumper circuit
The module provides a distance measurement mode selection jumper J1, which can select short-distance measurement mode, medium-distance measurement mode, or adjustable distance mode. When the jumper is selected LOW, it is close-distance measurement mode, when it is selected HIG, it is medium-distance measurement mode; when it is selected SET, it is adjustable distance mode. The Lingyang University of Technology project provides complete programs for short-distance measurement mode and medium-distance measurement mode (ultrasonic_Low is the short-distance measurement mode program; ultrasonic_long is the medium-distance measurement mode program).
2.2.7 Module Interface
Figure 2-5 Ultrasonic module interface circuit
The user only needs to set the front power input jumper J2 and measurement mode selection jumper J1, and then use the cable to connect J5 to the lower eight bits of the IOB port of SPCE061A, and J4 to the upper eight bits of the IOB port, and then it can be used.
2.2.8 Notes
◆The power supply provided to the module must be above 4.5V, and the power supply voltage should be kept stable as much as possible.
◆The power supply connected to the module external power interface J3 should not exceed 12V. ◆
The performance of the module is closely related to the surface material of the object being measured. For example, wool and cloth have very low reflectivity to ultrasonic waves, which will seriously affect the measurement results.
◆The accuracy of the module's mid-range distance measurement mode is related to program design. The distance measurement results are not calibrated in the provided sample program, so it is normal to have a distance error of 3 to 5 cm.
2.3 Robot Introduction
2.3.1 Robot Drive Circuit Diagram
The robot drive circuit diagram is shown in Figure 2-6:
Figure 2-6 Robot drive circuit diagram
The robot drive circuit uses a high-power transistor to form an H-bridge to drive the motor, which can realize the forward and reverse rotation of the motor. These motors include two motors for walking and a motor for head turning. In addition, a transistor is used to drive a unidirectional rotating motor, including an acceleration motor and a launch motor. The drive circuit is relatively simple.
2.3.2 Main functions
◆Control it through voice commands;
◆Can dance to two dance songs;
◆Walking function, turning function, head turning function;
◆Flying disc launching function;
2.3.3 Actual image of the robot
Figure 2-7 Actual image of the robot
2.3.4 Precautions
◆ The robot should not face people when launching the frisbee to avoid injury
◆ The robot should be handled with care and should not be dropped
◆ Pay attention to the positive and negative poles when installing the battery, otherwise it is easy to burn the robot motor or main control board
3 System Overall Solution Introduction
Use 61 board to control the robot, use IOA7-IOA15 and IOB2 and IOB9 resources, and use speakers. As shown in Figure 3-1:
Figure 3-1 System structure diagram
The system is mainly composed of 61 board, ultrasonic ranging module and robot driving circuit. 61 board is the main control board of the whole system. The ultrasonic ranging module regularly detects whether there are obstacles in front of the robot during the movement. The driving circuit drives the motor and completes each action under the control of the main control board 61 board. In addition, the function of specific person voice recognition is added to control the robot through commands, making the robot intelligent.
4 System software design
In the main function, call related functions to complete the training of a specific person's voice, then perform voice recognition after the training is successful, and perform related operations according to the recognized commands. The program flow is shown in Figure 4-1:
Figure 4-1 Main program flow chart
Determine whether it is the first download based on the flag in FLASH. Use the library function BSR_ExportSDWord(uiCommandID) to export the trained voice model and store it in FLASH for operation, and then call the read and write FLASH function. When performing voice recognition, first read FLASH to obtain the voice model, and then call the BSR_ImportSDWord(uiCommandID) function to load the voice resource into memory. After recognizing the command, execute the relevant actions. The relevant action operation is to operate the forward or reverse rotation of the motor and combine the delay and the playback sound to form different actions.
Obstacle avoidance is achieved during the robot's activities.
Background sounds or music will be played during the robot's activities. Playback is performed in the background, using a 4096Hz time base interrupt to process voice decoding. This can free up a lot of CPU resources to handle other matters in the foreground.
The flow chart of the voice playback function is shown in Figure 4-2.
Figure 4-2 Voice playback program flow chart
The processing flow in the 4096Hz time base interrupt is shown in Figure 4-3.
Figure 4-3 Voice playback interrupt service program flow chart
While playing background music, the program will call the ultrasonic ranging function to detect obstacles in front of the robot. The ranging function uses TimerB to generate a 40KHz PWM square wave to drive the ultrasonic transmitting sensor. When the receiving sensor receives the echo, it will cause an external interrupt of SPCE061A after being processed by the processing circuit. The time from transmitting the ultrasonic wave to generating the interrupt can be calculated to calculate the distance of the target object. The ranging function process is shown in Figure 4-4.
Figure 4-3 Voice playback interrupt service program flow chart
While playing background music, the program will call the ultrasonic ranging function to detect obstacles in front of the robot. The ranging function uses TimerB to generate a 40KHz PWM square wave to drive the ultrasonic transmitting sensor. When the receiving sensor receives the echo, it will cause an external interrupt of SPCE061A after being processed by the processing circuit. The time from transmitting the ultrasonic wave to generating the interrupt can be calculated to calculate the distance of the target object. The ranging function process is shown in Figure 4-4.
Figure 4-5 Compile and link diagram
Step 2: Download the program code to the robot's 61 board.
Step 3: Turn on the robot's power and perform voice training. The training process is as follows:
Train the following 15 instructions in order: "Name", "Start", "Ready", "Dance", "One More Song", "Start", "Go Forward", "Backward", "Turn Right", "Turn Left", "Ready", "Aim Left", "Aim Right", "Fire", "Continuous Fire". Each instruction should be trained twice. When an instruction is correctly recognized, it will prompt to enter the next one; if it is not recognized, it will be required to repeat the instruction until it is correctly recognized.
Step 3: If the training is successful, it will enter the voice recognition state. If the training is not successful, repeat the training. Since the FLASH memory of SPCE061A is only 32K, the 15 instructions need to be stored in groups. Here they are divided into 3 groups, each with 5 instructions. The switching between different groups of commands needs to be based on the trigger name, so in the recognition state, to execute the action, you first need to trigger the name, which is the first command trained, and then you can recognize the remaining four commands in the first group. After triggering the first command, and then triggering the second command, you can recognize the third command, refer to the figure below:
Figure 4-6 Robot operation diagram
Step 4: When the robot is moving forward, backward, or dancing, put your hand or other objects close to the front of the robot. The robot will make a "HoHooHoHoo" sound, stop moving, and then launch a frisbee forward.
The application of SPCE061A plus motor drive control circuit can realize the control of multiple motors and complete many actions of the robot. With ultrasonic sensors and other sensing devices, more functions can be added to the robot. Microcontroller enthusiasts can make their own motor drive circuits, choose a variety of sensors, and use their imagination to make their own robots.
Previous article:Design of signal acquisition node based on single chip microcomputer
Next article:Voltage online monitoring system implemented using SPCE061A single chip microcomputer
Recommended ReadingLatest update time:2024-11-16 23:53
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Have you ever designed a 0-10V dimming power supply that is fully compatible with dimmers?
- TI's IWR6843 smart mmWave sensor antenna-in-package evaluation module
- Structural Design of Virtual I2C Bus Software Package Based on TMS320F206
- eBox question. Has anyone used eBox before? How to set the timer?
- ST NUCLEO-L552ZE-Q Review Summary
- 【Comic】Detailed explanation of power supply circuit
- You are in charge of optimizing the mobile version of EEWorld Forum!
- Does anyone know about the Xtensa core of ESP32?
- Comparison of the internal structures of TI's three major series of DSPs
- This is good, you can try it