Dave Jones Design 87 Chestnut St., Owego, NY 13827 USA phone: (607) 687-5740 fax: (607) 687-5898 e-mail: mail@djdesign.com web: www.djdesign.com ================================================= VMUX Programming example ---- ------------------- This example is for an 8 output VMUX series swicher. It was written in Borland Turbo C on a PC platform for use under MS-DOS. Similar output routines would have to be written for other computers. The 2 library routines used in the example that would have to be replaced in another computer or another compiler are: inportb(port) - this reads a hardware I/O port. In this example it is used to read the parallel port's status byte to find the state of the 'BUSY' signal. biosprint() - this is used to send a byte of data to the parallel port. Besides setting the output data bits of the port, it also toggles the 'STROBE' signal on the parallel port to transfer the data into the switcher. Most printer output routines do this automatically. If you set the data bits on the parallel port directly then you will also have to toggle the 'STROBE' bit yourself. /*---------------------------------------------------------*/ /*---------------------------------------------------------*/ #define NUM_MONS 8 /* the number of outputs in this switcher */ #define PAR_CTL1 0x379 /* hardware I/O port for parallel status */ char switdat[NUM_MONS]; /* an array to hold the data for the patch */ /* switdat[0] is output 1 */ /* each byte has a value of 0-7 */ /* representing inputs 1-8*/ /*---------------------------------------------------------*/ /* this routine sends out the initialization stream to the switcher */ /* it is run once, usually at the very beginning of the program */ void Init_Vmux(void) { int i; while(~inportb(PAR_CTL1) & 0x80) ; /* wait for the 'BUSY' bit on the */ /* parallel port to clear. */ for(i=0; i=0; i--) { /* for each output .... */ (void)biosprint(0, 0, 0); /* output a binary 0 */ (void)biosprint(0, (switdat[i]>>2) & 1, 0); /* output bit 2 of data */ (void)biosprint(0, (switdat[i]>>1) & 1, 0); /* output bit 1 of data */ (void)biosprint(0, switdat[i] & 1, 0); /* output bit 0 of data */ } /* then finish with ..... */ (void)biosprint(0, 1, 0); /* output a binary 1 */ (void)biosprint(0, 0, 0); /* output a binary 0 */ (void)biosprint(0, 3, 0); /* output a binary 3 */ }