0 Introduction
Motion recognition is a hot topic. After launching the sensational multi-touch technology, Apple is preparing to apply for its own motion recognition patent. Motion recognition is simply to use the acceleration sensor to detect the speed change in space and extract the action through the algorithm. Motion recognition has applications in many aspects, such as Wii, mobile phone sensing games, four-propeller aircraft, etc., but it is rarely or even not used in MP3 control. A major trend of today's electronic products is motion control. Imagine an MP3 without any touch or mechanical buttons. As long as you shake it back and forth, you can perform all the most basic control operations. It is both smart and fashionable. This should be a new operating experience. This article will explore how to design such an MP3 that can be normally controlled by motion.
1 Hardware Platform
1.1 SEP4020 Embedded Processor
The driver described in this article is based on the SEP4020 embedded microprocessor. SEP4020 is a processor designed by the National ASIC System Engineering Technology Research Center of Southeast University. It is designed using 0.18 μm standard CMOS process and embedded with ASIX CORE (32-bit RISC core, compatible with ARM720T, with 8kB instruction data cache and full-function MMU). The SEP4020 chip integrates various functions, including:
8/16-bit SRAM/NOR FALSH interface, 16-bit SDRAM interface
Hardware NAND FLASH controller, supports NAND FLASH self-start, supports software/hardware ECC check
10M/100M adaptive Ethernet MAC, supports RMII interface
64k Byte high-speed on-chip SRAM
USBl. 1 Device, full speed 12Mb/s
supports I2S audio interface
Supports MMC/SD card
LCD controller, supports 640×480×16-bit TFT color screen and STN black and white, grayscale screen
RTC, supports calendar function/WatchDog, supports backup power
10-channel TIMER, supports capture, external clock drive and MATCHOUT
4-channel PWM, supports high-speed GPIO
4-channel UART, supports infrared
2-channel SSI, supports SPI and Microwire protocol
2-channel SmartCard interface, compatible with IS07816 protocol
Supports up to 97 GPIO, 14 external interrupts
Supports linked list DMA transfer and external DMA transfer
On-chip DPLL, supports multiple power consumption modes: IDLE, SLOW, NORMAL SLEEP
1.2 MC9S08QG8
The motion capture judgment part in this article is controlled by MC9S08QG8. MC9S08QG8 is a single-chip microcomputer of Freescale Company, and its performance is as follows:
8-channel, 10-bit analog-to-digital converter
3 communication interfaces: SCI, SPI, IIC
4k or 8k reprogrammable FLASH memory
Built-in in-circuit emulator (ICE)
1.3 MMA7620
The motion sensing in the motion-controlled MP3 is done by MMA7620. MMA7620 is a three-axis acceleration sensor from Freescale, and its performance is as follows:
3-axis acceleration sensing and output, can simultaneously measure the values of three coordinate axes (x, y, z) and output them through three channels
4 sensitivity levels to choose from
With sleep mode
2 Design of motion-controlled MP3
2.1 Motion Capture
An action will generate acceleration from the beginning to the end, so the action can be judged by detecting the magnitude and direction of the acceleration generated by the action. To measure the magnitude of acceleration, an acceleration sensor is needed to express the obtained acceleration in the form of analog quantity, and then the analog quantity obtained by the sensor is converted into a digital signal through an AD conversion module to facilitate subsequent calculations. However, after searching for information, it was found that if an AD converter is used unilaterally to convert the voltage signal obtained from the acceleration sensor into a digital signal and the desired accuracy is required, the cost will be greatly increased. However, many existing single-chip microcomputers have integrated AD conversion modules, and the price of the entire single-chip microcomputer is lower than that of a single three-channel AD conversion chip. What is more impressive is that the processing function of the single-chip microcomputer itself can be used to process the digital signal obtained by AD conversion and predict the action. In addition, many communication protocols are integrated in the single-chip microcomputer, which is simple and robust. Considering the above, if a single-chip microcomputer is used instead of an AD conversion module, the burden of the core board and the development difficulty of the entire project can be reduced.
The acceleration sensor can be the MMA7620 three-axis acceleration sensor of Freescale. The single-chip microcomputer can be the MC9S08QG8 single-chip microcomputer of Freescale. Its integrated eight-channel 9-bit AD conversion module matches the three-channel output of MMA7620, and its volume is also very small, which is suitable for portable devices.
Figure 1 is the schematic diagram of the handheld part, including the microcontroller and sensors PTA0, PTA1, PTA2: Input: Connect to the x, y, z port outputs of the three-axis acceleration sensor respectively, and read the analog data of the x, y, z axis of the acceleration sensor.
PTA3: Output; connected to the Sleep pin of the three-axis acceleration sensor to put the sensor into sleep mode to reduce power consumption and lock it to avoid interference during movement.
PTTB0: Input; used as the serial port receiving pin to receive commands from the core board.
PTFBl: Output; used as the serial port sending pin to send the action information measured by the acceleration sensor and processed by the microcontroller to the core board.
PTB6, PTB7: Output; connected to the gselect pin of the accelerometer to control the sensitivity of the accelerometer.
2.2 Action judgment
Using Freescale's FreeMASTER software, you can easily debug the program online and view all global variables of the program. For specific software and usage methods, please check the Freescale website. The following data was obtained using FreeMASTER software, with time and AD conversion value as coordinates.
20 data are sampled in each direction each time. Since the reliability of the first data is relatively large, the first data of each group of data is used as the basis for comparison. After many tests, when the value of the x direction is less than 80, it is a right turn action, when the value of the x direction is greater than 170, it is a left turn action, when the value of the y direction is less than 70, it is an upward lift action, and when the value of the y direction is greater than 160, it is a downward press action. Although the above data can represent the action, the difference between the human action time and the processing and analysis speed of the single-chip microcomputer is still too large. In order to solve this problem and synchronize the single-chip microcomputer with the action, the previous two actions can be recorded, and the current action can be filtered according to the previous two actions: if there are several consecutive identical actions, it is judged as one action, and if they are different, it is switched. The switching of actions must bring about changes in the previous and subsequent actions. Memorizing the previous actions can determine whether there is an action switch. This action recognition method is relatively simple and easy to implement. If more accurate recognition is to be achieved, the algorithm needs to be further optimized. Figure 2 shows the result obtained by the AD converter when shaking right. Figure 3 shows the data of swinging back and forth and left and right.
After the action is identified, the action ID agreed upon by both parties is sent through the serial communication protocol. See Table 1 for details.
Through the serial port protocol, the core board can also perform certain control over the sensor and the microcontroller, including sensor sensitivity adjustment and lock sleep function, making the subsequent test development more convenient.
2.3 MP3 Control
As a platform, Linux operating system has good system customization and portability, which makes it occupy an important position in the embedded field. Linux has many good process communication mechanisms, such as memory sharing, pipes, multithreading, signals, etc. Here, signals are selected as the bridge for control communication. Using the complete serial port driver inside Linux, it is easy to send signals to the specified program, that is, the player program, in the soft interrupt receiving program of the serial port. Then the player program receives and judges the signal type, and assigns the corresponding control value to the corresponding control global variable, making intervention control possible. The control uses the player's own mechanism, which makes it more stable and reliable. Madplay is used as the MP3 player software, and its default control is achieved through the terminal keyboard. In order to control the playback with the signal generated by the action, and at the same time not to modify the Madplay program source code in large quantities, the connection between the player and the keyboard can be cut off and connected to the serial port, so that the action of the entire player can be controlled without modifying the upper-level mechanism.
For details on specific system transplantation and required source code software packages, please visit www.armfans.net
2.4 MP3 playback
MC9S08QG8 and SEP4020 communicate through the serial port.
The basic principle of serial port operation is to save the original parameters of the serial port first, then set the parameters required by the program, and restore the scene after the program ends. The general operation of the serial port is as follows:
Header files required for serial port operations
Set up the serial port soft interrupt, fill in the SIGIO structure, and assign the corresponding interrupt function:
Add an automatic play script to the operating system so that the system can search for MP3 files, create a playlist, start the Madplay player, etc. when it boots up. The script code is as follows:
When an action occurs, MC9S08QG8 sends an action signal to SEP4020, and then the Linux kernel in SEP4020 sends a SIGIO (serial port signal) to each user process. Madplay process captures the signal and reads the message on the serial port to determine the form of the action. Two modules need to be added to the Madplay program. The first module is used to read the message on the serial port. The specific implementation method is to open and read the serial port device file /dev/ttySl to obtain the message, and then according to the setting, 4 serial port signals will be read from the device, corresponding to 4 ASCII characters "L, R, U, D" corresponding to four different actions; the second module is the processing function of the response signal. Once the Linux kernel receives the SIGIO serial port signal, the Madplay process enters the soft interrupt to read the serial port message on /dev/ttySl. As soon as the action is determined, Madplay uses the kill function to send the corresponding signal to this process to control the playback.
3 Conclusion
This article introduces the design process of motion control MP3 under Linux operating system for hardware such as SEP4020 processor, and provides an example for the design of MP3 with this control mode. The following are some suggestions for improvement: As a handheld device, motion control MP3 has high requirements for energy consumption, so when designing, it is necessary to consider using more low-power devices to replace high-power devices. The motion control MP3 is restricted in motion, and the judgment of MP3 will be greatly disturbed. Therefore, if it is difficult to make great improvements in the motion sampling method and motion judgment algorithm, other control methods should be considered to temporarily replace motion control for the convenience of continued use.
Previous article:Design of dimming controller based on single chip microcomputer
Next article:Design and implementation of MCU for multi-point video conferencing control unit
Recommended ReadingLatest update time:2024-11-17 02:55
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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- Overview of air conditioning automatic control system 2
- Realization of Simple Single Chip Microcomputer Calculator
- See how many PA posts have been viewed in the forum
- 【PLC based on IoT】---Testing RPI-400 performance based on AI
- Are old tools better? Or are you just lazy?
- Smart car based on ESP32 road sign recognition
- Regarding the issue of isolated communication:
- New forum feature: Post by uploading a word document (good news for those who like to post a lot of pictures)
- A new version of micro:bit (V2) will be released soon
- What is this error?