/*
	relay.c
	
	Works for relay 6 board connected to the BL1200/Little PLC.

	This program performs the following operations.

	1. Reset the PLCBus
	2. Toggle the relays on the XP8300/Relay6 expansion board
	   with address 000.

	Jumper settings.

		Install jumpers on J1 1-2, 3-4, 5-6. (This is the factory default.)	   
*/

main()
{
int i,j,k;

   inport(0xc6);  /* reset the PLCBus */

   for(i=0;i<30000;i++){ j=j; } /* DS1233 requires 350 ms after RST input */

	while(1) {
	   for(k=0; k<14; k++) {
   		delay();
		   j=(2*k) & 0xe |  (( k & 0x8 )!=0);
   		write12data(0x0,j);
   		hitwd();
  		}
	}
}

delay()
{
int k;
	for(k=0; k<4000; k++) hitwd();
}