![NANOTEC PD4-C5918M4204-E-01 Скачать руководство пользователя страница 75](http://html1.mh-extra.com/html/nanotec/pd4-c5918m4204-e-01/pd4-c5918m4204-e-01_manual_3241520075.webp)
Manual PD4-C (USB)
11 Programming with NanoJ
Version: 1.4.1 / 22.07.2016 / FIR-v1626
75
11 Programming with NanoJ
11.1 Introduction
The VMM (Virtual Machine Monitor) is a protected execution environment within the firmware. The user
can load his or her own programs ("User Program") in this environment via USB . These can trigger
functions in the motor controller, for example by reading or writing entries in the object directory.
The use of protective mechanisms makes it impossible for the user programs to cause the actual
firmware to crash. In the worst case, the user program alone is aborted with an error code stored in the
object directory.
Once loaded on the controller, the user program will start autocratically after power up or restart of the
controller.
11.2 Available computing time
A user program receives computing time in a 1-ms cycle (see also the following diagram). Because the
firmware loses computing time due to interrupts and system functions, only about 30% - 50% of this
time is available to the user program (depending on the operating mode and application case). During
this time, the user program must have completed its operations and must either have closed or have
yielded the computing time with the
yield()
function. In the first case, the user program is started
again when the next 1-ms cycle begins; in the second case, the program is continued at the command
following the
yield()
in the next 1-ms cycle.
t in ms
3
2
1
0
Idle
VMM
Operating
Read inputs
Write outputs
system
If the system detects that the user program requires more than the time assigned to it, it is closed and
an error code is entered in the object directory. When developing user programs, therefore, the runtime
behavior of the program must be carefully checked, especially in the case of time-intensive tasks.
Therefore, it is advisable to use tables, instead of calculating a sinus value from a
sin
function.
Note
If the NanoJ program should not return the computing time for an excessive time, it is ended by the
operating system. In this case, the number "4" is entered in the status word at object 2301
of the
VMM; the number "5" (timeout) is noted in the VMM error register at object 2302
.
11.3 Interaction of the user program with the motor controller
11.3.1 Communication options
A user program has numerous options for communicating with the motor controller:
•
Reading and writing of object dictionary values per PDO mapping