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 (K2.20/TC):

   baseaddr [port]                 # Kuper/A800 base address [0300 default]
       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] # 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?
   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
        ppr [chan] [value]         # Pulses per revolution
      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]
sampspersec [val]                  # Vel samples per second:
				   # RTMC=120.0, A800=107.0, A800(REVB)=120.0
     setbit [port] [bitmask]       # Set port bit by ORing [bitmask]
      start [label]                # Declare beginning of a procedure
		(NOTE: label name 'always' defines procedure ALWAYS parsed)
     system [command]              # Execute a DOS command
   tripport [chan] [port] [mask] [test] # 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 a
{
    print
    print AERIAL: (NOT YET IMPLEMENTED)
#    print -n AERIAL: 
#    ishome? a
#    {
#        print -n RUNOUT FROM HOME - 
#       go a -500 .2
#       ishome? a
#       {
#           print
#           print *** Cant run out of home position! (are motors off?)
#           exit 1
#       }
#       cswait 20
#    }
#    print -n SEEKING HOME - 
#    gohome a 1000 .2
#    fail? 
#    {
#        print -n SEEK HOME IN REV DIR - 
#       go a -1500 .2           # (arrive at home from same direction)
#       # cswait 50
#       gohome a 2000 .4
#       # cswait 50
#       fail?
#       {
#           print
#           print *** Cant find home position! (are motors off?)
#           exit 1
#       }
#    }
#    print DONE.
}
end a

start b
{
    print -n   MAIN: 
    ishome? b
    {
        print -n RUNOUT FROM HOME - 
        go b -500 .4
        ishome? b
        {
            print
            print *** Cant run out of home position! (are motors off?)
            exit 1
        }
        cswait 20
    }
    print -n SEEKING HOME - 
    gohome b 1000 .4
    fail? 
    {
        print -n SEEK HOME IN REV DIR - 
        # cswait 50
        go b -1500 .4   # (arrive at home from same direction)
        # cswait 50
        gohome b 2000 .4
        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 -500 .4
        ishome? c
        {
            print
            print *** Cant run out of home position! (are motors off?)
            exit 1
        }
        cswait 20
    }
    print -n SEEKING HOME - 
    gohome c 1000 .4
    fail? 
    {
        print -n SEEK HOME IN REV DIR - 
        # cswait 50
        go c -1500 .4   # (arrive at home from same direction)
        # cswait 50
        gohome c 2000 .4
        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 1500 .11
        ishome? d
        {
            print
            print *** Cant run out of home position! (are motors off?)
            exit 1
        }
        cswait 20
    }
    print -n SEEKING HOME -
    # cswait 50
    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

# EXAMPLE OF INITIALIZING A LINEAR AXIS
#    Change the X to a channel letter.
#
start X
{
    print -n  CAM ZOOM: 
    ishome? X
    {
        print -n MOVE OFF, 
        gochange X -100000 .25
        ishome? X
        {
            print
            print *** Cant find home! (are motors off?)
            exit 1
        }
        # GO A LITTLE FURTHER IN SAME DIRECTION
        go X -400 .25
        cswait 20
    }
    print -n MOVE TOWARD EDGE, 
    gochange X 100000 .25
    print DONE.
}
end X

# 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.