系统架构。
This figure shows that the communication between the main ARM7 processor (ATMEL AT91SAM7S256) and Sensors/Servo Motors is done via the co-processor (ATMEL AVR), except for the Ultrasonic Sensor and acquisition of Servo Motor revolutions. For ECRobot NXT applications, the most important factor to access the Sensors/Servo Motors is the communication with the co-processor via the I2C serial bus. This system architecture definitely influences the software run-time environment of the ECRobot NXT. The main ARM7 processor accesses the Sensors (to read sensor A/D value) and Servo Motors (to set PWM duty ratio) independently every 2 milliseconds through a 1 millisecond periodic Interrupt Service Routine of LEJOS NXJ firmware. Servo Motors revolutions are directly captured by pulse triggered Interrupt Service Routines of the LEJOS NXJ firmware in the main ARM7 processor. The Ultrasonic Sensor has its brain directly communicate with the main ARM7 processor via another I2C communication channel.
除了超声波传感器同伺服电机转动查询外,上图显示主ARM7处理器(ATMEL AT91SAM7S256) 同传感器/步进型马达通过辅助(ATMEL AVR)通讯的示意图。对于ECRobot NXT 的应用,访问传感器/伺服电机的关键要素就是通过I2C串行总线同协处理器通讯。该系统架构一定程度上影响ECRobot NXT软件实时运行环境。在LEJOS NXJ通过1微秒中断轮询模式,主ARM7处理器完成独立的每2毫秒传感器(读A/D值)和伺服电机(设置PWM占空比)。伺服电机的转速直接捕获来自主ARM7处理器的LEJOS NXJ固件上脉冲触发次数。超声波传感器有它的处理器,直接同主ARM7处理器通过另外的I2C通讯通道通讯。
nxtOSEK(TOPPERS/OSEK or TOPPERS/JSP) Rate Monotonic Scheduler:
nxtOSEK(TOPPERS/OSEK或者 TOPPERS/JSP)速率单向调度:
ECRobot NXT generates OSEK/JSP based Rate Monotonic Scheduler.
In the Exported Function-Calls Scheduler block, there is Platform parameter to configure platform software on the NXT. Since Embedded Coder Robot NXT v3.16, TOPPERS/OSEK or TOPPERS/JSP can be configured. In the generated ecrobot_main.c file, there are Tasks definitions and the specified Function-Calls are mapped into the Tasks. Execution timing of each Tasks is configured in the automatically generated RTOS configuration file (TOPPERS/OSEK: ecrobot.oil, TOPPERS/JSP: ecorobot.cfg). From MBD engineer‟s point of view, MBD engineers do not need to take care of what kind of RTOS is used, they just need to consider about execution timing (i.e. initialize, periodical execution) on application level.
ECRobot NXT 生成OSEK/JSP基于单向速率调度器。
在导出函数调度模块中,通过平台参数完成NXT平台软件参数配置。从ECRobot v3.16版本开始TOPPERS/OSEK或者TOPPERS/JSP可以完成配置。
在生成的ecrobot_main.c文件中,产生任务的定义及其任务对应的具体函数调用。在自动代码生成的每个任务执行时间完成配置,生成RTOS配置文件(TOPPERS/OSEK的:ecrobot.oil ,TOPPERS/JSP的:ecrobot.cfg)。从基于模型的工程师的观点,MBD不关心使用什么样的RTOS,在应用级别他们仅需要关心执行的时间段(例如,初始化,轮询执行)。
ECRobot Interface API:
ECRobot接口API:
In the lejos_osek/ecrobot directory,there are ECRobot NXT interface C source files (ecrobot_interface.c, ecrobot_interface.h). These C source files include device APIs that access LEJOS NXJ I/O driver. Most of the published ECRobot Interface APIs have corresponding ECRobot NXT device blocks.
For example, Fcn_10ms C function is generated from Fcn_10ms Function-Call Subsystem in TestMotor.mdl. In Fcn_10ms Function-Call Subsystem there is a Servo Motor Write block, and a corresponding published device API is implemented in the Fcn_10ms C function. This device API is implemented by using a custom Simulink Signal Object which is called NXT.Signal.
在lejos_osek/ecrobot目录中,有ECRobot NXT接口C源文件(ecrobot_interface.c,ecrobot_interface.h)。这些C源文件包括访问的LeJOS NXJ I / O设备的驱动API。在大多数公布ECRobot接口API对应ECRobot NXT设备模块。
例如,TestMotor.mdl中Fcn_10ms函数调用子系统的产生Fcn_10ms的C函数。在Fcn_10ms的函数调用子系统有伺服电机写块,并由对应设备API在Fcn_10ms C函数实现。该设备的API实现使用自定义的Simulink信号对象被称为NXT.Signal。