VMUX
Programming Example

     An ASCII text versiion of this page is available here

   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<NUM_MONS; i++) {        /* do for each output ..... */
      (void)biosprint(0, 1, 0);       /*   output a binary 1  */
      (void)biosprint(0, 0, 0);       /*   output a binary 0  */
      (void)biosprint(0, 0, 0);       /*   output a binary 0  */
      (void)biosprint(0, 1, 0);       /*   output a binary 1  */
   }                                  /* 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  */
}
 
 
/*************************************************************/

 
/* this routine sends out the control stream to the switcher */
/*  it is run any time you want to re-patch the switcher     */

void Set_Vmux(void)
{
   int i;

   while(~inportb(PAR_CTL1) & 0x80) ; /* wait for the 'BUSY' bit on the */
                                      /*   parallel port to clear */
   for(i=NUM_MONS-1; 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  */
}
 
/*************************************************************/

 

Home - What's New - Products - Support -Tutorials
Books - Gallery - History - Contact Us
Copyright 2016 Dave Jones Design
All images and text on these and connected pages are copyrighted with all rights reserved and are not in the public domain