CN100370416C - Programmable control device and method thereof - Google Patents
Programmable control device and method thereof Download PDFInfo
- Publication number
- CN100370416C CN100370416C CNB2005100000163A CN200510000016A CN100370416C CN 100370416 C CN100370416 C CN 100370416C CN B2005100000163 A CNB2005100000163 A CN B2005100000163A CN 200510000016 A CN200510000016 A CN 200510000016A CN 100370416 C CN100370416 C CN 100370416C
- Authority
- CN
- China
- Prior art keywords
- control device
- programmable control
- signal
- unit
- functional
- 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.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 44
- 230000009471 action Effects 0.000 claims abstract description 188
- 230000006870 function Effects 0.000 claims abstract description 113
- 230000001960 triggered effect Effects 0.000 claims abstract description 63
- 230000004044 response Effects 0.000 claims abstract description 21
- 230000000875 corresponding effect Effects 0.000 claims description 43
- 238000012545 processing Methods 0.000 claims description 42
- 238000006243 chemical reaction Methods 0.000 claims description 8
- 230000002159 abnormal effect Effects 0.000 claims description 7
- 230000005236 sound signal Effects 0.000 claims description 3
- 238000011017 operating method Methods 0.000 claims 1
- 238000013461 design Methods 0.000 abstract description 12
- 230000000007 visual effect Effects 0.000 abstract 1
- 238000011161 development Methods 0.000 description 45
- 230000007246 mechanism Effects 0.000 description 31
- 230000008569 process Effects 0.000 description 18
- 238000010586 diagram Methods 0.000 description 15
- 239000000047 product Substances 0.000 description 14
- 230000003993 interaction Effects 0.000 description 9
- 230000002093 peripheral effect Effects 0.000 description 5
- 238000007781 pre-processing Methods 0.000 description 5
- 230000007704 transition Effects 0.000 description 4
- 230000008676 import Effects 0.000 description 3
- 239000011159 matrix material Substances 0.000 description 3
- 238000012356 Product development Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000000284 extract Substances 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 230000000977 initiatory effect Effects 0.000 description 2
- 239000010410 layer Substances 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000003825 pressing Methods 0.000 description 2
- 238000004088 simulation Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 230000015572 biosynthetic process Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 239000012467 final product Substances 0.000 description 1
- 239000002346 layers by function Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
- 238000003786 synthesis reaction Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000002054 transplantation Methods 0.000 description 1
- 238000005406 washing Methods 0.000 description 1
Images
Landscapes
- Input From Keyboards Or The Like (AREA)
Abstract
Description
技术领域 technical field
本发明涉及控制装置领域,特别是涉及一种可编程控制装置及其方法。The invention relates to the field of control devices, in particular to a programmable control device and a method thereof.
背景技术 Background technique
随着社会及科技的发展,各类电子产品日益普及,为人们的学习、工作和生活等诸多方面带来了较大的便利。相应地,以微处理器为基础的可编程控制装置(如MCU,微控制器)的应用也日益广泛。例如,在办公室,微控制器被应用到计算机键盘、显示器、打印机、复印机、传真机和电话系统等;在家庭,微控制器被应用到微波炉、洗衣机和烘干机、安全系统、草坪洒水装置控制器以及音乐/视频娱乐设施等。With the development of society and technology, all kinds of electronic products are becoming more and more popular, which brings great convenience to people's study, work and life. Correspondingly, the application of microprocessor-based programmable control devices (such as MCU, microcontroller) is also increasingly widespread. For example, in offices, microcontrollers are used in computer keyboards, monitors, printers, copiers, fax machines, and telephone systems; in homes, microcontrollers are found in microwave ovens, washing machines and dryers, security systems, and lawn sprinklers controllers and music/video entertainment facilities, etc.
对于一般的微控制器来说,必须与其他的外围电路相连才能实现更多的功能。例如:与外围存储器连接以扩展其存储空间,与A/D(模/数)、D/A(数/模)转换器以及LCD(液晶显示器)驱动器相连实现人机会话,甚至采用专用的语音IC(集成电路)来实现语音或音乐播放功能。For a general microcontroller, it must be connected with other peripheral circuits to achieve more functions. For example: connect with peripheral memory to expand its storage space, connect with A/D (analog/digital), D/A (digital/analog) converter and LCD (liquid crystal display) driver to realize man-machine conversation, and even use dedicated voice IC (Integrated Circuit) to realize voice or music playback function.
通常,单片机或嵌入式控制芯片等可编程控制装置通过运行存储在其中的控制程序来实现各种电子产品所具有的功能。Generally, programmable control devices such as single-chip microcomputers or embedded control chips realize the functions of various electronic products by running the control programs stored therein.
目前,现有技术中,控制装置的开发方法主要包括下述阶段:At present, in the prior art, the development method of the control device mainly includes the following stages:
1)了解控制装置硬件结构及其功能;1) Understand the hardware structure and functions of the control device;
2)熟悉掌握控制装置的汇编指令集;2) Familiar with the assembly instruction set of the control device;
3)熟悉包括汇编器、链接器以及捆绑器等工具软件的工具链的使用;3) Familiar with the use of tool chains including assemblers, linkers and bundlers;
4)设计控制装置系统结构,包括硬件结构和软件架构;4) Design the system structure of the control device, including hardware structure and software architecture;
5)实施硬件结构设计,并针对其编写应用程序;5) Implement hardware structure design and write application programs for it;
6)调试验证系统设计。6) Debug and verify system design.
现有技术的该开发方法中,由于开发人员按照复杂的设计规则来编辑结构化的由汇编指令组成的控制程序,并且需要考虑控制装置的硬件响应的实现过程;且开发系统只能根据开发人员输入的汇编指令进行编译和链接,并最终转换为可执行机器代码,因此具有一些不足之处:首先,如果要实现对控制装置的编程控制,则需要了解其硬件功能及其外围连接电路的相关硬件,给开发人员带来较大的不便;其次,开发人员需要熟悉汇编指令集并掌握一定的技巧,其编程过程复杂、不易扩展;总之,为熟悉汇编指令集、了解可编程控制装置的硬件结构和底层细节,开发人员之前需耗费大量的时间用于前期学习,从而增加开发周期,延长产品的上市时间,增加产品开发成本,而且产品质量难以确保;并且最终产品质量如果没有经历长期的市场考验,将有可能存在较多潜在的问题,会影响后续的产品的功能扩充或产品的移植。In the development method of the prior art, since the developer edits the structured control program composed of assembly instructions according to complex design rules, and needs to consider the implementation process of the hardware response of the control device; and the development system can only be based on the developer's The input assembly instructions are compiled and linked, and finally converted into executable machine codes, so there are some disadvantages: First, if you want to realize the programming control of the control device, you need to understand its hardware function and its peripheral connection circuit. Hardware brings great inconvenience to developers; secondly, developers need to be familiar with the assembly instruction set and master certain skills, the programming process is complicated and difficult to expand; in short, in order to be familiar with the assembly instruction set and understand the hardware of programmable control devices Structure and underlying details, developers need to spend a lot of time on early learning, thus increasing the development cycle, prolonging the time to market of products, increasing product development costs, and product quality is difficult to ensure; and if the final product quality has not experienced long-term market There may be more potential problems in the test, which will affect the subsequent product function expansion or product transplantation.
随着IC技术的发展,虽然一些外围功能部件如存储器等已可以集成在控制装置当中,然而该现有技术的开发方法依然难以有效地满足人们对电子产品开发的需求。With the development of IC technology, although some peripheral functional components such as memory can be integrated in the control device, the development method of the prior art is still difficult to effectively meet people's demand for electronic product development.
另一种现有技术可参阅美国专利第5,867,818号,其揭示一种“无指令可编程控制设备及其方法”。该方法虽然简单易行且直观,可以缩短控制设备的编程时间,但是该编程方法受可编程控制设备条件的局限,例如该无指令可编程控制设备需要有专门分别用于存储I/O状态和执行事件的存储器,并由此需要配置各自相应的寻址电路;而且,在I/O状态存储器里,又要分别将用户设定的I/O状态、输入端口触发条件以及输出端口的输出数据一一进行存储;并根据用户设定的输入端口触发条件利用鉴定电路来鉴定输入端口的触发条件是否满足;当此触发条件满足时,又要根据相应的事件寻址电路寻址到事件存储器而执行相应的事件。再有,该可编程控制设备的功能的执行完全依赖于输入端口触发条件的满足。虽然发明人也提到一种比较通用的IC设计,但其仍然依赖于输入端口的触发并只能实现简单的输出功能。显然,围绕发明人披露出的简单易行的编程方法所表述的一些IC设计已经难以适应于复杂、多样化的可编程控制设备的开发,因而,使得用户的应用受到限制。For another prior art, please refer to US Patent No. 5,867,818, which discloses a "commandless programmable control device and method thereof". Although this method is simple, easy, and intuitive, and can shorten the programming time of the control device, the programming method is limited by the conditions of the programmable control device. Execute the memory of the event, and thus need to configure the corresponding addressing circuit; moreover, in the I/O state memory, the I/O state set by the user, the trigger condition of the input port and the output data of the output port must be separately set Store one by one; and use the identification circuit to identify whether the trigger condition of the input port is satisfied according to the trigger condition of the input port set by the user; Execute the corresponding event. Furthermore, the execution of the functions of the programmable control device completely depends on the satisfaction of the trigger conditions of the input ports. Although the inventor also mentioned a relatively general IC design, it still relies on the triggering of the input port and can only realize simple output functions. Apparently, some IC designs based on the simple and easy programming method disclosed by the inventor have been difficult to adapt to the development of complex and diverse programmable control devices, thus limiting the application of users.
发明内容 Contents of the invention
本发明解决的技术问题在于提供一种可编程控制装置及其方法,其实现简单直观、且容易扩展;能够应用于具有各种复杂、多样化功能的IC设计。The technical problem solved by the present invention is to provide a programmable control device and its method, which are simple and intuitive to implement, and easy to expand; and can be applied to IC designs with various complex and diversified functions.
为此,本发明解决技术问题的技术方案是:提供一种可编程控制装置,包括:For this reason, the technical scheme that the present invention solves technical problem is: provide a kind of programmable control device, comprise:
功能单元,具有至少一个功能对象;a functional unit having at least one functional object;
存储单元,用于存储所述功能对象的触发状态设定信息、以及各触发状态下功能对象被触发时可编程控制装置的动作事件;The storage unit is used to store the trigger state setting information of the functional object, and the action events of the programmable control device when the functional object is triggered in each trigger state;
事件响应电路,用于在所述功能对象被触发时,根据功能对象的当前触发状态查找该功能对象关联的动作事件;An event response circuit, configured to search for an action event associated with the functional object according to the current trigger state of the functional object when the functional object is triggered;
执行电路,用于根据事件响应电路的查找结果执行所述动作事件。The execution circuit is configured to execute the action event according to the search result of the event response circuit.
优选地,所述功能对象在接收到预定的外部信号时被触发。Preferably, the functional object is triggered when a predetermined external signal is received.
优选地,所述功能单元是输入电路;所述功能对象是输入管脚,用于接收可编程控制装置外部的输入信号;该输入电路还包括输入信号处理电路,用于根据该输入信号产生触发信号并传送到事件响应电路。Preferably, the functional unit is an input circuit; the functional object is an input pin for receiving an input signal from outside the programmable control device; the input circuit also includes an input signal processing circuit for generating a trigger according to the input signal signal and sent to the event response circuit.
优选地,所述输入信号处理电路是输入管脚读取电路或睡眠/唤醒电路。Preferably, the input signal processing circuit is an input pin reading circuit or a sleep/wake circuit.
优选地,该可编程控制装置还包括模数转换电路,用于将从可编程控制装置外部接收的模拟信号转换为数字信号;所述功能单元是键盘扫描单元,用于从可编程控制装置外部接收按键信号;或所述功能单元是红外信号接收电路,用于从可编程控制装置外部接收红外信号;或所述功能单元是比较器电路,用于从可编程控制装置外部接收比较输入信号。Preferably, the programmable control device also includes an analog-to-digital conversion circuit for converting an analog signal received from outside the programmable control device into a digital signal; the functional unit is a keyboard scanning unit for Receiving button signals; or the functional unit is an infrared signal receiving circuit for receiving infrared signals from outside the programmable control device; or the functional unit is a comparator circuit for receiving comparison input signals from outside the programmable control device.
优选地,所述功能对象将接收到的外部信号传送到事件响应电路,该事件响应电路根据该外部信号判断功能单元是否被触发;或者所述功能对象在接收到预定的外部信号时产生触发信号并传送到事件响应电路。Preferably, the functional object transmits the received external signal to the event response circuit, and the event response circuit judges whether the functional unit is triggered according to the external signal; or the functional object generates a trigger signal when receiving a predetermined external signal and sent to the event response circuit.
优选地,所述功能对象在执行预定功能时被触发。Preferably, the functional object is triggered when a predetermined function is performed.
优选地,所述功能对象是定时器,用于在计时时间到达时产生触发信号。Preferably, the functional object is a timer, which is used to generate a trigger signal when the timing time is reached.
优选地,所述功能单元是音频播放单元,所述功能对象是该音频播放单元播放的音符或声音片断;或者所述功能单元或者是图像显示单元,所述功能对象是该图像显示单元产生的图像扫描驱动信号。Preferably, the functional unit is an audio playback unit, and the functional object is a musical note or a sound clip played by the audio playback unit; or the functional unit or an image display unit, and the functional object is a sound generated by the image display unit Image scanning drive signal.
优选地,所述功能对象在切换到触发状态时被触发。Preferably, the functional object is triggered when switched to a triggered state.
优选地,所述功能单元是信号输出单元,用于在被触发时输出预定的输出信号。Preferably, the functional unit is a signal output unit, configured to output a predetermined output signal when triggered.
优选地,所述信号输出单元包括输出电路、音频播放单元或者图像显示单元。Preferably, the signal output unit includes an output circuit, an audio playback unit or an image display unit.
优选地,所述执行电路执行的动作事件至少包括产生输出信号、切换功能对象的触发状态或者启动另一动作事件。Preferably, the action event executed by the execution circuit at least includes generating an output signal, switching a trigger state of a functional object, or initiating another action event.
优选地,该可编程控制装置还包括复位电路,用于实现所述可编程控制装置的复位操作。Preferably, the programmable control device further includes a reset circuit for realizing the reset operation of the programmable control device.
优选地,所述功能对象在被触发时产生的触发信号是异常事件信号或中断事件信号。Preferably, the trigger signal generated when the functional object is triggered is an abnormal event signal or an interrupt event signal.
本发明还提供一种可编程控制装置的运用方法,该控制装置包括功能单元,所述功能单元具有至少一功能对象;包括步骤:The present invention also provides a method for operating a programmable control device, the control device includes a functional unit, and the functional unit has at least one functional object; including steps:
1)选定所述可编程控制装置的功能对象;1) Selecting the functional object of the programmable control device;
2)配置前述功能对象的触发状态;2) Configure the trigger state of the aforementioned functional object;
3)设置触发状态下前述功能对象被触发时由控制装置执行的动作事件;3) Set the action event executed by the control device when the aforementioned functional object is triggered in the triggered state;
4)定义前述动作事件;并且至少在一动作事件中设定功能对象的当前触发状态。4) Define the aforementioned action events; and set the current trigger state of the functional object in at least one action event.
优选地,在所述步骤3)中还包括设定所述功能对象在接收到预定的外部信号时被触发;或者在执行预定功能时被触发;或者在切换到触发状态时被触发。Preferably, step 3) further includes setting the functional object to be triggered when receiving a predetermined external signal; or to be triggered when a predetermined function is executed; or to be triggered when switching to a trigger state.
优选地,所述动作事件包括产生输出信号、切换功能对象的触发状态或者启动另一动作事件。Preferably, the action event includes generating an output signal, switching a trigger state of a functional object, or initiating another action event.
优选地,所述功能对象包括输入管脚、键盘按键、红外接收命令、比较器、输出管脚和/或定时器。Preferably, the functional objects include input pins, keyboard keys, infrared receiving commands, comparators, output pins and/or timers.
优选地,所述功能单元是音频播放单元或者图像显示单元;所述功能对象是音频播放单元播放的音符或声音片断,或者是图像显示单元产生的图像扫描驱动信号;所述步骤1)中还包括设定与功能对象关联的资源文件。Preferably, the functional unit is an audio playback unit or an image display unit; the functional object is a musical note or a sound clip played by an audio playback unit, or an image scanning drive signal generated by an image display unit; in the step 1) also Contains resource files that set the associated functional objects.
本发明还提供一种可编程控制装置,包括:The present invention also provides a programmable control device, including:
触发信号提供单元,用于接收或产生与控制装置相关的触发信号;A trigger signal providing unit is used to receive or generate a trigger signal related to the control device;
存储器,用于存储控制装置所要执行的代码,其中该代码包括代表动作事件、触发信号与动作事件之间的对应关系的参数;The memory is used to store the code to be executed by the control device, wherein the code includes parameters representing the corresponding relationship between the action event, the trigger signal and the action event;
处理器,用于根据该触发信号查找前述对应关系,并根据查找的结果执行对应的动作事件;A processor, configured to search for the aforementioned corresponding relationship according to the trigger signal, and execute a corresponding action event according to the search result;
信号输出单元,用于输出处理器产生的输出信号。The signal output unit is used for outputting the output signal generated by the processor.
优选地,所述触发信号提供单元包括输入电路、键盘扫描单元、定时器、音乐播放单元、语音播放单元、图像接收单元、比较器或模数转换电路。Preferably, the trigger signal providing unit includes an input circuit, a keyboard scanning unit, a timer, a music playing unit, a voice playing unit, an image receiving unit, a comparator or an analog-to-digital conversion circuit.
优选地,所述信号输出单元包括输出电路、音频信号播放电路或图像显示驱动电路。Preferably, the signal output unit includes an output circuit, an audio signal playing circuit or an image display driving circuit.
优选地,所述触发信号提供单元在接收到预定的外部信号时、或者在执行预定功能时、或者在切换到触发状态时产生触发信号。Preferably, the trigger signal providing unit generates a trigger signal when receiving a predetermined external signal, or when executing a predetermined function, or when switching to a trigger state.
相对于现有技术,本发明的有益效果是:首先,由于本发明的方法针对可编程控制装置的特点,将该控制装置按功能单元划分为各功能对象,并且将复杂、多样化的控制装置的设计和编程过程细化为选定功能对象、配置触发状态、宣告并定义动作事件等阶段,因此,开发人员选定功能对象后,只需从功能描述的角度来配置触发状态,并相应设定触发状态下功能对象被触发时的动作事件即可完成可编程控制装置的功能开发,使得一个复杂、多样化的控制装置的编程设计的实现更为模块化且步骤充分简化。其次,本发明使得开发人员无需了解控制装置的底层的硬件结构,也不需学习熟悉该控制装置的汇编语言并用此对控制装置进行晦涩编程,只需要从实际产品的模块化功能需求出发,对功能对象、触发机制和动作事件等分步进行描述,开发系统即可自动生成汇编语言格式的控制程序,因此容易对可编程控制装置的功能进行扩展,能够应用于各种功能的开发,如输入/输出、红外接收、定时/计数器、音频播放以及图形显示等,并方便产品的升级。再次,实践证明,采用本发明的开发人员只需较短时间(几个小时)就能完成对控制装置的编程过程,由此缩短用户产品的开发周期(通常,现有技术中这一过程需要十几天~几十天),节省人力成本。Compared with the prior art, the beneficial effects of the present invention are: firstly, because the method of the present invention is aimed at the characteristic of programmable control device, this control device is divided into each functional object according to the functional unit, and complex, diversified control device The design and programming process is subdivided into stages such as selecting functional objects, configuring trigger states, announcing and defining action events, etc. Therefore, after a developer selects a functional object, he only needs to configure the trigger state from the perspective of functional description, and set the trigger state accordingly. The function development of the programmable control device can be completed by the action event when the functional object is triggered in a certain trigger state, which makes the programming design of a complex and diverse control device more modular and the steps are fully simplified. Secondly, the present invention makes it unnecessary for developers to understand the underlying hardware structure of the control device, and does not need to learn and be familiar with the assembly language of the control device and use it to program the control device. It only needs to proceed from the modularized functional requirements of the actual product. Functional objects, trigger mechanisms, and action events are described step by step, and the development system can automatically generate control programs in assembly language format, so it is easy to expand the functions of programmable control devices and can be applied to the development of various functions, such as input / output, infrared receiver, timer / counter, audio playback and graphics display, etc., and facilitate product upgrades. Again, practice has proved that the developer who adopts the present invention only needs to complete the programming process to the control device in a short period of time (several hours), thus shortening the development cycle of the user's product (generally, this process in the prior art requires more than ten days to dozens of days), saving labor costs.
附图说明 Description of drawings
图1是可编程控制装置的开发过程的原理示意图;Fig. 1 is a schematic diagram of the principle of the development process of the programmable control device;
图2是本发明可编程控制装置的开发方法的流程图;Fig. 2 is the flowchart of the development method of programmable control device of the present invention;
图3是本发明中接收用户编辑信息的示意图;Fig. 3 is a schematic diagram of receiving user editing information in the present invention;
图4是本发明的可编程控制装置的开发系统的框图;Fig. 4 is the block diagram of the development system of the programmable control device of the present invention;
图5是本发明中编译单元的框图;Fig. 5 is the block diagram of compiling unit among the present invention;
图6是实际的键盘扫描硬件连接示意图;Fig. 6 is a schematic diagram of the actual keyboard scanning hardware connection;
图7是本发明实例一中选定键盘阵列组合的示意图;Fig. 7 is the schematic diagram of the selected keyboard array combination in Example 1 of the present invention;
图8是本发明实例一中用户自定义键盘阵列组合的示意图;8 is a schematic diagram of a user-defined keyboard array combination in Example 1 of the present invention;
图9是本发明中生成控制程序的示意图;Fig. 9 is a schematic diagram of generating a control program in the present invention;
图10是本发明的可编程控制装置的实施方式的框图;Fig. 10 is a block diagram of an embodiment of the programmable control device of the present invention;
图11是本发明的可编程控制装置的实施例的框图。Fig. 11 is a block diagram of an embodiment of the programmable control device of the present invention.
具体实施方式 Detailed ways
请参阅图1,是可编程控制装置的开发过程的原理示意图。Please refer to FIG. 1 , which is a schematic diagram of the development process of the programmable control device.
首先,由数据处理设备910提供集成开发环境(IDE),在数据处理设备910上生成控制程序;再通过汇编、链接等手段生成可执行机器代码;随后,由数据处理设备910将此可执行机器代码通过并口线、串口线等连接线920加载到调试装置930上,并启动该可执行机器代码进行运行并调试。可执行机器代码运行中调试装置930通过并口线、串口线等连接线920与数据处理设备910交换信息。First, an integrated development environment (IDE) is provided by the data processing device 910, and a control program is generated on the data processing device 910; then executable machine code is generated by means of assembly, linking, etc.; then, the executable machine code is generated by the data processing device 910 The code is loaded onto the debugging device 930 through connecting lines 920 such as a parallel port line and a serial port line, and the executable machine code is started to run and debug. Executable machine code debugging device 930 exchanges information with data processing equipment 910 through connection lines 920 such as parallel port lines and serial port lines.
当调试成功后,即可将该可执行机器代码下载(例如,采用烧录等手段)到可编程控制装置中,完成可编程控制装置的开发。After the debugging is successful, the executable machine code can be downloaded (for example, by means of burning) into the programmable control device to complete the development of the programmable control device.
其中,本发明所述数据处理设备910包括但不限于计算机、笔记本电脑等各类具有数据处理能力的电子设备;所述调试装置930包括但不限于单片机、控制装置仿真板、在线仿真器等具有实时仿真接口,供软件运行的硬件平台。Wherein, the data processing equipment 910 of the present invention includes but not limited to computers, notebook computers and other electronic equipment with data processing capabilities; the debugging device 930 includes but not limited to single-chip microcomputers, control device simulation boards, online emulators, etc. Real-time simulation interface, the hardware platform on which the software runs.
请参阅图2,是本发明可编程控制装置的开发方法的流程图。Please refer to FIG. 2 , which is a flow chart of the development method of the programmable control device of the present invention.
步骤S100,数据处理设备910提供用户界面,供用户创建新的控制程序并引导用户进行编辑,接收来自用户的输入信息。In step S100, the data processing device 910 provides a user interface for the user to create a new control program and guide the user to edit it, and receives input information from the user.
请一并参阅图3,是所述步骤S100中用户进行编辑的具体过程示意图。Please also refer to FIG. 3 , which is a schematic diagram of the specific process of editing by the user in step S100 .
步骤S110,设定该可编程控制装置硬件的基本参数。Step S110, setting basic parameters of the hardware of the programmable control device.
所述基本参数包括可编程控制装置的基本型号、所应用的系统时钟等,用于提供可编程控制装置进行运行操作的信息。The basic parameters include the basic model of the programmable control device, the applied system clock, etc., and are used to provide information on the operation of the programmable control device.
步骤S120,选定该可编程控制装置的功能对象。Step S120, selecting the function object of the programmable control device.
所述功能对象与可编程控制装置的功能单元紧密关联,包括但不限于可编程控制装置的输入电路的输入端口、输出电路的输出端口、键盘扫描电路的按键、红外信号接收命令、定时器/计数器等。所述功能对象在被触发并满足触发条件时,可编程控制装置将完成相应的动作功能。The functional object is closely related to the functional unit of the programmable control device, including but not limited to the input port of the input circuit of the programmable control device, the output port of the output circuit, the key of the keyboard scanning circuit, the infrared signal receiving command, the timer/ Counter etc. When the functional object is triggered and the triggering condition is met, the programmable control device will complete the corresponding action function.
步骤S130,配置前述功能对象的触发状态、以及在特定的触发状态下功能对象被触发时控制装置执行的动作事件。Step S130, configuring the trigger state of the aforementioned functional object and the action event executed by the control device when the functional object is triggered in a specific trigger state.
通常,功能对象可以在接收到预定的外部信号时被触发,如:当功能对象为输入端口时,可以设定当输入端口为高电平时,当前状态下该输入端口被触发。也可以由功能对象自身的运行来触发功能对象,如:当功能对象为定时/计数器时,假如该定时/计数器为TM0,可以设定当TM0溢出时,当前状态下该定时/计数器被触发。还可以是当切换到该功能对象的触发状态时,控制装置则执行设定的动作事件,如:当功能对象是输出端口时,在触发状态下将输出预定的信号。Usually, a functional object can be triggered when a predetermined external signal is received. For example, when the functional object is an input port, it can be set that when the input port is at a high level, the input port is triggered in the current state. The functional object can also be triggered by the operation of the functional object itself, such as: when the functional object is a timer/counter, if the timer/counter is TM0, it can be set that when TM0 overflows, the timer/counter is triggered in the current state. It is also possible that when switching to the trigger state of the functional object, the control device executes the set action event, such as: when the functional object is an output port, a predetermined signal will be output in the trigger state.
对于根据外部信号来触发的功能对象来说,所述功能对象对应的电路或者对应的功能单元可以将接收到的外部信号传送到事件响应电路,该事件响应电路根据该外部信号判断功能单元是否被触发;所述功能对象也可以在其相应的功能单元接收到预定的外部信号时产生触发信号并传送到事件响应电路。For a functional object triggered according to an external signal, the circuit corresponding to the functional object or the corresponding functional unit may transmit the received external signal to the event response circuit, and the event response circuit judges whether the functional unit is activated according to the external signal Trigger: The functional object can also generate a trigger signal when its corresponding functional unit receives a predetermined external signal and transmit it to the event response circuit.
当然,对于相同的功能对象,可以配置多个不同的触发状态。在不同的触发状态下,可以设定在功能对象被触发时不同的动作事件。Of course, for the same functional object, multiple different trigger states can be configured. In different trigger states, different action events can be set when the functional object is triggered.
当然,还可以在功能对象的某些触发状态下不设置动作事件,则在该触发状态下,该功能对象被触发时控制装置将不执行任何操作。Of course, it is also possible not to set an action event in some triggering states of the functional object, then in this triggering state, the control device will not perform any operation when the functional object is triggered.
步骤S140,定义所述动作事件;其中,所述的动作事件中至少一个包括对当前触发状态的切入。Step S140, defining the action events; wherein at least one of the action events includes switching to the current trigger state.
所述动作事件用于描述可编程控制装置执行的动作。动作事件在设定后,可以同时被不同的功能对象的不同触发状态所选用。The action event is used to describe the action performed by the programmable control device. After the action event is set, it can be selected by different trigger states of different functional objects at the same time.
通常,所述动作事件可以通过用户自定义的动作函数来设定,在执行所述函数时,控制装置可能产生特定的输出信号、或者切换功能对象的触发状态或者启动另一动作事件。Usually, the action event can be set by a user-defined action function. When the function is executed, the control device may generate a specific output signal, or switch the trigger state of the functional object or start another action event.
所述动作事件还可以是用户指定的动作常量,动作常量一般用于在功能对象为输出端口时指明该输出端口的输出动作,包括但不限于逻辑高电平信号、或逻辑低电平信号、或单正脉冲信号、或单负脉冲信号、或正脉冲串信号以及负脉冲串信号。The action event can also be an action constant specified by the user. The action constant is generally used to indicate the output action of the output port when the functional object is an output port, including but not limited to a logic high level signal, or a logic low level signal, Or a single positive pulse signal, or a single negative pulse signal, or a positive pulse train signal and a negative pulse train signal.
步骤S200,数据处理设备910对用户的输入信息进行编译、自动生成汇编语言格式的控制程序。In step S200, the data processing device 910 compiles the user input information and automatically generates a control program in assembly language format.
首先,将功能对象的选定信息和触发机制(触发状态、触发条件)的配置转换为编译参数;其次,将动作事件的设定信息转换为编译参数,并且结合所有的编译参数生成汇编语言形式的控制程序。First, convert the selection information of the functional object and the configuration of the trigger mechanism (trigger state, trigger condition) into compilation parameters; secondly, convert the setting information of the action event into compilation parameters, and combine all compilation parameters to generate an assembly language form control program.
此外,在处理功能对象和触发机制时,还会调取与该功能对象有关的程序模块,将其有机结合到控制程序中,用以自动实现对硬件底层的操作,从而对用户来说,可以在功能层描述软硬件触发环境,而不需要关心控制装置底层硬件的实现细节,方便用户的后续功能扩充。In addition, when dealing with the functional object and the trigger mechanism, the program module related to the functional object will also be called, and it will be organically combined into the control program to automatically realize the operation of the bottom layer of the hardware, so that for the user, it can be Describe the software and hardware triggering environment at the functional layer without caring about the implementation details of the underlying hardware of the control device, which is convenient for users to expand subsequent functions.
本发明中,所述程序模块可以是采用汇编语言设计的功能模块,用于实现对控制装置底层硬件的操作,例如,对键盘阵列的扫描等,从而支持对用户输入的信息进行编译的过程。In the present invention, the program module may be a functional module designed in assembly language, used to realize the operation of the underlying hardware of the control device, for example, scan the keyboard array, etc., thereby supporting the process of compiling the information input by the user.
步骤S300,对所述控制程序进行汇编、链接,生成可执行机器代码。Step S300, assemble and link the control program to generate executable machine code.
此外,为进一步扩展可编程控制装置的功能,所述步骤S120中选定的功能对象还可以是Music(音乐)播放模块的EventNote(音符)和Speech(语音)播放模块的EventSect(语音段)。相应地,所述步骤S100中,还需要设置应用资源:即可编程控制装置在运行时使用的各种资源文件及其相关参数。在步骤S300之后还包括绑定可执行机器代码与资源文件的步骤S400。In addition, in order to further expand the function of the programmable control device, the functional object selected in the step S120 can also be the EventNote (note) of the Music (music) playback module and the EventSect (speech segment) of the Speech (voice) playback module. Correspondingly, in the step S100, it is also necessary to set application resources: that is, various resource files and related parameters used by the programmable control device during operation. After the step S300, a step S400 of binding the executable machine code and the resource file is also included.
步骤S500,在生成可执行机器代码后,即可进行调试运行;如果调试通过,则可加载(例如采用烧录方式)至可编程控制装置,完成所需功能的开发,此不赘述。In step S500, after the executable machine code is generated, it can be debugged and run; if the debug is passed, it can be loaded (for example, by burning) to the programmable control device to complete the development of required functions, which will not be described in detail here.
请参阅图4,是本发明的可编程控制装置的开发系统的框图。Please refer to FIG. 4 , which is a block diagram of the development system of the programmable control device of the present invention.
所述开发系统提供集成开发环境(IDE),包括用户交互单元110、编译单元(QPL Complier)120、功能模组(QPL Module)130、汇编单元(QPL Assembler)140、链接单元(QPL Linker)150。The development system provides an integrated development environment (IDE), including a
所述用户交互单元110用于接收用户的输入信息。所述用户的输入信息包括功能对象的选定信息、触发机制的配置信息、动作事件的设定信息。The
请一并参阅图5,所述编译单元120用于解析用户的输入信息,自动生成控制程序。其包括功能对象及触发机制处理单元(QPDEC)121、动作事件处理单元(QPDEF)122。Please also refer to FIG. 5 , the compiling
所述功能对象及触发机制处理单元121用于将功能对象的选定信息和触发机制的配置转换为编译参数并传送到动作事件处理单元122;所述动作事件处理单元122用于将动作事件的设定信息转换为编译参数,并且结合所有的编译参数生成汇编语言形式的控制程序。The function object and trigger mechanism processing unit 121 is used to convert the selected information of the function object and the configuration of the trigger mechanism into compilation parameters and transmit them to the action event processing unit 122; the action event processing unit 122 is used to convert the The setting information is converted into compile parameters, and all compile parameters are combined to generate a control program in assembly language.
所述功能模组130用于为编译单元120提供功能对象操作程序以支持编译单元120的编译过程。具体地说,当编译单元120扫描到功能对象的选定信息中包含的某一功能对象时,则从功能模组130中提取该功能对象的操作程序(例如,当扫描到设置有键盘的按键时,便会从中取出键盘扫描程序),并将其一一有机结合到控制程序中。The
需要说明的是,所述动作事件处理单元122的功能也可以由两个分立的部分来实现,即动作事件预处理部分(QPDCC)和编译部分(QPDEF);所述动作事件预处理部分对动作事件的设定信息进行预处理后传递给编译部分;所述编译部分同时接收该预处理后的参数和功能对象及触发机制处理单元121传递的编译参数,并生成控制程序。It should be noted that the function of the action event processing unit 122 can also be realized by two separate parts, that is, the action event preprocessing part (QPDCC) and the compiling part (QPDEF); The setting information of the event is preprocessed and passed to the compiling part; the compiling part receives the preprocessed parameters and the compiling parameters transmitted by the function object and the trigger mechanism processing unit 121 at the same time, and generates a control program.
此外,所述编译单元120还可以具有驱动单元(QPC),从用户交互单元110接收输入的信息,并分别驱动功能对象及触发机制处理单元121、动作事件处理单元122。In addition, the
其中,该驱动单元的驱动步骤如下:传输用户交互单元接收的功能对象及触发机制信息的参数给对象及触发机制处理单元和动作事件处理单元,并接收所述对象及触发机制处理单元反馈的第一编译参数并传递给动作事件处理单元;传输动作事件设定信息给动作事件处理单元,动作事件处理单元生成第二编译参数;动作事件处理单元结合驱动单元所传递的第一编译参数和第二编译参数,生成控制程序。Wherein, the driving steps of the driving unit are as follows: transmit the parameters of the function object and trigger mechanism information received by the user interaction unit to the object and trigger mechanism processing unit and the action event processing unit, and receive the first feedback from the object and trigger mechanism processing unit A compilation parameter is passed to the action event processing unit; the action event setting information is transmitted to the action event processing unit, and the action event processing unit generates the second compilation parameter; the action event processing unit combines the first compilation parameter passed by the drive unit and the second Compile the parameters and generate the control program.
该驱动单元的驱动步骤还可以是:传输用户交互单元接收的功能对象及触发机制信息的参数给对象及触发机制处理单元和动作事件处理单元,并接收所述对象及触发机制处理单元反馈的第一编译参数,传递给动作事件处理单元;传输动作事件设定信息给动作事件处理单元中的预处理部分,并接收所述预处理部分反馈的第二编译参数,传递给动作事件处理单元的编译部分;动作事件处理单元的编译部分结合驱动单元所传递的第一编译参数和第二编译参数,生成控制程序。The driving step of the driving unit may also be: transmitting the parameters of the function object and trigger mechanism information received by the user interaction unit to the object and trigger mechanism processing unit and the action event processing unit, and receiving the first feedback from the object and trigger mechanism processing unit A compilation parameter, which is passed to the action event processing unit; transmits the action event setting information to the preprocessing part in the action event processing unit, and receives the second compilation parameter fed back by the preprocessing part, and passes it to the compilation of the action event processing unit part; the compiling part of the action event processing unit combines the first compiling parameter and the second compiling parameter passed by the drive unit to generate a control program.
所述汇编单元140用于将编译单元120产生的汇编程序转换成目标代码。The
所述链接单元150用于将前述目标代码与相关的库文件进行链接,生成可执行机器代码。The linking
此外,如前所述,为进一步扩展可编程控制装置的功能,用户选定的功能对象还可以是Music(音乐)播放模块的EventNote(音符)和Speech(语音)播放模块的EventSect(语音段)时。相应地,用户需要通过用户交互单元110设置应用资源:即可编程控制装置在运行时使用的资源文件及其相关参数。所述编译单元120还具有资源文件处理单元,用于将用户输入的资源文件设置信息整合至汇编语言的控制程序中,该资源文件处理单元可以与功能对象及触发机制处理单元结合在一起。并且,本发明还包括捆绑单元(QPL Binder)160,用于将链接单元150产生的可执行机器代码与相关的资源文件进行捆绑,生成最终的可执行机器代码。In addition, as previously mentioned, in order to further expand the function of the programmable control device, the functional object selected by the user can also be the EventNote (note) of the Music (music) playback module and the EventSect (voice segment) of the Speech (voice) playback module hour. Correspondingly, the user needs to set application resources through the user interaction unit 110 : that is, resource files and related parameters used by the programmable control device during operation. The compiling
为验证可控制编程装置的系统设计,确保产品的质量,本发明的开发系统还包括调试单元(QPL Debugger)170,用于对最终的可执行机器代码进行调试,此不赘述。In order to verify the system design of the controllable programming device and ensure the quality of the product, the development system of the present invention also includes a debugging unit (QPL Debugger) 170 for debugging the final executable machine code, which will not be described in detail.
为便于对本发明开发系统和方法的理解,下面结合实施例对本发明做进一步的详细描述。In order to facilitate the understanding of the development system and method of the present invention, the present invention will be further described in detail below in conjunction with embodiments.
首先,用户在集成开发环境建立新的用户工程,开发系统的用户交互单元自动生成两个源文件:资源引入源文件(Resource)和控制工程程序源文件(File)。所述资源引入源文件用于实现资源文件的描述,引入用户需要使用的资源文件;所述控制程序源文件用于设置软硬件环境和触发机制,描述动作事件。First, the user creates a new user project in the integrated development environment, and the user interaction unit of the development system automatically generates two source files: resource import source file (Resource) and control engineering program source file (File). The resource import source file is used to realize the description of the resource file, and import the resource file that the user needs to use; the control program source file is used to set the software and hardware environment and trigger mechanism, and describe the action event.
其中,本实施例对控制程序源文件进行更细致的划分,拆分为软硬件环境和触发机制配置源文件(Declaration)和动作事件定义源文件(Definition)。Among them, the present embodiment divides the source files of the control program into more fine-grained divisions into software and hardware environment and trigger mechanism configuration source files (Declaration) and action event definition source files (Definition).
随后,用户交互单元接收用户对源文件的编辑,引导用户完成对可编程控制装置的编程。Subsequently, the user interaction unit receives the editing of the source file by the user, and guides the user to complete the programming of the programmable control device.
在编程过程中,本实施例提供QPL(Quick Program Language)模块化编程语言,使得开发过程变得简单、快速且直观。QPL语言是一种方便灵活的模块化描述应用程序的软硬件环境及动作事件的高级语言。其包括三个语法单元:一是资源文件描述部分;二是软硬件环境及触发机制配置的描述部分,用于描述控制装置的外围触发,免去用户处理底层硬件细节的烦恼;三是动作事件定义的描述部分,用于描述当某一功能对象被触发时控制装置对应执行的动作。In the programming process, this embodiment provides a QPL (Quick Program Language) modular programming language, which makes the development process simple, fast and intuitive. The QPL language is a convenient and flexible modular high-level language that describes the software and hardware environment and action events of the application program. It includes three grammatical units: one is the resource file description part; the other is the description part of the software and hardware environment and trigger mechanism configuration, which is used to describe the peripheral triggering of the control device, eliminating the trouble for users to deal with the details of the underlying hardware; the third is the action event The description part of the definition is used to describe the corresponding actions performed by the control device when a certain functional object is triggered.
实例一$Keyscan(键盘简易编程方法)Example 1 $Keyscan (keyboard simple programming method)
请参阅图6,是实际的键盘硬件连接示意图。Please refer to Figure 6, which is a schematic diagram of the actual keyboard hardware connection.
在选定功能对象时,IDE(集成开发环境)提供键盘扫描配置列表,使得用户通过该列表可以方便地选择各种满足需要的键盘阵列;如果用户不满足于系统提供的缺省键盘定义,那么用户还可以通过IDE进行自主配置。When selecting a functional object, the IDE (Integrated Development Environment) provides a keyboard scanning configuration list, so that the user can easily select various keyboard arrays that meet the needs through the list; if the user is not satisfied with the default keyboard definition provided by the system, then Users can also perform self-configuration through the IDE.
请参阅图7,开发系统为用户定义多个方便的键盘阵列组合,支持行列式和直连式,用户只要指定要使用EasyN即可。Please refer to Figure 7, the development system defines multiple convenient keyboard array combinations for users, supports determinant and direct connection, and users only need to specify to use EasyN.
请参阅图8,也可以进行用户自定义,只需指定哪些I/O作为Scan Line(扫描线),哪些I/O作为Sense Line(输入线)即可。开发系统会自动为用户作IO的初始化、键盘的扫描,使得用户无需关心硬件底层的细节。IDE会在Declaration文件中自动生成KeyScan段,并在该段下生成键盘矩阵EASY8各功能对象TG1至TG8:Please refer to Figure 8, user-defined can also be performed, just specify which I/O as Scan Line (scanning line) and which I/O as Sense Line (input line). The development system will automatically initialize the IO and scan the keyboard for the user, so that the user does not need to care about the details of the underlying hardware. The IDE will automatically generate the KeyScan section in the Declaration file, and generate the keyboard matrix EASY8 functional objects TG1 to TG8 under this section:
$KeyScan:$KeyScan:
EASY8EASY8
TG1 TG2 TG3 TG4&TG1 TG2 TG3 TG4&
TG5 TG6 TG7 TG8TG5 TG6 TG7 TG8
并且,键盘支持设置键盘扫描的输入线(Sense Line)的上拉电阻和下拉电阻。键盘也支持键盘扫描输出线(Scan Line)输出高、低电平的设置,SenseLine、Scan Line的设置根据用户键盘矩阵电路的实际情况确定。In addition, the keyboard supports setting the pull-up resistor and pull-down resistor of the keyboard scan input line (Sense Line). The keyboard also supports the setting of high and low output levels of the keyboard scanning output line (Scan Line). The settings of SenseLine and Scan Line are determined according to the actual situation of the user's keyboard matrix circuit.
开发系统还会自动避免错误,由于Sense Line、Scan Line与芯片I/O接口硬件相关,每一系列芯片的I/O接口情况不太一样,若用户不了解而导致设置错误时,系统会出示错误提示对话框,引导用户进行正确的设置操作。The development system will also automatically avoid errors. Since the Sense Line and Scan Line are related to the chip I/O interface hardware, the I/O interface of each series of chips is not the same. If the user does not understand and causes a setting error, the system will show An error prompt dialog box guides the user to perform correct setting operations.
配置结束后,用户就能够使用QPL语言提供的触发条件描述语法来描述键盘的各个按键的触发条件和动作事件。After the configuration is completed, the user can use the trigger condition description syntax provided by the QPL language to describe the trigger conditions and action events of each key on the keyboard.
由于开发系统的键盘模组能识别两个键同时按下的情况,且能够识别某按键按下、抬起的动作。因此触发条件可以是键按下触发或键释放触发。Because the keyboard module of the development system can recognize the situation that two keys are pressed at the same time, and can recognize the action of pressing and lifting a certain key. So the trigger condition can be a key press trigger or a key release trigger.
在键盘功能对象中,动作事件可以是一个动作函数名,用户可以在后续的动作函数的描述部分Definition文件中做相应的函数体定义描述;动作事件也可以表示为无动作。In the keyboard function object, the action event can be an action function name, and the user can define and describe the corresponding function body in the subsequent action function description part Definition file; the action event can also be expressed as no action.
同时,用户可以设置若干不同的触发状态,在不同的触发状态下,用户可以为各个按键设置不同的动作事件,系统提供状态切换函数SetState以方便用户进行状态转换。At the same time, the user can set several different trigger states. In different trigger states, the user can set different action events for each button. The system provides the state switching function SetState to facilitate the user to perform state conversion.
下面是功能对象及触发机制编程描述的举例说明。The following is an example of a programming description of functional objects and trigger mechanisms.
$KeyScan:$KeyScan:
[1]DebounceLevel=10[1] DebounceLevel = 10
[2]Easy8[2]Easy8
[3] TG1 TG2 TG3 TG4 TG5 TG6 TG7 TG8[3] TG1 TG2 TG3 TG4 TG5 TG6 TG7 TG8
[4]K_S0:Path_A@Path_B/Path_C X X X X[4]K_S0: Path_A@Path_B/Path_C X X X X X
[5]K_S1:/Path_C X/Path_A /Path_C X/@Path_B X X[5]K_S1: /Path_C X/Path_A /Path_C X/@Path_B X X
[6]……[6]...
[7]K_Sn:X /Path_C X/Path_A /Path_C X /@Path_B X X[7]K_Sn: X /Path_C X/Path_A /Path_C X /@Path_B X X
其中,in,
[1]是对按键防抖功能的设置;[1] is the setting of the button anti-shake function;
[2]是通过IDE设置的键盘阵列大小;[2] is the keyboard array size set by IDE;
[3]是IDE生成的键盘阵列,TG1~TGm(m=8)表示键盘的每一个触发按键(即功能对象);[3] is the keyboard array generated by the IDE, TG1 ~ TGm (m=8) represent each trigger button (that is, the function object) of the keyboard;
[4]是用户使用QPL语言配置的键盘状态K_S0和在此状态下各个按键的触发条件和动作事件。K_S0是触发状态。[4] is the keyboard state K_S0 configured by the user using the QPL language and the trigger conditions and action events of each key in this state. K_S0 is the trigger state.
Path_A,Path_B,Path_C是触发时的执行动作函数的名称,与TG1~TGm一一对应,表示此触发按键被按下或释放时的执行动作(实际上,用户在此处设置动作事件时也同时宣告此动作事件,所以用户必须在后续的动作事件描述部分中定义这些动作事件的实际意义;动作事件可以复用),没有动作事件对应或使用X对应的触发按键无论在按下或释放时均没有执行动作。Path_A, Path_B, and Path_C are the names of the execution action functions when triggered, corresponding to TG1~TGm one by one, indicating the execution action when the trigger button is pressed or released (actually, when the user sets the action event here, it also Announce this action event, so the user must define the actual meaning of these action events in the subsequent action event description section; action events can be reused), there is no action event corresponding or the trigger button corresponding to X is pressed or released No action was performed.
动作事件前面如果有’/’字符,那么表示此动作在释放时触发,否则表示在按下时触发。If there is a '/' character in front of the action event, it means that the action is triggered when it is released, otherwise it means that it is triggered when it is pressed.
用户还可以同时设置动作函数的执行属性,方法就是在动作函数前面加入‘@’符号,如果设置的动作函数前加有‘@’符号,表示在触发条件满足时系统会采用快速函数的方式,即以调用(call)函数的方式进入某一动作函数执行该函数内指令,并以该函数内的“return”指令(从函数返回)返回到原来调用该函数的指令处,这种函数的执行可形成嵌套执行;如果设置的动作函数前没有‘@’符号,表示在触发条件满足时系统会采用普通函数方式,即采用“goto”指令方式进入函数执行该函数内指令,并以该函数内“end”指令结束指令的执行,而不会像调用函数那样返回,这种函数的执行不会形成嵌套执行。The user can also set the execution attribute of the action function at the same time. The method is to add the '@' symbol in front of the action function. If the '@' symbol is added in front of the set action function, it means that the system will use the fast function when the trigger condition is met. That is, enter an action function by calling a function to execute the instructions in the function, and use the "return" instruction (return from the function) in the function to return to the instruction that originally called the function. The execution of this function Nested execution can be formed; if there is no '@' symbol before the set action function, it means that the system will adopt the ordinary function method when the trigger condition is met, that is, use the "goto" instruction to enter the function to execute the instruction in the function, and use the function The inner "end" instruction ends the execution of the instruction, instead of returning like calling a function, and the execution of this function will not form nested execution.
[5]~[7]与[4]类似,是用户使用QPL语言配置的键盘状态K_S1,……,K_Sn和在这些状态下各个按键的触发条件和动作事件。[5]~[7] are similar to [4], which are the keyboard states K_S1, ..., K_Sn configured by the user using the QPL language and the trigger conditions and action events of each key in these states.
当用户将当前状态切换到KeyScan的某个状态时,则在此状态下,如果用户触发了某一按键,那么在此状态下这一按键的对应的动作事件将被可编程控制装置执行。When the user switches the current state to a certain state of KeyScan, in this state, if the user triggers a certain key, the corresponding action event of this key will be executed by the programmable control device in this state.
随后,进行动作事件描述(在Definition文件中进行),也就是对前面宣告的动作事件的实际意义进行定义,即对前面宣告的动作函数的函数体进行定义,可以是采用一些高级语言,如ANSI-C,Pascal,Fortran等,实现的用于描述执行动作的函数,并在至少一个函数里设定按键的某一个状态为当前执行状态。Then, describe the action event (in the Definition file), that is, define the actual meaning of the previously declared action event, that is, define the function body of the previously declared action function, which may be in some high-level language, such as ANSI -C, Pascal, Fortran, etc., implement functions used to describe execution actions, and set a certain state of the button as the current execution state in at least one function.
需要说明的是,可编程控制装置的各功能对象的触发状态的切换可以通过两种方式进行。一种方式是调用开发系统提供的状态切换函数SetState(x,y),参数x、y的含义是:x用于指明事件源,可为“KEY”、“IR”、“IN”、“OUT”、“TM”、“ME”等;y用于表示所指事件源中状态索引号(1~n),0为无状态。另一种方式是在动作事件中进行状态切换。It should be noted that the switching of the trigger state of each functional object of the programmable control device can be performed in two ways. One way is to call the state switching function SetState(x, y) provided by the development system. The meaning of the parameters x and y is: x is used to indicate the event source, which can be "KEY", "IR", "IN", "OUT ", "TM", "ME" and so on; y is used to indicate the state index number (1~n) in the event source referred to, and 0 means no state. Another way is to do state switching in action events.
也就是说,在编程过程中,用户只需要选定键盘阵列的触发按键;配置触发按键的触发状态和触发条件;并且设定按键在满足触发条件(按下/释放)时可编程控制装置所执行的动作事件(动作函数或无动作)即可。除此之外,用户不需要关心键盘使用的I/O脚是否与其它的I/O使用相冲突,不需要考虑如何进行键盘扫描的检测,不需要考虑在某一状态下按键按下或释放时如何触发相应的动作,所有这些有关硬件、软件底层的细节由开发系统的IDE及其中的QPL Complier和QPL Module协调解决。That is to say, in the programming process, the user only needs to select the trigger button of the keyboard array; configure the trigger state and trigger condition of the trigger button; and set the programmable control device when the button meets the trigger condition (press/release). The action event (action function or no action) that is executed is sufficient. In addition, the user does not need to care about whether the I/O pin used by the keyboard conflicts with other I/O uses, does not need to consider how to detect the keyboard scan, and does not need to consider whether the key is pressed or released in a certain state How to trigger the corresponding actions, all these details about the underlying hardware and software are coordinated and resolved by the IDE of the development system and its QPL Complier and QPL Module.
实例二IRScan(红外扫描接收方法)Example two IRScan (infrared scanning receiving method)
选定功能对象、设置触发条件及与动作事件的对应关系。Select the functional object, set the trigger condition and the corresponding relationship with the action event.
首先,本实例中选定用于接收红外信号的端口。如果用户没有进行选定,则开发系统将选用缺省的端口。First, select the port for receiving infrared signals in this example. If the user does not make a selection, the development system will use the default port.
需要说明的是,对本实例来说,由于指定红外接收器件的耗电量较大,因此需设定红外接收器件的电源控制端口及其有效/无效状态,使控制装置能够在省电的睡眠状态时将其无效掉。It should be noted that, for this example, due to the large power consumption of the specified infrared receiving device, it is necessary to set the power control port of the infrared receiving device and its valid/invalid status, so that the control device can be in a power-saving sleep state invalidate it.
其次,对于本实例来说,还需要选定红外接收器的编号(ID)。只有当接收到的红外命令中包含指定该编号的接收器时才执行动作事件。Second, for this example, the number (ID) of the selected infrared receiver is also required. The action event is only executed when the received IR command contains the specified receiver number.
随后,指定该管脚接收的红外信号的类型(红外命令之ID)。并配置不同类型的红外信号对应的动作事件。Then, specify the type of infrared signal received by the pin (ID of infrared command). And configure the action events corresponding to different types of infrared signals.
同时,用户可以设置若干个不同的触发状态,在不同的触发状态下,用户可以为各个红外信号设置不同的动作事件。At the same time, the user can set several different trigger states, and in different trigger states, the user can set different action events for each infrared signal.
下面是功能对象及触发机制描述的举例说明。The following are examples of descriptions of functional objects and trigger mechanisms.
$IrScan:$IrScan:
[1]IrReceivePin=Pa.0[1] IrReceivePin = Pa.0
[2]IrRxPowerCtrl(pb.1)/high[2]IrRxPowerCtrl(pb.1)/high
[3]IrRxId=1[3] IrRxId=1
[4] Rx1 Rx2 Rx3 Rx10[4] Rx1 Rx2 Rx3 Rx10
[5]Ir_S0:Path_A Path_B Path_C X[5]Ir_S0: Path_A Path_B Path_C X
[6]Ir_S1:Path_C Path_A Path_C X[6]Ir_S1: Path_C Path_A Path_C X
[7]……[7]...
[8]Ir_Sn:X Path_C Path_A Path_C[8]Ir_Sn: X Path_C Path_A Path_C
其中,in,
[1]是用户设置的红外接收IO端口,用户可以选择性设置,否则使用缺省的IO端口。[1] is the infrared receiving IO port set by the user, which can be set selectively by the user, otherwise the default IO port will be used.
[2]是用户对红外接收器进行电源控制的端口及其有效状态设置。[2] is the port for the user to control the power of the infrared receiver and its effective state setting.
[3]是对红外接收器编号的设置。[3] is the setting of the infrared receiver number.
[4]是接收的各红外信号的命令ID。[4] is the command ID of each received infrared signal.
[5]是对某一触发状态Ir_S0下接收到某一命令的红外信号Rxm(其中,m=0~63)时对应的动作事件的设置。[5] is the setting of the corresponding action event when the infrared signal Rxm (wherein, m=0~63) of a certain command is received in a certain trigger state Ir_S0.
[6]~[7]与[5]类似。是对触发状态Ir_S1,...,Ir_Sn下接收到某一命令的红外信号Rxm(m为正整数)时对应的动作事件的设置。[6]~[7] are similar to [5]. It is the setting of the corresponding action event when the infrared signal Rxm (m is a positive integer) of a certain command is received in the trigger state Ir_S1,..., Ir_Sn.
当用户将当前状态切换到IrScan某个状态Ir_Sn(n为正整数)时,那么在此状态下,如果接受到某一命令的红外信号,则这一命令的红外信号对应的动作事件将被执行。也就是说,当指定ID的红外接收器收到红外命令Rxm(m为正整数)后,可编程控制装置会执行当前触发状态下的Rxm下对应的动作事件。动作事件包括指定动作函数名或指定无动作(X)。When the user switches the current state to a certain state of IrScan Ir_Sn (n is a positive integer), then in this state, if the infrared signal of a certain command is received, the action event corresponding to the infrared signal of this command will be executed . That is to say, when the infrared receiver with the specified ID receives the infrared command Rxm (m is a positive integer), the programmable control device will execute the action event corresponding to Rxm under the current trigger state. An action event includes specifying an action function name or specifying no action (X).
随后,进行动作事件的实际意义的描述,也就是对前面宣告的动作函数的函数体进行定义,并在至少一个函数里设定IrScan功能对象的某一个状态为当前执行状态。Then, describe the actual meaning of the action event, that is, define the function body of the previously declared action function, and set a certain state of the IrScan function object as the current execution state in at least one function.
也就是说,在编程过程中,用户通过使用开发系统的QPL语言提供的Irscan语法,能简洁直观的指定当接收到某一红外命令信号时的动作事件;而无需关心硬件如何实现红外扫描,以及当接受到某一红外命令信号时,此红外命令信号如何与动作事件关联。同时,用户可以设置不同的触发状态,在不同的触发状态下,用户可以为各个红外命令信号设置不同的动作事件。有关底层的细节由开发系统的IDE及其中的QPL Complier和QPL Module协调解决。That is to say, during the programming process, by using the Irscan syntax provided by the QPL language of the development system, the user can concisely and intuitively specify the action event when receiving a certain infrared command signal; no need to care about how the hardware implements infrared scanning, and When an infrared command signal is received, how does this infrared command signal relate to an action event. At the same time, the user can set different trigger states, and in different trigger states, the user can set different action events for each infrared command signal. The details about the underlying layer are coordinated by the IDE of the development system and its QPL Complier and QPL Module.
实例三$Input(输入事件)Example three $Input (input event)
首先,选定功能对象。本实例中就是选定输入管脚。First, select the functional object. In this example it is the selected input pin.
随后,指定输入管脚的触发条件,并配置不同输入管脚被触发时对应的动作事件。Then, specify the trigger conditions of the input pins, and configure the corresponding action events when different input pins are triggered.
输入管脚可以在从高电平跃变到低电平时触发,或者从低电平跃变到高电平时触发。An input pin can trigger on a high-to-low transition, or a low-to-high transition.
同时,用户可以设置不同的触发状态,在不同的触发状态下,用户可以为各个输入管脚设置被触发时对应的不同的动作事件。动作事件包括指定动作函数名或指定无动作。At the same time, the user can set different trigger states, and in different trigger states, the user can set different action events corresponding to each input pin when it is triggered. Action events include specifying an action function name or specifying no action.
下面是功能对象及触发机制描述的举例说明。The following are examples of descriptions of functional objects and trigger mechanisms.
$Input:$Input:
[1]DebounceLevel=10[1] DebounceLevel = 10
[2] Pa.1 Pb.2 Pa.3 Pc.6[2] Pa.1 Pb.2 Pa.3 Pc.6
[3]I_S0:Path_A Path_B /Path_C[3]I_S0: Path_A Path_B /Path_C
[4]I_S1:/Path_C X/Path_A /Path_C[4]I_S1: /Path_C X/Path_A /Path_C
[5]……[5]...
[6]I_Sn:X /Path_C X/Path_A /Path_C[6]I_Sn: X /Path_C X/Path_A /Path_C
其中,in,
[1]是用户对输入信号防抖功能的设置。[1] is the user's setting for the input signal anti-shake function.
[2]是用户设置的输入管脚。用户可以通过IDE提供的信息来查看可选用的管脚,以此来正确选择管脚(如果选择不正确,Compiler将提示错误)。[2] is the input pin set by the user. Users can view the available pins through the information provided by the IDE, so as to correctly select the pins (if the selection is incorrect, the Compiler will prompt an error).
[3]是用户使用QPL语言配置的输入管脚触发状态I_S0和在此状态下各个输入管脚的触发条件和动作事件。I_S0是触发状态。[3] is the input pin trigger state I_S0 configured by the user using QPL language and the trigger conditions and action events of each input pin in this state. I_S0 is the trigger state.
Path_A,Path_B,Path_C是被触发时的执行动作函数名。动作函数名前面如果有’/’字符,那么表示此动作函数在输入管脚从高电平跃变到低电平时触发,否则表示在输入管脚从低电平跃变到高电平时触发。其余与KeyScan类似。Path_A, Path_B, Path_C are the name of the execution action function when triggered. If there is a '/' character in front of the action function name, it means that the action function is triggered when the input pin transitions from high level to low level, otherwise it means that it is triggered when the input pin transitions from low level to high level. The rest is similar to KeyScan.
[4]~[6]与[3]类似,是用户使用QPL语言配置的输入管脚触发状态I_S1,...,I_Sn和在这些状态下各个输入管脚的触发条件和动作事件。[4]~[6] are similar to [3], which are the input pin trigger states I_S1,...,I_Sn configured by the user using the QPL language, and the trigger conditions and action events of each input pin in these states.
随后,进行动作事件中动作函数描述,也就是对前面宣告的动作函数进行函数体定义,并在至少一个函数里设定输入管脚的一个状态为当前执行状态。Then, describe the action function in the action event, that is, define the function body of the previously declared action function, and set a state of the input pin as the current execution state in at least one function.
本实例在编程过程中,用户通过使用开发系统的QPL语言提供的Input语法,能简洁直观的指定任何输入管脚以及动作事件;而无需关心硬件如何实现输入管脚扫描,以及如何实现某一输入管脚与动作事件的关联。同时,用户可以设置不同的触发状态,在不同的触发状态下,用户可以设置各个输入管脚被触发时不同的动作事件。有关硬件、软件底层的细节由开发系统的IDE及其中的QPL Complier和QPL Module协调解决。In the programming process of this example, users can specify any input pins and action events concisely and intuitively by using the Input syntax provided by the QPL language of the development system; they do not need to care about how the hardware implements input pin scanning, and how to implement a certain input Association of pins with action events. At the same time, the user can set different trigger states, and in different trigger states, the user can set different action events when each input pin is triggered. The details of the underlying hardware and software are coordinated by the IDE of the development system and its QPL Complier and QPL Module.
实例四$Output(输出事件)Example four $Output (output event)
首先,选定功能对象。本实例中就是选定输出管脚。First, select the functional object. In this example it is the selected output pin.
随后,指定不同输出管脚被触发时的对应的动作事件。Then, specify the corresponding action events when different output pins are triggered.
动作事件包括指定动作常量或指定无动作。其中,动作常量可表示为逻辑高电平信号,或为逻辑低电平信号,或为单正脉冲信号,或为单负脉冲信号,或为正脉冲串信号,或为负脉冲串信号。Action events include specifying an action constant or specifying no action. Wherein, the action constant can be expressed as a logic high level signal, or a logic low level signal, or a single positive pulse signal, or a single negative pulse signal, or a positive pulse train signal, or a negative pulse train signal.
同时,用户可以设置若干个不同的触发状态,在不同的触发状态下,用户可以为各个输出管脚设置不同的动作事件。At the same time, the user can set several different trigger states, and in different trigger states, the user can set different action events for each output pin.
下面是功能对象及触发机制描述的举例说明。The following are examples of descriptions of functional objects and trigger mechanisms.
$Output:$Output:
[1]FlashRate=50[1] FlashRate = 50
[2]Duty=0.6[2]Duty=0.6
[3] Pa.1 Pb.2 Pa.3 Pc.6[3] Pa.1 Pb.2 Pa.3 Pc.6
[4]O_S0:H L P+[4]O_S0: H L P+
[5]O_S1:L P- X SP-[5]O_S1: L P- X SP-
[6]……[6]...
[7]O_Sn:X SP+ P-/Duty=0.3/80[7]O_Sn: X SP+ P-/Duty=0.3/80
其中,in,
[1]是用户设置的输出信号为正或为负脉冲串信号时该脉冲串信号的频率。[1] is the frequency of the pulse train signal when the output signal set by the user is positive or negative.
[2]是用户设置的输出信号为正或为负脉冲串信号时该脉冲串信号的占空比。[2] is the duty cycle of the pulse train signal when the output signal set by the user is positive or negative.
[3]是用户设置的输出管脚。用户可以通过IDE提供的信息来查看可选用的输出管脚,以此来正确选择管脚(如果选择不正确,Compiler将提示错误)。[3] is the output pin set by the user. Users can view the available output pins through the information provided by the IDE, so as to correctly select the pins (if the selection is incorrect, the Compiler will prompt an error).
[4]是用户设置的输出状态O_S0以及在此状态下每个输出管脚的输出状态。[4] is the output state O_S0 set by the user and the output state of each output pin in this state.
[5]~[7]与[4]类似,是用户设置的输出状态O_S1,...,O_Sn以及在此状态下每个输出管脚的输出状态。[5]~[7] are similar to [4], which are the output states O_S1, ..., O_Sn set by the user and the output state of each output pin in this state.
注意,在此,“H”、“L”分别表示输出逻辑高或逻辑低电平信号;“P+”、“P-”分别表示输出正或为负脉冲串信号;“SP+”、“SP-”则分别为单正或单负脉冲信号。Note that here, "H" and "L" represent output logic high or logic low level signals respectively; "P+" and "P-" respectively represent output positive or negative pulse train signals; "SP+", "SP- " are single positive or single negative pulse signals respectively.
当用户将当前状态切换到某个触发状态时,那么在此状态下可编程控制装置将驱动各个输出管脚输出与之相对应的信号波形。When the user switches the current state to a certain trigger state, the programmable control device will drive each output pin to output a corresponding signal waveform in this state.
随后,进行动作事件描述,即在至少一个函数里设定输出管脚的一个状态为当前执行状态。Then, describe the action event, that is, set a state of the output pin as the current execution state in at least one function.
本实例中,在编程过程中,用户通过使用开发系统的QPL语言提供的Onput语法,能简洁直观的指定任何输出管脚以及动作事件;而无需关心硬件如何实现输出管脚扫描,以及如何实现某一输出管脚与动作事件的关联。同时,用户可以设置不同的触发状态,在不同的触发状态下,用户可以为各个输出管脚设置不同的动作事件。有关硬件、软件底层的细节由开发系统的IDE及其中的QPL Complier和QPL Module协调解决。In this example, during the programming process, users can specify any output pins and action events concisely and intuitively by using the Input syntax provided by the QPL language of the development system; they do not need to care about how the hardware implements output pin scanning, and how to implement a certain An output pin is associated with an action event. At the same time, the user can set different trigger states, and in different trigger states, the user can set different action events for each output pin. The details of the underlying hardware and software are coordinated by the IDE of the development system and its QPL Complier and QPL Module.
实例五$TimerEvents(定时器事件)Example five $TimerEvents (timer event)
首先,选定功能对象。本实例中就是选定定时器。First, select the functional object. In this example, it is the selected timer.
随后,指定不同定时器满足定时计数溢出条件时的对应执行的动作事件。该动作事件包括指定动作函数名或指定无动作。Then, specify the corresponding action event to be executed when different timers meet the timer count overflow condition. The action event includes specifying an action function name or specifying no action.
同时,用户可以设置不同的触发状态,在不同的触发状态下,用户可以为各个定时器设置不同的动作事件。该动作事件包括指定动作函数名或指定无动作。At the same time, the user can set different trigger states, and in different trigger states, the user can set different action events for each timer. The action event includes specifying an action function name or specifying no action.
下面是功能对象及触发机制描述的举例说明。The following are examples of descriptions of functional objects and trigger mechanisms.
$TimerEvents:$TimerEvents:
[1] TM1 TM2 TM3 TM4[1] TM1 TM2 TM3 TM4
[2]T_S0:T_Path_A T_Path_B T_Path_C X[2] T_S0: T_Path_A T_Path_B T_Path_C X
[3]T_S1:T_Path_C T_Path_A T_Path_C X[3] T_S1: T_Path_C T_Path_A T_Path_C X
[4]……[4]...
[5]T_Sn:X T_Path_C T_Path_A T_Path_C[5] T_Sn: X T_Path_C T_Path_A T_Path_C
其中,in,
[1]是用户设置的时钟的ID。[1] is the ID of the clock set by the user.
[2]是对某一状态T_S0下某一时钟被触发时的动作事件的设置,其中,“T_Path_A”、“T_Path_B”、“T_Path_C”分别为指定的动作函数名,“X”为指定的无动作。[2] is the setting of the action event when a clock is triggered in a certain state T_S0, where "T_Path_A", "T_Path_B", and "T_Path_C" are the specified action function names, and "X" is the specified none action.
[3]~[5]与[2]类似。是对状态T_S1,...,T_Sn下某一时钟被触发,即满足定时计数溢出条件时的动作事件的设置。[3]~[5] are similar to [2]. It is the setting of the action event when a certain clock is triggered in the state T_S1, ..., T_Sn, that is, when the timing count overflow condition is met.
当用户将当前状态切换到定时器的某个触发状态时,则在此触发状态下,如果某一时钟的计时时间到达,那么在此状态下这一时钟对应的动作事件将被执行。When the user switches the current state to a trigger state of the timer, in this trigger state, if the timing time of a certain clock arrives, the action event corresponding to this clock will be executed in this state.
并且,在设置触发状态后,用户可以设置定时器TMm(m为正整数)的加或减定时计数初值,当在该计数初值基础上定时计数溢出时,会执行该定时器在此状态下对应的动作事件。Moreover, after setting the trigger state, the user can set the initial value of the timer TMm (m is a positive integer) to add or subtract the timing count. Click on the corresponding action event.
随后,进行动作事件中动作函数描述,也就是对前面宣告的动作函数进行函数体定义,并在至少一个函数里设定输入管脚的一个状态为当前执行状态。Then, describe the action function in the action event, that is, define the function body of the previously declared action function, and set a state of the input pin as the current execution state in at least one function.
本实例中,用户通过使用QPL语言提供的timerevent语法,能简洁直观的指定当某一时钟的计时时间来到时的动作事件,而无需关心可编程控制装置如何实现时钟与其对应动作事件的关联。同时,用户可以设置不同的触发状态,在不同的触发状态下,用户可以为各个时钟设置不同的动作事件。所有这些有关硬件、软件底层的细节通过IDE,Compiler,Module协调解决。In this example, by using the timerevent syntax provided by the QPL language, the user can concisely and intuitively specify the action event when the timing time of a certain clock arrives, without caring about how the programmable control device implements the association between the clock and its corresponding action event. At the same time, the user can set different trigger states, and in different trigger states, the user can set different action events for each clock. All these details about the underlying hardware and software are coordinated and resolved through IDE, Compiler, and Module.
实例六$MusicEvents(音乐播放事件)Example 6 $MusicEvents (music playback event)
首先,选定功能对象。本实例中就是选定资源文件并指定其中的音符ID。First, select the functional object. In this example, the resource file is selected and the note ID in it is specified.
资源文件是指可编程控制装置在运行时使用的音乐文件(如MIDI音乐)及其相关参数。Resource files refer to music files (such as MIDI music) and related parameters used by the programmable control device during operation.
通常,在MIDI音乐中可以设置多个音符(EventNote)。如下表所示:Usually, multiple notes (EventNote) can be set in MIDI music. As shown in the table below:
EventNoteEventNote
因此,通过选定若干音符,并指定音符在不同音符播放时对应的动作事件。则当特定的音符被播放时,可编程控制装置可以执行设定的动作事件。该动作事件包括指定动作函数名或指定无动作。Therefore, by selecting several notes and specifying the action events corresponding to the notes when different notes are played. Then when a specific note is played, the programmable control device can execute the set action event. The action event includes specifying an action function name or specifying no action.
同时,用户可以设置若干不同的触发状态,在不同的触发状态下,用户可以为各个指定的音符设置不同的动作事件。At the same time, the user can set several different trigger states, and in different trigger states, the user can set different action events for each specified note.
下面是功能对象及触发机制描述的举例说明。The following are examples of descriptions of functional objects and trigger mechanisms.
$MusicEvents:$MusicEvents:
[1] ME1 ME2 ME3 ME10[1] ME1 ME2 ME3 ME10
[2]M_S0:M_Path_A M_Path_B M_Path_C X[2]M_S0: M_Path_A M_Path_B M_Path_C X
[3]M_S1:M_Path_C M_Path_A M_Path_C X[3] M_S1: M_Path_C M_Path_A M_Path_C X
[4]……[4]...
[5]M_Sn:X M_Path_C M_Path_A M_Path_C[5] M_Sn: X M_Path_C M_Path_A M_Path_C
其中,in,
[1]是用户设置的音符ID列表,音符ID最大可以是ME128。[1] is the note ID list set by the user, and the maximum note ID can be ME128.
[2]是对某一状态M_S0下对指定音符被播放时的动作事件的设置,其中,“M_Path_A”、“M_Path_B”、“M_Path_C”分别为指定的动作函数名,“X”为指定的无动作。[2] is the setting of the action event when the specified note is played in a certain state M_S0, where "M_Path_A", "M_Path_B", and "M_Path_C" are the names of the specified action functions, and "X" is the specified none action.
[3]~[5]与[2]类似。是对状态M_S1,...,M_Sn下某一音符被播放时的动作事件的设置。[3]~[5] are similar to [2]. It is the setting of the action event when a note is played in the states M_S1,...,M_Sn.
当用户将当前状态切换到某个musicevent状态时,如果指定音符被播放,那么在此状态下指定音符对应的动作事件将被执行。When the user switches the current state to a certain musicevent state, if the specified note is played, then the action event corresponding to the specified note in this state will be executed.
随后,进行动作事件中动作函数描述,也就是对前面宣告的动作函数进行函数体定义,并在至少一个函数里设定输入管脚的一个状态为当前执行状态。Then, describe the action function in the action event, that is, define the function body of the previously declared action function, and set a state of the input pin as the current execution state in at least one function.
本实例中,用户通过使用QPL语言提供的musicevent语法,能简洁直观的指定当某一音符被播放时的动作事件,而无需关心程序如何实现某一音符与其对应动作事件的关联。同时,用户可以设置不同的触发状态,在不同的触发状态下,用户可以为指定音符设置不同的动作事件。所有这些有关硬件、软件底层的细节通过IDE及其中的Compiler,Module协调解决。In this example, by using the musicevent syntax provided by the QPL language, the user can concisely and intuitively specify the action event when a certain note is played, without caring about how the program realizes the association between a certain note and its corresponding action event. At the same time, the user can set different trigger states, and in different trigger states, the user can set different action events for the specified notes. All these details about the underlying hardware and software are coordinated and resolved through the IDE and its Compiler and Module.
实例七$SpeechEvents(语音播放事件)Example seven $SpeechEvents (speech playback event)
对于语音播放事件来说,其处理思路类似于实例六的音乐播放事件,此不赘述。As for the voice playing event, its processing idea is similar to that of the music playing event in Example 6, which will not be repeated here.
在用户对源文件的编辑结束后,可以通过IDE启动编译单元,由编译单元根据用户输入的信息自动生成汇编语言格式的控制程序。After the user finishes editing the source file, the compilation unit can be started through the IDE, and the compilation unit will automatically generate a control program in assembly language format according to the information input by the user.
请参阅图9,编译单元的驱动单元从用户交互单元110接收输入的信息;将资源引入源文件(Resource)和软硬件环境和触发机制源文件(Declaration)传递给功能对象及触发机制处理单元(QPDEC)。Referring to Fig. 9, the driver unit of the compilation unit receives input information from the
功能对象及触发机制处理单元将资源引入源文件和软硬件环境和触发机制源文件转换成第一编译参数,反馈给驱动单元。The functional object and trigger mechanism processing unit converts the resource introduction source file and the software and hardware environment and the trigger mechanism source file into first compilation parameters, and feeds them back to the drive unit.
驱动单元将动作事件源文件(Definition)传递给动作事件预处理部分(QPDCC);动作事件预处理部分对该动作事件源文件进行预处理后生成第二编译参数,反馈给驱动单元。The drive unit passes the action event source file (Definition) to the action event preprocessing part (QPDCC); the action event preprocessing part preprocesses the action event source file and generates second compilation parameters, which are fed back to the drive unit.
驱动单元将第一和第二编译参数传递给编译部分(QPDEF),生成汇编语言格式的控制程序。The drive unit passes the first and second compilation parameters to the compilation part (QPDEF) to generate a control program in assembly language format.
在此过程中,当编译单元120扫描到功能对象的选定信息中包含的某一功能对象时,则从功能模组130中提取该功能对象的操作程序,并将其一一有机结合到控制程序中。During this process, when the compiling
随后,汇编单元和链接单元对所述控制程序进行汇编、链接,生成可执行机器代码。Subsequently, the assembly unit and the linking unit assemble and link the control program to generate executable machine codes.
此外,为进一步扩展可编程控制装置的功能,当选定的功能对象是Music(音乐)播放模块的EventNote(音符)或者Speech(语音)播放模块的EventSect(语音段)时,还包括绑定可执行机器代码与资源文件,生成完整的可执行机器代码的步骤。In addition, in order to further expand the functions of the programmable control device, when the selected functional object is the EventNote (note) of the Music (music) playback module or the EventSect (voice segment) of the Speech (voice) playback module, it also includes binding Steps to execute machine code and resource files to generate complete executable machine code.
在生成可执行机器代码后,即可进行下载并调试运行;如果调试通过,则可加载烧录至可编程控制装置,完成所需功能的开发,此不赘述。After the executable machine code is generated, it can be downloaded and debugged; if the debugging is passed, it can be loaded and burned into the programmable control device to complete the development of the required functions, which will not be described here.
请参阅图10,是本发明可编程控制装置的框图。Please refer to FIG. 10 , which is a block diagram of the programmable control device of the present invention.
该可编程控制装置包括功能单元810、存储单元820、事件响应电路830、执行电路840和复位电路850。The programmable control device includes a
所述功能单元810是可编程控制装置中能够实现特定功能的器件,具有若干功能对象,当这些功能对象被触发时,可编程控制装置可以根据预先的设定去完成与其关联的动作,从而有效地完成用户的功能需求。The
通常,功能单元810包括但不限于输入电路、输出电路、键盘扫描电路、定时/计数器、模数转换器、红外接收电路、语音播放电路、音乐播放电路等。Generally, the
一般来说,对于可以接收外部信号的器件来说,当其接收到预定的信号时,即可以认为该功能对象被触发。而对于输出电路来说,当控制装置启动该输出电路以向外部输出信号时,则认为输出电路被触发。Generally speaking, for a device that can receive external signals, when it receives a predetermined signal, it can be considered that the functional object is triggered. As for the output circuit, when the control device activates the output circuit to output a signal to the outside, it is considered that the output circuit is triggered.
此外,为进一步拓展可编程控制装置的功能,还可以将控制装置内定时器,或播放的音符或者声音片断定义为功能对象。此时,如果定时器计时时间到达时、或语音播放电路来播放特定的声音片断或者音乐播放电路播放特定的音符,则认为该功能对象被触发。In addition, in order to further expand the functions of the programmable control device, the timer in the control device, or the played notes or sound clips can also be defined as functional objects. At this time, if the timer timing is reached, or the voice playback circuit plays a specific sound clip or the music playback circuit plays a specific note, then the functional object is considered to be triggered.
此外,对于同一个功能对象来说,可以为其设定多个不同的触发条件,例如,对于键盘来说,按键被按下或抬起可以认为是两个不同的触发条件,并且对应不同的触发条件可以设定不同的动作事件。In addition, for the same functional object, multiple different trigger conditions can be set for it. For example, for a keyboard, pressing or lifting a key can be considered as two different trigger conditions, and correspond to different Trigger conditions can set different action events.
而且对于同一个功能对象,可以设置多个不同的触发状态,在特定的触发状态下来指定对应的动作事件,从而进一步丰富触发机制的表现形式。Moreover, for the same functional object, multiple different trigger states can be set, and corresponding action events can be specified in a specific trigger state, thereby further enriching the expression form of the trigger mechanism.
该存储单元820中存储所述功能对象的触发状态、以及各触发状态下功能对象被触发时对应的动作事件。上述信息可以包含在用户采用本发明的开发方法完成的控制程序内。该信息可以存储在一个存储空间内,也可以采用多个存储空间来进行保存,此不赘述。The
当功能对象810被触发时,事件响应电路830将获悉相关的触发信号,从而查询存储单元820以判断功能对象810的当前触发状态;并且根据触发信号查找对应的动作事件。When the
触发信号可以是功能对象产生的异常中断信号或事件中断信号。例如,当功能对象是定时器,所述触发信号是定时器计时溢出信号所引发的异常中断信号或事件中断信号。当功能对象是输入电路时,则可以是其接收的外部信号所触发的异常中断信号或事件中断信号。The trigger signal can be an abnormal interrupt signal or an event interrupt signal generated by a functional object. For example, when the functional object is a timer, the trigger signal is an abnormal interrupt signal or an event interrupt signal caused by a timer overflow signal. When the functional object is an input circuit, it may be an abnormal interrupt signal or an event interrupt signal triggered by an external signal received by it.
执行电路840随后根据事件响应电路830的查找结果执行所述动作事件。The
复位电路850主要用于实现所述可编程控制装置的复位操作。The
请参阅图11,是本发明可编程控制装置的一个实施例。Please refer to Fig. 11, which is an embodiment of the programmable control device of the present invention.
该可编程控制装置包括处理器710、存储器720、输入/输出端口730、低电压复位和上电复位电路740、定时/计数器750、音频处理器760、数字混合器(多通道声音硬件合成电路)770、数模转换电路780。This programmable control device includes
输入/输出端口730中的通用输入/输出端口、特殊功能输入输出端口、数模转换电路780等触发信号提供单元被触发后可以产生相应的触发信号。其中,输入/输出端口730中的通用输入端口在接收到外部信号时,与其连接的管脚读取电路将产生触发信号发送到处理器710;或者与其连接的睡眠/唤醒电路将产生异常中断或事件中断信号,发送到处理器710;输入/输出端口730中的通用输入/输出端口可组成各种类型的键盘矩阵电路,在接收到键按下或键抬起信号时,将产生触发信号发送到处理器710,或者与输入端口连接的睡眠/唤醒电路将产生异常中断或事件中断信号,发送到处理器710。特殊功能输入端口包括红外命令接收/端口、比较器比较输入端口以及模数转换器电路端口,分别在接收到红外命令时产生触发信号发送到处理器710,或比较输入信号相等时产生触发信号发送到处理器710,或将从控制装置外部接收模拟信号并将其转换为数字信号时产生触发信号发送到处理器710。输入/输出端口730中的通用输出端口被触发后,处理器710将根据当前触发状态执行输出动作常量指令,可输出逻辑高电平、逻辑低电平、单正脉冲信号、单负脉冲信号、或脉冲串信号。Trigger signal providing units such as general input/output ports, special function input and output ports, and digital-to-
定时/计数器750在定时/计时时间到达后,将产生事件中断信号会发送到处理器710。The timer/
音频处理器760和数字混合器770用于对音频信号进行处理并进行多通道混音处理,通过数模转换电路780在播放特定的音符或声音片断时,处理器710也会根据事先的设定接收到对应的触发信号。The
此外,低电压复位和上电复位电路740在触发时会引发复位事件,发送到处理器710。In addition, the low voltage reset and power-on
存储器720存储动作事件、触发信号与动作事件之间的对应关系。The
处理器710根据触发信号查找存储器720内的对应关系,并获取动作事件的地址,执行相应的动作事件。The
可以理解的是,触发信号提供单元还可以是图像接收单元,用于从控制装置外部接收图像信号。It can be understood that the trigger signal providing unit may also be an image receiving unit for receiving an image signal from outside the control device.
用于输出处理器产生的输出信号的信号输出单元还可以是图像显示驱动电路,此不赘述。The signal output unit for outputting the output signal generated by the processor may also be an image display driving circuit, which will not be described in detail here.
综上所述,本发明将可编程控制装置模块化划分各个功能对象,同时将控制程序模块化为功能对象选定、触发机制配置和动作事件设定等部分,用户能站在更高的层面描述软硬件触发环境,而不需要关心底层软、硬件的实现细节,所以使产品应用程序的开发简化、快速且清晰直观,并且方便用户的后续功能扩充。In summary, the present invention modularizes the programmable control device into various functional objects, and at the same time modularizes the control program into functional object selection, trigger mechanism configuration, and action event setting, so that users can stand at a higher level Describe the software and hardware triggering environment without caring about the implementation details of the underlying software and hardware, so the development of product applications is simplified, fast, clear and intuitive, and it is convenient for users to expand subsequent functions.
本发明可以协调控制装置各个部件功能,屏蔽底层硬件的细节,提供用户一个功能描述的环境,使得开发人员能把主要精力放在产品的功能上,而不需要对该装置的硬件资源非常熟悉,因此用户做的只是需要考虑实现控制装置哪些功能,而不需要去关心实现方案的细节,以此带给用户更大的功能设计空间。The present invention can coordinate the functions of each component of the control device, shield the details of the underlying hardware, and provide users with an environment for describing functions, so that developers can focus on the functions of the product without being very familiar with the hardware resources of the device. Therefore, what the user needs to do is to consider which functions of the control device to realize, and does not need to care about the details of the implementation scheme, thereby giving the user more room for functional design.
本发明提供QPL高级语言,其兼有模块化功能描述语言和集成化程序设计高级语言的优点,运用模块化功能描述语法,用户能站在更高的层面描述软硬件触发环境,而不需要关心底层软、硬件的实现细节,所以使产品应用程序清晰直观,从而方便了用户的后续功能扩充;运用集成化程序设计高级语言语法,用户能方便灵活的运用系统提供的各种播放控制指令、事件控制指令、时间控制指令来控制硬体的行为,同时配以集成化程序设计语言的控制流,表达式语法,用户能充分的描述动作事件。The invention provides QPL high-level language, which has the advantages of modular function description language and integrated programming high-level language. By using modular function description grammar, users can describe the triggering environment of software and hardware at a higher level without concern The implementation details of the underlying software and hardware make the product application program clear and intuitive, thereby facilitating the user's subsequent function expansion; using the integrated programming high-level language syntax, the user can conveniently and flexibly use various playback control commands and events provided by the system Control instructions and time control instructions are used to control the behavior of the hardware. At the same time, with the control flow and expression syntax of the integrated programming language, the user can fully describe the action events.
本发明可以应用于多个领域的可编程控制装置,采用本发明开发的控制装置可以应用于语音类控制器、通讯、多媒体电子产品,如儿童电子琴、电子语音玩具、电子图书、和弦铃声、游戏机、智能电话、多功能玩具等。The present invention can be applied to programmable control devices in many fields. The control device developed by the present invention can be applied to voice controllers, communications, and multimedia electronic products, such as children's electronic pianos, electronic voice toys, electronic books, polyphonic ringtones, and games. mobile phones, smart phones, multifunctional toys, etc.
以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以作出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。The above is only a preferred embodiment of the present invention, it should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present invention, some improvements and modifications can also be made, and these improvements and modifications should also be It is regarded as the protection scope of the present invention.
Claims (24)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2005100000163A CN100370416C (en) | 2005-01-04 | 2005-01-04 | Programmable control device and method thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2005100000163A CN100370416C (en) | 2005-01-04 | 2005-01-04 | Programmable control device and method thereof |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1801081A CN1801081A (en) | 2006-07-12 |
CN100370416C true CN100370416C (en) | 2008-02-20 |
Family
ID=36811113
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2005100000163A Expired - Fee Related CN100370416C (en) | 2005-01-04 | 2005-01-04 | Programmable control device and method thereof |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100370416C (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI459295B (en) * | 2008-08-22 | 2014-11-01 | Hon Hai Prec Ind Co Ltd | System and method for dynamically calling function modules |
CN103546625B (en) * | 2012-07-16 | 2016-12-21 | 南京中兴软件有限责任公司 | Terminal operation control method and device |
CN104050951B (en) * | 2014-05-05 | 2017-10-13 | 杭州天堂伞业集团有限公司 | Wind-force music apparatus and the music parachute kit with the device |
CN107664960A (en) * | 2017-08-23 | 2018-02-06 | 深圳市顺讯电子有限公司 | A kind of programmable control system and method |
KR20200124317A (en) * | 2018-04-27 | 2020-11-02 | 미쓰비시덴키 가부시키가이샤 | Programmable display system and programmable indicator |
CN111933099A (en) * | 2020-07-27 | 2020-11-13 | 北京爱其科技有限公司 | MIDI music playing circuit and method based on single chip microcomputer |
CN114996204B (en) * | 2022-06-13 | 2023-04-14 | 北京中科昊芯科技有限公司 | Configurable device of system on chip |
CN116165926A (en) * | 2022-12-07 | 2023-05-26 | 青岛海信日立空调系统有限公司 | Household appliance product |
CN118689155B (en) * | 2024-08-22 | 2025-01-10 | 苏州国芯科技股份有限公司 | Programmable timer, micro-control unit and vehicle |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5321829A (en) * | 1990-07-20 | 1994-06-14 | Icom, Inc. | Graphical interfaces for monitoring ladder logic programs |
US6366116B1 (en) * | 2001-01-18 | 2002-04-02 | Sunplus Technology Co., Ltd. | Programmable driving circuit |
CN1407441A (en) * | 2001-08-24 | 2003-04-02 | 微软公司 | System and method for automatic management computer service and programmable device |
CN1431570A (en) * | 2002-01-10 | 2003-07-23 | 欧姆龙株式会社 | Unit and programmbale controller and processing method of subscriber program |
-
2005
- 2005-01-04 CN CNB2005100000163A patent/CN100370416C/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5321829A (en) * | 1990-07-20 | 1994-06-14 | Icom, Inc. | Graphical interfaces for monitoring ladder logic programs |
US6366116B1 (en) * | 2001-01-18 | 2002-04-02 | Sunplus Technology Co., Ltd. | Programmable driving circuit |
CN1407441A (en) * | 2001-08-24 | 2003-04-02 | 微软公司 | System and method for automatic management computer service and programmable device |
CN1431570A (en) * | 2002-01-10 | 2003-07-23 | 欧姆龙株式会社 | Unit and programmbale controller and processing method of subscriber program |
Also Published As
Publication number | Publication date |
---|---|
CN1801081A (en) | 2006-07-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101551747B (en) | Software system configuring tool of ARM series microprocessor | |
CN100370416C (en) | Programmable control device and method thereof | |
CN100359462C (en) | Development method and system of programmable control device | |
CN106250116B (en) | A kind of software generic skeleton code generation method and system | |
CN105164641A (en) | Extending development environment | |
WO2015039628A1 (en) | Visualization step programming method | |
CN100530089C (en) | Pointing-reading machine system and its script drive method | |
Nayyar | An encyclopedia coverage of compiler's, programmer's & simulator's for 8051, pic, avr, arm, arduino embedded technologies | |
US6453450B1 (en) | Timing diagram compiler and runtime environment for interactive generation of executable test programs for logic verification | |
Gay | Beginning stm32 | |
Sadilek et al. | Prototyping visual interpreters and debuggers for domain-specific modelling languages | |
CN102541568A (en) | Graphic programming development method based on Cortex-M3-series microprocessor | |
CN111338753A (en) | System for realizing hardware simulation of electronic control unit based on computer | |
Khner | Expert. NET Micro Framework | |
CN110874215B (en) | Drive control method and system for electric appliance or electric equipment | |
Larsen et al. | Overture vdm-10 tool support: User guide | |
CN117539454A (en) | Event processing method, device, electronic equipment, chip and medium | |
CN101211308A (en) | Microcontroller emulation system | |
KR20160081200A (en) | Script-based microcontroller firmware development platform | |
KR20020032256A (en) | Integrated Embedded System and Method for Realizing thereof | |
JP2000035898A (en) | System simulator and system simulating method | |
CN100407116C (en) | Mouse quick input system and mouse for realizing quick input | |
CN120491947A (en) | Internet of things module programming method and device | |
Hass et al. | Modernizing the microcontroller laboratory with low-cost and open-source tools | |
Parson et al. | A {Tcl-Based}{Self-Configuring} Embedded System Debugger |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20080220 Termination date: 20150104 |
|
EXPY | Termination of patent right or utility model |