CN113448571B - MATLAB-based digital signal processor code rapid generation method - Google Patents

MATLAB-based digital signal processor code rapid generation method Download PDF

Info

Publication number
CN113448571B
CN113448571B CN202110791334.5A CN202110791334A CN113448571B CN 113448571 B CN113448571 B CN 113448571B CN 202110791334 A CN202110791334 A CN 202110791334A CN 113448571 B CN113448571 B CN 113448571B
Authority
CN
China
Prior art keywords
code
matlab
matlab software
simulation
system model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110791334.5A
Other languages
Chinese (zh)
Other versions
CN113448571A (en
Inventor
傅平
朱正伟
孙庆昊
肖玉龙
林晋晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shaanxi Weiyang Network Technology Co.,Ltd.
Original Assignee
Minjiang University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Minjiang University filed Critical Minjiang University
Priority to CN202110791334.5A priority Critical patent/CN113448571B/en
Publication of CN113448571A publication Critical patent/CN113448571A/en
Application granted granted Critical
Publication of CN113448571B publication Critical patent/CN113448571B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3608Software analysis for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a digital signal processor code rapid generation method based on MATLAB, which comprises the following steps: step S1, building a system model under a platform based on MATLAB software; s2, carrying out refinement analysis on the built system model through MATLAB software, and carrying out simulation verification in an environment of MATLAB software simulation; s3, converting the defined module part into a real-time code through a simulation platform, and verifying the correctness of the specific algorithm part and whether the corresponding module can generate the code; s4, setting a system model aiming at a specific chip through a code generation tool to generate a corresponding code; s5, connecting an actual controller with a CCS integrated development environment through a simulink simulation platform in MATLAB software; s6, comprehensively evaluating the system model, codes and hardware; s7, finally, performing field test to perfect specific requirements and generate codes; the invention can realize code generation.

Description

MATLAB-based digital signal processor code rapid generation method
Technical Field
The invention relates to the technical field of computer software, in particular to a digital signal processor code rapid generation method based on MATLAB.
Background
With the development of embedded technology and digital signal processing technology, digital signal processing chips are increasingly used in daily life. However, as the complexity of the system increases, the difficulty of developing and debugging DSP programs increases. In the traditional DSP program development process, the simulation, the code and the debugging are disjointed, so that the DSP program development efficiency is greatly reduced.
The traditional DSP source code development generally adopts two methods, namely, directly writing source code by using an assembly instruction, and then generating target executable code after being linked by an assembler and a connector; another approach is to write the source code in the standard C/c++ language. And compiling and linking through a compiler, an assembler and a connector, and finally generating the target code. Both methods require a great deal of time for developers to grasp the correct setting of various registers in the DSP and the programming method of software, and have long development cycle and delay the time to market of products.
Disclosure of Invention
In view of the above, the present invention aims to provide a quick generation method of digital signal processor codes based on MATLAB, which can realize code generation.
The invention is realized by the following steps: a rapid generation method of digital signal processor codes based on MATLAB, the generation method comprising the steps of:
step S1, building a system model under a platform based on MATLAB software;
s2, carrying out refinement analysis on the built system model through MATLAB software, and carrying out simulation verification in an environment of MATLAB software simulation;
s3, converting the defined module part into a real-time code through a simulation platform, and verifying the correctness of the specific algorithm part and whether the corresponding module can generate the code;
s4, setting a system model aiming at a specific chip through a code generation tool, generating a corresponding code, and putting the code into an actual controller;
step S5, in MATLAB softwaresimulinkThe simulation platform connects the actual controller with the CCS integrated development environment so as to verify the correctness of the code running in the DSP chip;
s6, comprehensively evaluating the system model, codes and hardware;
s7, finally, performing field test to perfect specific requirements and generate codes;
the step S1 is further specifically: within MATLAB softwaresimulinkDesigning and simulating a specific module in a simulation platform, generating a prj engineering file through Real Time Workshop provided by MATLA software, and compiling to generate a DSP development board for execution and an out file;
the step S2 is further specifically: in MATLAB softwaresimulinkSelection in a simulation platform module librarySelecting a specific required module, building a model, setting simulation parameters, and finally performing dynamic simulation and building a burn-in DSP development board; the step S3 is further specifically: using real-time MATLAB softwaresimulinkThe simulation platform converts the specific module part into a real-time code and downloads the real-time code into the code generation tool RTW to verify whether the corresponding module can correctly generate the code;
the step S4 is further specifically: setting a corresponding interface of the system model for a specific chip through a code generation tool RTW, generating a corresponding code, and downloading the corresponding code into an actual controller, wherein the code generation tool RTW firstly reads a mdl model file and compiles and generates an intermediate description file of RTW; RTW is generated by a code generation tool RTW, prj and engineering file codes facing the TI compiler, which are codes for generating a CCS integrated development environment in the test; the out file executed by the DSP development board is compiled and linked through the CCS integrated development environment and is automatically downloaded to a memory of the DSP development board for operation.
The invention has the beneficial effects that: the invention is simple and practical, has short development period, low error rate and obviously improved efficiency; the automatic code generation based on the model design can obviously shorten the development period of DSP software and reduce the cost, and the method can automatically generate codes without writing by a large number of staff; particularly in the electronic information industry with strong competition nowadays, the automobile electronic field accelerates the product development process, and the collaborative design of software algorithms and bottom hardware is a trend of future development. In the current competitive Internet of things market, how to accelerate the product development process, and division of software algorithms and bottom hardware design is a great trend in future development, so that the characteristic of slow development period of the current DSP can be exactly solved.
Drawings
FIG. 1 is a flow chart of the method steps of the present invention.
FIG. 2 is a flow chart of a system model design of the present invention.
FIG. 3 is a flow chart for verifying code correctness.
Detailed Description
The invention is further described below with reference to the accompanying drawings.
Referring to fig. 1, the present invention provides an embodiment: a rapid generation method of digital signal processor codes based on MATLAB, the generation method comprising the steps of:
step S1, building a system model under a platform based on MATLAB software;
s2, carrying out refinement analysis on the built system model through MATLAB software, and carrying out simulation verification in an environment of MATLAB software simulation;
s3, converting the defined module part into a real-time code through a simulation platform, and verifying the correctness of the specific algorithm part and whether the corresponding module can generate the code;
s4, setting a system model aiming at a specific chip through a code generation tool, generating a corresponding code, and putting the code into an actual controller;
step S5, in MATLAB softwaresimulinkThe simulation platform connects the actual controller with the CCS integrated development environment so as to verify the correctness of the code running in the DSP chip;
s6, comprehensively evaluating the system model, codes and hardware;
and S7, finally, performing field test to perfect specific requirements and generate codes.
The invention is further illustrated by the following examples:
referring to fig. 2, the whole model-based development is mainly divided into 7 parts:
system definition: the specific requirements of the design are realized, such as direct current motor rotating speed control system design, LED lamp flickering, SPI communication system design and the like, the idea is defined by MATLAB and then model building, so that research and development personnel develop under the same platform, and the model is modified according to the requirements, formats and the like to achieve the purpose.
Simulation design: the model is refined and analyzed, for example, a key shake eliminating module, a frequency control module, a square wave generating module and the like are needed to be built for realizing model control of the motor rotating speed, and then real-time simulation verification is carried out in a software simulation environment, so that feasibility of the model is verified through comparison of simulation waveforms and physical motor rotating waveforms.
Rapid prototyping: the real-time simulink simulation platform is utilized to simulate the operation of specific modules, such as key shake elimination, frequency control and the like, in the second step, and then convert the specific modules into real-time codes to be downloaded into a virtual controller RTW (described below) so as to verify whether the corresponding modules designed in the second step can correctly generate codes.
Automatic code generation: by means of an automatic code generation tool RTW, the model is subjected to corresponding interface settings for a specific chip, such as a TMS320F28335FPGA chip, and then the corresponding code is automatically generated and downloaded into the actual controller ccs.
The hardware is in the loop, and the actual controller is connected with the virtual control object ccs through the real-time simulation platform, so that the correctness of the code running in the DSP chip is verified, and the unexpected error or loss of the actual control object in a laboratory is reduced.
And (3) testing and calibrating, namely comprehensively evaluating the model, the code and the hardware.
And (3) field test: the specific flow and the test verification method are different, if the simulation of the speed control verification of the DC motor is the same as the comparison of the output waveforms of the real objects, whether the speed control function is realized or not is verified, for example, whether the duty ratio is changed or not is verified by calculating the high-level output time of one period through waveforms in the duty ratio experiment of the SPI communication control motor, the research personnel is required to meet specific different requirements, and the specific detail requirements in some designs are perfected.
The innovation is that a digital signal processor is used and combined with a Simulink to build a model control system to perform automatic code generation, so that the process of programming an initialization program by a developer is omitted, the development period of DSP software is obviously shortened, and meanwhile, the cost is reduced.
The technical scheme for solving the technical problems is as follows:
1. a system model (mdl) is built under a MATLAB platform, specific module design and simulation are carried out in a Simulink, then a prj engineering file is generated through Real Time Workshop provided by the MATLAB, executable DSP is compiled and generated, out files are finally downloaded automatically through CCS, and seamless connection between the MATLAB and the CCS can be realized through Embedded Coder Support Package for Texas Instrument C2000 DSP. And then debugging and verifying the correctness of the automatically generated embedded code on the TI-series DSP by utilizing the MATLAB reader and the Simulink model, please refer to FIG. 3.
2. First, MATLAB software needs to be used. The software is a commercial mathematical software, which is mainly used in computer language and interactive environment for algorithm, data analysis and numerical calculation, and is manufactured by MathWorks company in the United states. And MATLAB has the powerful relevant module collection toolbox of development to each different field, has realized that the user uses corresponding toolbox and application directly and no longer need to write the code. At present, MATLAB has been realized, and the MATLAB program is automatically converted into C and C++ codes which are independent of the MATLAB operation, so that a user is allowed to write a C or C++ language program which can interact with the MATLAB, and program files in different environments can be generated according to target configuration.
Simulink is mainly used for simulation and model-based design tools for embedded systems as well as dynamic systems. For signal processing, video image processing, and control systems, simulink provides an interactive graphical environment and a customizable library of modules for designing, simulating, executing, and testing. The specific simulation and analysis sequence is as follows: selecting a specific required module in a module library, building a model, setting simulation parameters, performing dynamic simulation, building a DSP development board, and analyzing and comparing the output result.
Code Composer Studio (CCS for short) is an Integrated Development Environment (IDE), a TI-enabled family of microcontrollers and embedded processor products that contains a suite of tools for developing and debugging embedded applications. The CCS has very powerful functions, integrates various functions such as editing, compiling, linking and debugging of codes, and supports mixed programming of C/C++ and assembly
7RTW (Real-Time workbench) is a Simulink-based code auto-generation environment. The Simulink software generates a high-level representation file containing block diagram execution semantics-model rtw file model rtw file is an ASCII format database, the contents of which describe the functions of the blocks in the Simulink model, including attribute names and attribute values, etc. A Target Language Compiler (TLC) reads a model RTW file and converts the model RTW file into an internal representation, an initial model RTW file is modified according to a TLC file of other modules and the like, optimized, portable and personalized codes can be directly generated from a model of the Simulink under the RTW, programs under various environments are automatically generated according to target configuration, the programs are an expansion mechanism based on a simulation model mechanism of the Simulink algorithm model, the RTW can be regarded as a compiler of a VHLL source program, and the function of automatically generating codes by MATLAB is realized.
Creating a corresponding algorithm model on a platform of Simulink, and executing RTW function to generate standardized and personalized program codes, and modifying system files to generate corresponding executable codes aiming at different target boards.
Specific code automatic generation can be divided into three phases:
the first stage, RTW will read the mdl model file first, and compile and produce the intermediate description file of RTW;
in the second stage, the intermediate description file RTW is generated by RTW, namely prj and engineering file codes facing TI compiler, which are codes for generating CCS integrated development environment in the test;
and thirdly, compiling and linking the executable out file through the CCS and generating the executable out file of the DSP, and automatically downloading the executable out file into a memory of the DSP for operation.
In simulink, a direct current motor system model is built as an example, and a model (.mdl) is shown on the right. Since the direct current motor controls the rotation speed of the motor through PWM pulse width modulation. Specifically, PWM (pulse width modulation) is a method of switching on and off power by a fixed frequency while changing how much time is turned "on" and "off" in one cycle as needed. The purpose of changing the average voltage is realized by changing the duty ratio of the voltage of the direct current motor, thereby realizing the control of the rotating speed of the motor.
And then building a corresponding model file in MATLAB according to the motor driving circuit schematic diagram. The model consists of a key jitter elimination and judgment module, a frequency control module, a different duty ratio control module and a control frequency square wave generation module, wherein the flow chart is shown on the right, and the selection reasons are as follows:
the code is compiled and downloaded to run, the key jitter problem occurs in the process, namely the motor rotation speed changes too fast, and the experimental effect is poor, so that a model for eliminating the jitter and judging whether the key is pressed is required to be established, and the final function is realized on the basis of the combination of the modules.
A second created frequency control module has the main function of controlling the frequency to vary from 0 pi to 2 pi.
Thirdly, when a key is pressed, the 1 adding operation is performed. Thereby realizing the change of the corresponding duty ratio and finally realizing the control of the rotating speed of the direct current motor.
Fourth, the square wave generating module generates a varying square wave under the frequency control module. Finally, the generated C code is verified to be correct by simulating the waveform to obtain a rectangular wave. Then, when the duty ratio is changed from 10% -80% through experimental comparison, the rotation speed of the motor is measured to be from 1.056 to 17.32 revolutions/second, the rotation speed is gradually increased, and the code is shown in the figure.
The main content of the test is model design and code generation based on MATLAB digital signal processor, software designer only needs to establish a Simulink model for control, then by means of a code automatic generation tool, the system automatically generates a C code corresponding to the model, and finally the generated code is downloaded to a target board by using CSS software for debugging and verification. The method can realize the control of the rotating speed of the direct current motor.
In a word, compared with the traditional development flow, the design based on the model greatly reduces the development cost of a developer and shortens the development period. The model-based design mode is equivalent to an executable specification, and a developer modifies and optimizes the model to be equivalent to improvement and improvement of the design, so that verification of the system through testing after project implementation is not required. The correctness of the project can be verified in time in the design period through simulation, and in the implementation period, particularly for embedded software, unnecessary error generation in the requirement and design period is reduced by generating codes by a model.
The foregoing description is only of the preferred embodiments of the invention, and all changes and modifications that come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein.

Claims (1)

1. A digital signal processor code rapid generation method based on MATLAB is characterized in that: the generation method comprises the following steps:
step S1, building a system model under a platform based on MATLAB software;
s2, carrying out refinement analysis on the built system model through MATLAB software, and carrying out simulation verification in an environment of MATLAB software simulation;
s3, converting the defined module part into a real-time code through a simulation platform, and verifying the correctness of the specific algorithm part and whether the corresponding module can generate the code;
s4, setting a system model aiming at a specific chip through a code generation tool, generating a corresponding code, and putting the code into an actual controller;
s5, connecting an actual controller with a CCS integrated development environment through a simulink simulation platform in MATLAB software so as to verify the correctness of the code running in the DSP chip;
s6, comprehensively evaluating the system model, codes and hardware;
s7, finally, performing field test to perfect specific requirements and generate codes;
the step S1 is further specifically: designing and simulating a specific module in a simulink simulation platform in MATLAB software, generating prj engineering files through Real Time Workshop provided by the MATLAB software, and compiling to generate DSP development board for execution;
the step S2 is further specifically: selecting a specific required module from a simulink simulation platform module library of MATLAB software, building a model, setting simulation parameters, and finally performing dynamic simulation and building a burn-in DSP development board;
the step S3 is further specifically: converting a specific module part into a real-time code and downloading the real-time code into a code generation tool RTW by using a simulink simulation platform of real-time MATLAB software to verify whether the corresponding module can correctly generate the code;
the step S4 is further specifically: setting a corresponding interface of the system model for a specific chip through a code generation tool RTW, generating a corresponding code, and downloading the corresponding code into an actual controller, wherein the code generation tool RTW firstly reads a mdl model file and compiles and generates an intermediate description file of RTW; RTW is generated by a code generation tool RTW, prj and engineering file codes facing the TI compiler, which are codes for generating a CCS integrated development environment in the test; the out file executed by the DSP development board is compiled and linked through the CCS integrated development environment and is automatically downloaded to a memory of the DSP development board for operation.
CN202110791334.5A 2021-07-13 2021-07-13 MATLAB-based digital signal processor code rapid generation method Active CN113448571B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110791334.5A CN113448571B (en) 2021-07-13 2021-07-13 MATLAB-based digital signal processor code rapid generation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110791334.5A CN113448571B (en) 2021-07-13 2021-07-13 MATLAB-based digital signal processor code rapid generation method

Publications (2)

Publication Number Publication Date
CN113448571A CN113448571A (en) 2021-09-28
CN113448571B true CN113448571B (en) 2023-05-16

Family

ID=77816095

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110791334.5A Active CN113448571B (en) 2021-07-13 2021-07-13 MATLAB-based digital signal processor code rapid generation method

Country Status (1)

Country Link
CN (1) CN113448571B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116643732B (en) * 2023-07-26 2023-10-24 成都谐盈科技有限公司 Method for generating joint codes of different modeling systems based on software radio communication

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102697520A (en) * 2012-05-08 2012-10-03 天津沃康科技有限公司 Electronic stethoscope based on intelligent distinguishing function
EP2626784A1 (en) * 2012-02-09 2013-08-14 MIMOON GmbH Method and apparatus for automated MATLAB interfacing
CN103699014A (en) * 2013-12-02 2014-04-02 沈阳工业大学 Semi-physical simulation platform and semi-physical simulation control method of electromobile
CN107346249A (en) * 2017-07-13 2017-11-14 重庆电子工程职业学院 A kind of computer software development approach based on model
CN111369874A (en) * 2020-04-08 2020-07-03 安徽理工大学 Line protection experiment platform based on model design

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2626784A1 (en) * 2012-02-09 2013-08-14 MIMOON GmbH Method and apparatus for automated MATLAB interfacing
CN102697520A (en) * 2012-05-08 2012-10-03 天津沃康科技有限公司 Electronic stethoscope based on intelligent distinguishing function
CN103699014A (en) * 2013-12-02 2014-04-02 沈阳工业大学 Semi-physical simulation platform and semi-physical simulation control method of electromobile
CN107346249A (en) * 2017-07-13 2017-11-14 重庆电子工程职业学院 A kind of computer software development approach based on model
CN111369874A (en) * 2020-04-08 2020-07-03 安徽理工大学 Line protection experiment platform based on model design

Also Published As

Publication number Publication date
CN113448571A (en) 2021-09-28

Similar Documents

Publication Publication Date Title
Lu et al. A low-cost real-time hardware-in-the-loop testing approach of power electronics controls
US7865350B1 (en) Partitioning a model in modeling environments
Fritzson Modelica—A cyber-physical modeling language and the OpenModelica environment
US7974823B1 (en) Test postcondition items for automated analysis and test generation
Huber et al. Tool Supported Specification and Simulation of Distributed Systems.
CN1928816A (en) Model drive for embedded system software and component development method
Kirner et al. Fully automatic worst-case execution time analysis for Matlab/Simulink models
CN103092747B (en) A kind of checking controlling program and method of testing and system
KR20110045853A (en) A method and system for testing industrial machine
CN109799971A (en) A kind of file creating apparatus and method
CN113448571B (en) MATLAB-based digital signal processor code rapid generation method
Hanselmann et al. Production quality code generation from Simulink block diagrams
Smolnikar et al. A framework for developing a microchip PIC microcontroller based applications
Erkkinen et al. Automatic code generation-technology adoption lessons learned from commercial vehicle case studies
Raju et al. An end-to-end modeling and prototyping platform for power electronics and electric drives
CN111258573A (en) Automatic code generation method and device for phase-shift PWM algorithm based on model design
CN113315399B (en) Circuit automatic control method and system for automatically generating SPWM (sinusoidal pulse Width modulation) signal based on model design
Graf et al. Gaining insight into executable models during runtime: Architecture and mappings
Frey et al. Internet-based development of logic controllers using Signal Interpreted Petri Nets and IEC 61131
CN113742232B (en) Model-based TC1797 diesel engine control algorithm development tool
CN113238491B (en) Simulation test method and device of execution mechanism, intelligent arm support and engineering vehicle
Archer et al. Specifying and proving properties of timed I/O automata in the TIOA toolkit
Jaikamal et al. Advanced Techniques for Simulating ECU C-code on the PC
US20220057769A1 (en) Programmable microgrid control system
Lanoe et al. A modeling and code generation framework for critical embedded systems design: From Simulink down to VHDL and Ada/C code

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240515

Address after: Room 301, Unit 1, Building 1, Zhongcheng Building, No. 12 Fengcheng 1st Road, Xi'an Economic and Technological Development Zone, Shaanxi Province, 710000

Patentee after: Shaanxi Weiyang Network Technology Co.,Ltd.

Country or region after: China

Address before: 350100 No. 200 Xiyuan Gong Road, Shangjie Town, Minhou County, Fuzhou City, Fujian Province

Patentee before: MINJIANG University

Country or region before: China