•
/*=============================================
IPOS-source file
===============================================*/
#include <const.h>
// Help for the predefined structures with
// F1
GSPODATA10 Po10;
SSPIDATA10 Pi10;
SSPOSSPEED Speed;
SSPOSRAMP Ramp;
long Pos32;
/*=============================================
Main function (IPOS entry function)
===============================================*/
main()
{
/*-------------------------------------
Technische handleiding veldbuscommunicatie DFO11A CANopen
Positionering met vijf procesdata
Het volgende IPOS-programma moet met de IPOSPLUS
in de regelaar geladen en gestart worden:
Initialization
--------------------------------------*/
// Process output words are transmitted on
// fieldbus(3)
Po10.BusType = 3;
// 5 process output words are coming in and
// 5 process input words are transmitted again
Po10.Len
= 5;
Pi10.Len
= 5;
/*-------------------------------------
Main program loop
--------------------------------------*/
while(1)
{
// first fetch the process output words
// from the input buffer
_GetSys( Po10, GS_PODATA );
// Process data no. 1 is the control word and
// configured by shell menu item 870
// ( 870 = CONTROLWORD1)
// Process data no. 2 is the target position Hi
// (TargetPos is defined in const.h)
Pos32 = Po10.PO2 << 16;
// Process data no. 3 is the target position Lo
// (TargetPos is defined in const.h)
Pos32 += Po10.PO3;
// Process data no. 4 is the
// positioning speed left and right
// to be converted from 0.2 rpm => 0.1 rpm precision
Speed.CW
= Po10.PO4 * 2;
Speed.CCW
= Po10.PO4 * 2;
_SetSys(SS_POSSPEED, Speed);
®
-compiler gecompileerd,
4
29