![NANOTEC PD4-C5918M4204-E-01 Manual Download Page 79](http://html1.mh-extra.com/html/nanotec/pd4-c5918m4204-e-01/pd4-c5918m4204-e-01_manual_3241520079.webp)
Manual PD4-C (USB)
11 Programming with NanoJ
Version: 1.4.1 / 22.07.2016 / FIR-v1626
79
The data type of the variable, i.e. U32, U16, U08, S32, S16 or S08.
•
<NAME>
The name of the variable that is later used in the user program.
•
<input|output|inout>
The write and read authorization of a variable: A variable can either be declared as input, output, or
inout. This defines whether a variable is readable (input), writable (output) or both (inout) and the
structure by which it needs to be addressed in the program.
•
<INDEX>:<SUBINDEX>
Index and sub-index of the object being mapped in the object directory.
Every declared variable is addressed in the user program via one of the three structures "In", "Out",, or
"InOut", depending on the defined write and read direction.
Example of a mapping
Example of a mapping and the associated variable access methods:
map U16 controlWord as output 0x6040:00
map U08 statusWord as input 0x6041:00
map U08 modeOfOperation as inout 0x6060:00
#include "wrapper.h"
void user() {
[...]
Out.controlWord = 1;
U08 tmpVar = In.statusword;
InOut.modeOfOperation = tmpVar; [...]
}
Potential error source
A potential source of error is a write access by means of the
od_write()
function on an object in the
object directory that was also created as a mapping. The code shown below is faulty:
map U16 controlWord as output 0x6040:00
#include " wrapper.h"
void user() {
[...]
Out.controlWord = 1;
[...]
// the value is overwritten by the mapping
od_write(0x6040, 0x00, 5 );
[...]
}
The line with the command
od_write(0x6040, 0x00, 5 );
is without effect. As described in the
introduction, all mappings are copied into the object directory at the end of each millisecond.
The following procedure is therefore derived:
•
The function
od_write
writes the value "5" in object 6040
:00
h
.
•
At the end of the 1-ms cycle, the mapping is written that also specifies object 6040
h
:00
h
, though
with the value "1".
•
This means - from the user's perspective - the
od_write
command is without effect.