Herunterladen Inhalt Inhalt Diese Seite drucken

Pepperl+Fuchs VAM-CTR-PC2 Handbuch Seite 40

Inhaltsverzeichnis

Werbung

do
/* loop until normal operation mode flag gets high */
{
Index(D_EC_FLAGS);
Read(flags);
/* end program after 2 seconds timeout*/
if(2 < difftime(time(NULL),timer))
{
printf ("can't start normal operation.");
return;
}
}while (0x00 == (flags & 0x20));
/* write projected parameter (PP) to parameter image (PI) */
/* AS-i PC2 board writes PI list only after power up! */
Page(D_PI);
Index(D_PI);
for(i=0 ; i<sizeof(pp) ; i++)
Write( pp[i] );
/* initialize watchdog */
Page(D_WDOG_CNT);
Index(D_WDOG_CNT);
Write(0x0a);
Page(D_WDOG_ENA);
Index(D_WDOG_ENA);
Write(0x01);
/* communication for ever */
do
{
/* reload watchdog counter with 100 ms */
Page(D_WDOG_CNT);
Index(D_WDOG_CNT); /* index register will be incremented */
Write(0x0a);
/* read input data from DPRAM */
for(i=0;i<sizeof(idata);i++)
Read( idata[i] );
/* read execution control flags from DPRAM */
Read(flags);
/* copy sensor bit of slave 1 to bit 0 of slave 2 */
odata[1] = idata[0] & 0x10; /* mask sensor bit of sl.1 */
odata[1] = odata[1] >> 4;
odata[1] = ~odata[1];
/* write output data to DPRAM */
for(i=0;i<sizeof(odata);i++)
Write( odata[i] );
/* print data to screen ("shift-" and "AND-operation" */
/* necessary for right placing on screen!) */
printf("input data (slave 1) = %1x
printf("output data (slave 2)= %1x
/* print "config OK" or "config err" to screen */
if( 0x00 == (flags & 0x01) )
printf("config err...\r");
else
{
Zumutbare Änderungen aufgrund technischer Verbesserungen vorbehalten.
40
Pepperl+Fuchs GmbH · 68301 Mannheim · Telefon (06 21) 7 76-11 11 · Telefax (06 21) 7 76-10 00 · Internet http://www.pepperl-fuchs.com
/* load watchdog counter with 100 ms */
/* enable watchdog */
/* after every read or write access! */
/* shift from sl.3 to sl.2 */
/* bitwise negation */
", idata[0]>>4);
", odata[1]&0x0f);
/* mask config flag */
AS-Interface
Anhang
Copyright Pepperl+Fuchs, Printed in Germany

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis