在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → Truetime manual Truetime2.0 使用手册

Truetime manual Truetime2.0 使用手册

一般编程问题

下载此实例
  • 开发语言:Others
  • 实例大小:0.79M
  • 下载次数:1
  • 浏览次数:271
  • 发布时间:2020-08-12
  • 实例类别:一般编程问题
  • 发 布 人:robot666
  • 文件格式:.pdf
  • 所需积分:2
 

实例介绍

【实例简介】
英文原版Truetime2.0使用手册。利用matlab实现MAC层模型。不知道怎么在一个标题下传多个文件,求教
Contents 1. Introduction 2. Getting Started 7 2. 1 Software Requirements 7 2.2 Installation 7 2.3 Compilation 3. Using the Simulator Writing Code Functions 4.1 Writing a Matlab Code function 4.2 Writing a C++ Code Function 10 4.3 Calling Simulink Block Diagrams 10 5. Initialization 12 5.1 Writing a Matlab Initialization Script 5.2 Writing a C++ Initialization Script 13 6. Compilation 13 7. The TrueTime kernel 15 7.1 Dynamic Voltage Scaling 8. The TrueTime Network 16 8.1 CSMA/ CD(Ethernet) 17 8.2 CSMA/AMP(CAN) 17 8.3 Round Robin(Token Bus 7 8.4 FDMA 18 8.5 TDMA (TTP) 18 8.6 Switched ethernet 18 8.7 Flexray 19 8. 8 PROFINET IO 19 9. The TrueTime Wireless Network 21 9180211b/g(WLAN) 22 9.2802154( ZigBee).. 23 9.3 Calculation of error probabilities 24 9.4 User-Defined Path-Loss Function 25 10. The TrueTime Battery 27 11. The TrueTime Standalone network blocks 27 12. Examples 12.1 PID-control of a Dc-servo 28 12.2 Task Scheduling and Control .....31 12.3 Networked Control System 32 12.4 Wireless Control System with Automatic Gain Control 33 12.5 Wireless Ad-hoc Routing Using AODV 34 12.6 Mote soccer 6 13. Kernel Implementation Details ,36 13.1 Kernel data Structures 37 13.2 Task model 39 13. 3 The Kernel Function 13.4 Timing 14. TrueTime Command reference 42 ttAbortSimulation (TH) ttAnalogIn(TH) 48 ttAnalogOut (TH) 49 ttAttachCBS D) 50 ttAttachDLHandler(1)..,....... 51 ttAttachHook(C++ only)(n) ,,,,,,52 ttAttachNetworkHandler n) 53 ttAttachTriggerHandler (n) .,54 ttAttachWCETHandler() 55 ttCallBlock System(TH) 56 ttCreateCBS (I) ttCreateEvent() .........58 ttCreateHandler(I) 59 ttCreate ob(TH) 60 ttCreateLog(功 61 ttCreateMailbox (I) 63 ttCreateMonitor (I) 64 ttCreatePeriodicTask (1) ttCreatePeriodicTimer(ITH) ,,66 ttCreateSemaphore I) 67 ttCreateTask(I) 68 ttCreateTimer (ITH) 69 tt CurrentTime(ITH) 70 ttDiscardUnsentMessages (IT 71 ttEnterMonitor (T) ttExitMonitor(①) 73 ttFetch(①) 74 ttGetData(TH) 75 etMsg(TH) ttGetInitArg(C++ only)(I) 77 ttGetInvoker(H 78 ttGetX (ITH) 79 ttGive(TH) 81 ttInitKernel) 82 ttKillJob(TH) 83 nOw(TH 84 ttlogStart (TH) ttLog Stop(TH) 86 ttLog Value(TH) 87 ttNonPreemptible 1) 88 ttNoSchedule(I) 89 ttNotify (T) ttNotifyAll (TH) 91 ttPost (T) 92 ttRemoveTimer (Th) 93 reTrieve (T) 94 ttSendMsg(TH) 95 ttSetCBSParameters (IT) ·· 6 ttSetData(TI) 97 ttSetKernelParameter (ITH) 98 ttsetNetworkParameter (ITH 99 ttsetNextsegment (TH) 100 ttSetX (ITH) 101 ttSleep (T) ttSleepUntil (T) 104 ttTake (T) 105 ttTry Fetch(TH) 06 ttTryPost(TH) 107 ttWait(r) .,,,,,,,,,,,,,,..,108 15. References 109 6 1。 Introduction This manual describes the use of the Matlab/Simulink-based The Mathworks 2001 simulator TRUETIME, which facilitates Co-Simulation of controller task ex- ecution in real-time kernels, network transmissions, and continuous plant dy- namics. The simulator is presented in [Henriksson et al, 2003; Cervin et al 2003; Henriksson et al., 2002; Andersson et al., 2005 but be aware that several differences from these papers exist The manual describes the fundamental steps in the creation of a TRUETIME sim ulation. This include how to write the code that is executed during simulation how to configure the kernel and network blocks, and what compilation that must be performed to get an executable simulation. The code functions for the tasks and the initialization commands may be written either as C++ functions or as Matlab m-files. and both cases are described Several tutorial examples are provided, treating standard and networked PID control, scheduling, overrun handling, synchronization, control over wireless net- works, mote coordination. wireless ad-hoc routing using aodv. mobile robot soc cer and more The manual also describes some of the internal workings of TRUETIME, including the task model, implementation details, and timing details. The network blocks and the radio model used for the wireless simulations are also presented in some detail. A TRUETIME command reference with detailed explanations of all functionality provided by the simulator is given at the end of the manual For questions and bug reports, please direct these issues to trust imegcontrol,lth, se 2. Getting Started 2.1 Software Requirements TRUE TIME requires Matlab 6. 1(R12. 1)or later with Simulink 4.1 or later A C++ compiler is required to run TRUETIME in the C++ version. For the matlab version, pre-compiled files are provided in the archive that is downloaded from the TrUETIME web site. The following compilers are known to work Visual Studio C++ for Windows g++for Linux 2.2 Installation Download and extract the compressed archive(truetime-2.0. zip), available at the TRUE TIME home page. Extracting the file creates the directory truetime-20 which will be referred to as DIR in the sequel. In order to run true time the environment variable ttkernel, must be defined to point the directory with the TRUe TIme kernel files, DIR/kernel. In later versions of Matlab, this can be done using e.g. the command 7 LIbrary: true tIme 回回风 File Edit view Foma! Help schedule i rigger schedule TrueTime Network True Time Send True Time Receive True Time Kernel schedule 1 schedule True Time Battery True Time wireless True Time Ultrasound Network Truetime 2.0 beta Block Library Copyright(c)2009 Lund University ten by anton Cervin, Dan Herr iksan and Martin Ohin Department of Automatic Control LTH, Lund University Sweden Please direct questions and bug reports to: truetime controlithse Figure 1 The TRUETIME 2.0 beta block library setenv("TTKERNEL', C: \MyFilesitruetime-2O\kernel) In older versions of matlab. the setenv command is not available. so the envi ronment variable must be defined in the operating system Unix/ Linux: export TTKERNEL=$DIR/kernel Windows: use Control Panel/System/ Advanced/ Environment Variables Then add the following lines to your Matlab startup script. This will set up all necessary paths to the TrueTime kernel files addpath( [getenv( TTKERNEL, )J) addpath([ getenv( TTKERNEL’)’/mat1ab/he1p’]) ddpath([ getenv( TTKERNEL’)’/ matlab1) Starting Matlab and issuing the command truetime from the matlab prompt will now open the TRUETTME block library, see Figure 1 2.3 Compilation Since the TRUE TIMe archive contains pre-compiled files, no compilation is required to run truetime with the m-file apl However, TRUETIME also supports simulations written in C++ code, which then must be compiled In this case, you first need to configure your C++ compiler in Matlab. This can be done by issuing the command > mex -setup In the setup, make sure that you change from the matlab default compiler to a proper C++compiler: For more detailed instructions on how to compile individual simulations. see Section 6 in this manual 3. Using the Simulator The TRUE TIME blocks are connected with ordinary Simulink blocks to form a real time control system, see Figure 2. Before a simulation can be run, however, it is necessary to initialize kernel blocks and network blocks, and to create tasks, interrupt handlers, timers, events, monitors, etc for the simulation As mentioned above, the initialization code and the code that is executed during simulation may be written either as Matlab M-files or as C++code(for increased simulation speed). How the code functions are defined and what must be provided during initialization will be described below. It will also be described how the code is compiled to executable Matlab code innle File Edit View Simulation Format Tools Help 回 Band-Limited hite Noise A Unstable Process schedule True Time Kernel Schedule Figure 2 A TRUE TIME Kernel block connected to a continuous plant 4. Writing Code Functions The execution of tasks and interrupt handlers is defined by code functions. A code function is further divided into code segments according to the execution model shown in Figure 3. All execution of user code is done in the beginning of each code segment. The execution time of each segment should be returned by the code function 4.1 Writing a Matlab Code Function The syntax of a Matlab code function implementing a simple P-controller is given by Listing 1 The variable segment determines which segment that should be executed, and data is a user-defined data structure that has been associated with the task when it was created(see tt CreateTask and ttCreatePeriodicTask in the command reference). The data is updated and returned by the code function. The code function also returns the execution time of the executed segment Execution of user code Simulated execution time Figure 3 The execution of user code is modeled by a sequence of segments executed in order by the kernel In this example, the execution time of the first segment is 2 ms. This means that the delay from input to output for this task will be at least 2 ms. However preemption from higher priority tasks may cause the delay to be longer. The second segment returns a negative execution time. This is used to indicate end of execution, i. e that there are no more segments to execute ttAnalogIn and ttAnalogOut are real-time primitives used to read and write signals to the environment. Detailed descriptions of these functions can be found in the command reference at the end of this manual 4.2 Writing a C++ Code function Writing a code function in C++ follows a similar pattern as the code function described in Listing 1. The corresponding C++ syntax for the P-controller code Task Data that contains the control signal u and the controller ga, d tructure function is given in Listing ? We here assume the existence of a data sti 4.3 Calling Simulink Block Diagrams In both the C++ and m-file cases, it is possible to call Simulink block diagrams from within the code functions. This is a convenient way to implement controllers Listing 2 shows an example where the discrete Pi-controller in Figure 4 is used in a code function. See the command reference at the end of this manual for further explanation of the command ttCallBlockSystem Listing 1 Example of a P-controller code function written in Matlab code function Lexectime, data] =ctrl code(segment, data) switch segment case 1 y= ttAnalogIn(1); data u =-dataK y; exectime data exectime ttAnalogOut(1, data. u) exectime =-1 end 【实例截图】
【核心代码】

标签:

实例下载地址

Truetime manual Truetime2.0 使用手册

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警