TRIPSWITCH(OPCSDEFS) Optical Printer Control System TRIPSWITCH(OPCSDEFS) NAME tripswitch - configure tripswitches for axes USAGE tripswitch [port] [mask] [test] [0] # (all values in HEX!) EXAMPLES tripswitch 0000 00 00 0 # disable all trip switch detection tripswitch 03bd 40 00 0 # LPT1 pin 10, HI bit detects condition tripswitch 03bd 40 40 0 # LPT1 pin 10, LO bit detects condition DESCRIPTION Tripswitches are set up to stop motion control moves (FEED, GO, etc) if an axis is about to go off its track. When a trip occurs, the software will stop the motors and indicate a trip error: ** TRIP SWITCH ERROR - AXIS WENT TOO FAR ** RETURN to continue, or SPACEBAR to ABORT: Sensors should be wired so that a light by the trip switch indicates which trip switch was activated, so the problem can be corrected. A trip condition will occur only when any switch changes from its normal state to its trip state. A trip condition will NOT occur when the switch changes back to its normal state. This allows the operator to back the motor off after a trip occurred, without causing reoccuring trip errors. [port] is the port number in the range 0000-03ff. If [port] is 0000, no trip switch checking is done. [mask] is applied to the value received from the port whenever the software is checking for a trip switch condition. This is applied before comparing to [test]. [test] is compared to the value read from the port after [mask] is applied. If the result is the same as [test], a trip condition will occur. [0] is always zero. WIRING CONSIDERATIONS Normally you would use an optically isolated interface card for the buckle and viewer switches, e.g. PIO-100(DOCS). If directly connecting switches to the parallel port, it is recommended you use a separate, dedicated 5 volt power supply wired through the switches in such a way that when the sensing switch is tripped, +5 volts is passed to the computer. Such a supply can be a store-bought 12 VDC transformer, with an added 7805 5 volt regulator. Note that if you use an unregulated supply (ie. a transformer without the 7805), the voltage output can vary according to the AC power from the wall, which normally varies plus or minus 10 percent, causing a wide margin of possible voltages to the computer's sensing input, which really wants either +5 or ground, and nothing else. As with any signal going to the sensing input on a computer, the signal should never be open..the signal must pull either 5 volts or ground for a TRUE or FALSE condition. An open input is more like a radio antenna that will register both TRUE AND FALSE conditions randomly, causing spurious sensing errors. To further prevent noise problems, use sheilded wire for the sensing signals, and ground the shield ONLY at the power supply end. Do NOT use the sheild as a ground return for the computer..use a separate conductor for signal ground. Keep wire lengths as short as possible. If noise problems persist, and you have ruled out a problem with the computer, it may be that the wire is simply too long for such a low voltage signal. You may want to use a higher voltage (12 volts) in the switch circuitry to drive an optoisolator close to the computer, using the optoisolator to switch 5 volt signals to the parallel port. You can find the base port value for the parallel ports from the operating system using the DOS 'debug' utility: C>debug # run 'debug' -d40:8 f # enter this (not the '-') 0040:0008 BC 03 78 03 00 00 00 00 # debug spits this out -q ----- ----- # type 'q' to quit debug | | | LPT #2's port base address | LPT #1's port base address Your machine may show different values. In the case above, 03BC is the base port value for LPT1..note the bytes are in reverse order in typical LSB/MSB fashion. See the PARALLEL() man page which shows the pin out and port addresses of the IBM PC's parallel ports. The following shows an example of how to wire the trip switches. AT THE PARALLEL CONNECTOR ------------------------- Using a shielded 2 conductor cable, wire the dark conductor to the computer's parallel port input bit. Then run a 400 ohm resistor from the input pin to one of the GND pins (a pull down configuration). Wire the light conductor to the +5 volt supply. Ground the shield AND the +5 volt supply's ground to all of the parallel port's ground pins (18-25). AT EACH SPDT TRIP SWITCH ------------------------ Throughout the wire, you can drop in single pole dual terminal micro switches. Wire the switch's Normally Open (NO) terminal to the dark conductor that goes to the computer. Wire the switch's Common (C) to the light conductor (+5). Wire an LED such that the negative input is to the Normally Closed (NC) terminal, and the positive input is connected to C terminal along with the light conductor (+5). Now tie a 400 ohm resistor from the NC terminal to the shield (ground). Once wired, the input to the computer will be normally grounded (through the 400 ohm resistor at the connector). All the LEDs will be dark, because they are seeing 5 volts across their terminals, and 5 volts will leak through the associated 400 ohm resistor. If a switch is tripped, 5 volts is brought to the computer's input. The switch's LED will light because now ground is supplied to its negative terminal through the 400 ohm resistor, since NC is no longer shorted to +5 by the switch. Set up the OPCSDEFS.OPC file to contain a tripswitch command with the appropriate port and bit information. Then enter the software and run one of the positional axes. If a trip condition occurs only when the switch is RELEASED (instead of pressed), you dont have to change the wiring of the switches..just change the [test] value. EXAMPLE: tripswitch 03bd 40 40 0 # If this doesn't work... tripswitch 03bd 40 00 0 # Try this, or vice-versa. -- If you find that it does not matter whether a switch is pressed or not, then the port and/or mask bits may be wrong. You can use the 'PARALLEL.EXE' utility to monitor a parallel port's pins, so you can see which bit is actually changing when you press a trip switch. When executing 'parallel' from DOS, you can specify which port you want to monitor: parallel 1 # This will monitor LPT1 parallel 2 # This will monitor LPT2 SEE ALSO DEENERGIZE(OPCSDEFS) - define port/bit to deenergize motors ALLSTOP(OPDSDEFS) - define port/bit to detect the allstop key BUCKLE(OPCSDEFS) - define port/bit to detect film buckles VIEWER(OPCSDEFS) - define port/bit to detect viewer open TRIPSWITCH(OPCSDEFS) - define port/bit to detect trip switches SETBIT(OPCSDEFS) - set bit(s) on a port CLRBIT(OPCSDEFS) - clear bit(s) on a port XORBIT(OPCSDEFS) - invert bit(s) on a port PARALLEL(BIOS) - parallel port pinout with port/bit masks ORIGIN Gregory Ercolano, Los Feliz California 10/11/90