EasyManua.ls Logo

NANOTEC PD4-C - Page 96

Default Icon
256 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
8 Programming with NanoJ
Note
If the NanoJ program does not yield the computing time after too long a time, it is ended by the
operating system. In this case, the number 4 is entered in the statusword for object 2301
h
; in the
error register for object 2302
h
, the number 5 (timeout) is noted, see 2301h NanoJ Status and 2302h
NanoJ Error Code.
8.1.2 Sandbox
Using processor-specific features, a so-called sandbox is generated. When used in the sandbox, a user
program can only access specially assigned memory areas and system resources. For example, an attempt
to directly write to a processor IO register is acknowledged with an MPU Fault and the user program
terminated with the corresponding error code in the object dictionary.
8.1.3 NanoJ program – communication possibilities
A NanoJ program has a number of possibilities for communicating with the controller:
Read and write OD values using PDO mapping
Directly read and write OD values using system calls
Call other system calls (e.g., write debug output)
The OD values of the user program are made available in the form of variables via PDO mapping. Before
a user program receives the 1 ms time slot, the firmware transfers the values from the object dictionary to
the variables of the user program. As soon as the user program receives computing time, it can manipulate
these variables as regular C variables. At the end of the time slot, the new values are then automatically
copied by the firmware back to the respective OD entries.
To optimize the performance, three types of mapping are defined: input, output, and input/output (In, Out,
InOut).
Input mappings can only be read; they are not transferred back to the object dictionary.
Output mappings can only be written.
Input/output mappings, on the other hand, can both be read and written.
The set mappings can be read and checked via the GUI for objects 2310
h
, 2320
h
, and 2330
h
. Up to 16
entries are allowed for each mapping.
Whether a variable is stored in the input, output or data range is controlled in NanoJEasy via the
specification of the linker section.
8.1.4 Executing a NanoJ program
When executing a cycle, the NanoJ program essentially consists of the following three steps with respect to
the PDO mapping:
1. Read values from the object dictionary and copy them to the input and output areas
2. Execute a user program
3. Copy values from the output and input areas back to the object dictionary
The configuration of the copy processes is based on the CANopen standard.
In addition, values of the object dictionary can be accessed via system calls. This is generally slower;
mappings are therefore to be preferred. The number of mappings is limited (16 entries each in In/Out/InOut).
Tip
Nanotec recommends: Map OD entries that are used and changed frequently and use system calls
to access OD entries that are used less frequently.
A list of available system calls can be found in chapter System calls in a NanoJ program.
Version: 2.0.1 / FIR-v1650 96

Table of Contents