EasyManua.ls Logo

SEW-Eurodrive IPOS plus - Clearing Bits and Output Terminals

SEW-Eurodrive IPOS plus
384 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...
Manual – IPOSplus®
247
18
Clearing bits and output terminals
Compiler – Examples
18.2 Clearing bits and output terminals
There are two ways to clear individual bits in variables:
1. The _BitClear ( Hx, y ) function clears bit y in variable x.
2. The bit-by-bit AND operation Hx & K sets those bits in variable x to one that are also
set to one in constant K.
In both cases, the legibility of the program can be improved if the bit position or the con-
stant is defined symbolically. Bit clearing functions are mainly used to reset binary unit
outputs. Therefore, in the following example, variable H481 (StdOutpIPOS) will be used
as the target variable of the operation. Variable H480 (OptOutpIPOS) would be used ac-
cordingly to address the outputs of the option. In the example, the output terminal DO02
of the basic unit is to be set to zero.
If several outputs are to be reset at the same time, then you can either call the
_BitClear() function several times in succession or use the bit-by-bit AND logic opera-
tion. In the second case, one statement will suffice. This reduces the amount of code
and thus also has a positive effect on the program run time.
The following example uses the AND operation to clear DO01 and DO02 at the same
time.
Using the AND operation:
#include <const.h>
#include <io.h> // MOVIDRIVE A
#include <iob.h> // MOVIDRIVE B
main()
{
StdOutpIPOS &= ~DO01 & ~DO02;
}
Using _BitClear() Using the AND operation
#include <const.h>
#include <io.h> // MOVIDRIVE A
#include <iob.h> // MOVIDRIVE B
main()
{
_BitClear( StdOutpIPOS, 2 );
}
#include <const.h>
#include <io.h> // MOVIDRIVE A
#include <iob.h> // MOVIDRIVE B
main()
{
StdOutpIPOS &= ~DO02;
/*The operator "~" causes bit-by-
bit
negation of DO02. Thus all the bits
of DO02 are 1 except for bit 2 */
}
P
i
f
kVA
Hz
n
P
i
f
kVA
Hz
n

Table of Contents