252
Manual – IPOSplus®
18
Value of a number
Compiler – Examples
18.5 Value of a number
The following sample program demonstrates how the IPOS
plus®
Compiler can be used
to create the absolute value of a number.
In task 1 a revision program is running that moves the drive relatively 400000 increments
CW and 400000 increments CCW.
In task 2 the actual speed is read and the amount of the actual speed is created. The
amount is stored in the variable
lActSpeedAbsolute
.
#include <constb.h> // MOVIDRIVE A
#include <iob.h> // MOVIDRIVE B
#define SEKUNDE 1000
SSPOSSPEED tSpeed;
long lActSpeed, lActSpeedAbsolute;
/*===================================
Task 2
===================================*/
Task2()
{
_GetSys( lActSpeed,GS_ACTSPEED );
// Calculate absolute speed value
if( lActSpeed < 0 )
lActSpeedAbsolute = -lActSpeed;
else
lActSpeedAbsolute = lActSpeed;
}
main()
{
// Initialization =================
// Positioning speed 500 rpm
tSpeed.CW = tSpeed.CCW = 5000;
_SetSys( SS_POSSPEED,tSpeed );
// Activate Task 2
_SetTask2( T2_START,Task2 );
// Main program loop ==============
while(1)
{
_GoRel( GO_WAIT,400000 );
_Wait( SEKUNDE );
_GoRel( GO_WAIT,-400000 );
_Wait( SEKUNDE );
}
}
P
i
f
kVA
Hz
n
P
i
f
kVA
Hz
n