HOME(DOCS)		Optical Printer Control System		HOME(DOCS)

NAME
    home - motor homing standalone program

OPTIONS
    -v    # verbose mode for debugging changes
    -d    # debug mode
    -h    # help

USAGE
    home [name-of-procedure] ..

EXAMPLES
    home             # home all axes defined in 'default' procedure
    home a b c       # call procedures 'a', 'b' and 'c'

DESCRIPTION
    'home' is an external .EXE command that runs in DOS, but can be
    easily available within OPCS by adding 'doscmd home' to OPCSDEFS.OPC.

    'home' is part of the OPCS system, and is used to home the camera,
    projector, fader, and motion control axes. It can set bits, check
    for hardware conditions, etc.

    'home' has a simple command language that lets one run motors until
    the status bit of home sensors change, and there's also logical
    if() conditions that can be used to check hardware bits.

DEFINING HOMING PROCEDURES
    Homing procedures are defined this way:
        
	start foo
	{
	    commands..
	}
	end foo
        
    ..where 'foo' can be any word or letter that is used to call
    the procedure, and can be invoked from the command line as:

        home foo

    In the case of setting up homing procedures for channels,
    the procedure names are the channel letter, e.g.:
        
        start a
	{
	    print AERIAL HOME

	    # ..code to handle homing the aerial projector..
	}
	end a
        
    ..so to home the 'a' channel, one just executes:

        home a

    The names used for 'start' and 'end' are whatever you want.
    By convention, channel letters are used for defining procedures
    for homing those channels. You can also define your own procedures
    for doing other things, like homing wedge wheels, and other such
    things that the OPCSDEFS.OPC file can't do.

    The homedefs.hom file has two special procedures:
        
        start always
	{
	        # commands that always execute, and are executed *first*;
	}
	end always

	start default
	{
		# Commands to execute if user just typed
		# 'home' without any command line arguments.
	}
	end default
        
    When you run 'home' without arguments, the 'default' procedure
    in the homedefs.hom file is executed. So it's common to have
    that procedure home all the motors, e.g.

	start default
	{
	    call a     # home aerial (if there is one)
	    call b     # home main
	    call c     # home camera
	    call d     # home fader
	}
	end default

COMMANDS
    Home commands are put into the homedefs.hom file, enclosed 
    in procedures. Here's a list of all the home commands:

     call [proc]                 # Call named procedure
   clrbit [port] [bitmask]       # Clear port bit by OR/XORing [bitmask]
   cswait [centisecs]            # Wait so many centiseconds
      end [label]                # Declare the end of a procedure
     exit [code]                 # Exit with an error code
    fail?  { commands }          # Run { cmds } if gohome/gochange cmd failed
       go [chan] [dist] [spd]    # Send a motor some distance
 gochange [chan] [maxdist] [spd] # Run until home sensor changes state
   gohome [chan] [maxdist] [spd] # Home a motor
     goto [label]                # goto a label within proc (label-name:)
 homeport [chan] [port] [mask] [test] # Define port to test for home condition
  ishome? [chan] { cmds }        # Is a channel at its home position?
  istrip? [chan] { cmds }        # Is a chan's trip switch is tripped?
kuperbase [port]                 # kuper port base [default=0x300]
 nothome? [chan] { cmds }        # Is chan NOT at its home position?
  notrip? [chan] { cmds }        # Is a chan's trip switch NOT tripped?
  outport  [port] [bytevalue]    # Write a byte to a port
    pass?  { commands }          # Run { cmds } if go/gohome/gochange passed
 portset? [port] [mask] { cmds } # Check if port bit set
 portclr? [port] [mask] { cmds } # Check if port bit clear
    print [string]               # Prints a message to the screen
printport [port]                 # Print the value at a port in hex
      pse                        # Wait for a keypress from the user
    reset [chan] [value]         # Reset counter for [chan] to [value]
   setbit [port] [bitmask]       # Set port bit by ORing [bitmask]
    start [label]                # Declare the beginning of a procedure
		(NOTE: lable name 'always' defines a procedure ALWAYS parsed)
   system [command]              # Execute a DOS command
 tripport [chan] [port] [mask] [test] # Define port to test for trip condition
   xorbit [port] [bitmask]       # Invert port bit by XORing [bitmask]
♀
ENVIRONMENT VARIABLES

    OPCSDEBUG - if set to '1', 'home' will dump the velocity arrays
                to stdout after the motors have moved. The output 
		can be redirected to a file for better inspection.

		The 16 bit velocity values printed are 16 bit words
		of the form:

                               0 x 0 8 1 0                  <-- hex
                                   - - - -
                        ___________| | | |___________
                       |          ___| |___          |
                       |         |         |         |
                    0 0 0 0   1 0 0 0   0 0 0 1   0 0 0 0   <-- binary
                    | | | |   | \_______________________/
                    | | | |   |          Speed (11 bits)
		    | | | |   |
		    | | | |   Direction bit
		    | | | |
		    | | | Full Rotation (counter)
		    | | |
		    | | Soft Reverse
		    | |
		    | Allstop check bit
		    |
		    Full Stop (last velocity in array)

	         The lower 12 bits (dir + speed) are sent directly
		 to the Kuper card. The upper 4 bits are interpreted
		 by the 'mdrive' resident driver code.

EXAMPLE HOMEDEFS.HOM FILE

    ####################################################################
    # HOME PROGRAM'S DEFINITIONS FILE
    # This file contains commands particular only to the 'home' program.
    # 'home' is a standalone program that can move the motors, and watch
    # for changes in the home sensors.
    ####################################################################

    # DEFINE PORTS FOR THE USER'S INSTALLATION

    start always	# THESE COMMANDS *ALWAYS* PARSED
    {
	### HOME SENSORS
	homeport a 0000 00 00	homeport e 0000 00 00	homeport i 0000 00 00
	homeport b 0000 00 00	homeport f 0000 00 00	homeport j 0000 00 00
	homeport c 0000 00 00	homeport g 0000 00 00	homeport k 0000 00 00
	homeport d 0000 00 00	homeport h 0000 00 00	homeport l 0000 00 00

	### TRIP SWITCHES
	tripport a 0000 00 01	tripport e 0000 00 01	tripport i 0000 00 01
	tripport b 0000 00 01	tripport f 0000 00 01	tripport j 0000 00 01
	tripport c 0000 00 01	tripport g 0000 00 01	tripport k 0000 00 01
	tripport d 0000 00 01	tripport h 0000 00 01	tripport l 0000 00 01
    }
    end always

    start b
    {
	print -n   MAIN: 
	ishome? b
	{
	    print -n RUNOUT FROM HOME - 
	    go b -100 .2
	    ishome? b
	    {
		print
		print *** Cant run out of home position! (are motors off?)
		exit 1
	    }
	    cswait 20
	}
	print -n SEEKING HOME - 
	gohome b 200 .2
	fail? 
	{
	    print -n SEEK HOME IN REV DIR - 
	    go b -300 .2		# (arrive at home from same direction)
	    gohome b 400 .2
	    fail?
	    {
		print
		print *** Cant find home position! (are motors off?)
		exit 1
	    }
	}
	print DONE.
    }
    end b

    start c
    {
	print -n CAMERA: 
	ishome? c
	{
	    print -n RUNOUT FROM HOME - 
	    go c -100 .2
	    ishome? c
	    {
		print
		print *** Cant run out of home position! (are motors off?)
		exit 1
	    }
	    cswait 20
	}
	print -n SEEKING HOME - 
	gohome c 200 .2
	fail? 
	{
	    print -n SEEK HOME IN REV DIR - 
	    go c -300 .2		# (arrive at home from same direction)
	    gohome c 400 .2
	    fail?
	    {
		print
		print *** Cant find home position! (are motors off?)
		exit 1
	    }
	}
	print DONE.
    }
    end c

    start d
    {
	print -n  FADER: 
	ishome? d
	{
	    print -n RUNOUT FROM HOME - 
	    go d 3000 .11
	    ishome? d
	    {
		print
		print *** Cant run out of home position! (are motors off?)
		exit 1
	    }
	    cswait 20
	}
	print -n SEEKING HOME -
	gohome d -11450 .11
	fail?
	{
	    print
	    print *** Cant find home position! (are motors off?)
	    exit 1
	}
	cswait 10
	go d -1950 .11
	print  DONE.
    }
    end d

    # USED BY JOG(OPCS)
    start deenergize
    {
	print *** HOMEDEFS.HOM: No 'deenergize' target defined.
    }
    end deenergize

    exit 0


ORIGIN
    Gregory Ercolano, Topanga, California 05/12/00
© Copyright 1997 Greg Ercolano. All rights reserved.