Recipes4Linux

Engineering Requirements Document for Hypothetical Part Stamping Machine


The hypothetical machine shown diagrammatically in the illustrations is intended to be a grossly simplified illustration of the type of problems which we typically encounter.  The number of air cylinders and sensors which would appear on an actual machine could be at least twenty (20) times the number shown, and this fact should be kept in mind when formulating a scheme for controlling the machine.

The machine shown is designed to continuously stamp parts.  The operation of the machine is as follows:  Cylinder A extends toward the gravity operated part feeder to pick up a part in the receptacle at the end of its shaft.  Cylinder A then retracts and cylinder B extends to push the part out of its receptacle and into the press.  Cylinder B then retracts and cylinder C extends and retracts to stamp the part in the press.  When the next part is pushed into the press,  this part will be pushed out.  The operation can be thought of as two independent "jobs" which may be done in parallel.  The first "job" is the loading of the part into the press which involves the sequential operation of cylinders A and B.  The second "job" is the stamping in the press which is performed by cylinder C.  These two tasks can be performed concurrently; however, the press may not close until cylinder B is withdrawn, and cylinder B may not be inserted into the press until it is opened.

The cylinders are operated pneumatically; specifically, air pressure at one end of the cylinder causes the cylinder to extend, while air pressure at the other end causes the cylinder to retract.  The end at which the air pressure is present is controlled by a solenoid valve controlled by the computer.  The positions of cylinders A-C are governed by whether solenoids a-c are on or off, respectively.  Associated with each cylinder is a pair of positional sensors which detect when the cylinder is fully extended or retracted.  These six (6) sensors, shown as small triangles in the diagram, are defined as follows:

  1. cylinder A retracted (A-IN)
  2. cylinder A extended (A-OUT)
  3. cylinder B retracted (B-IN)
  4. cylinder B extended (B-OUT)
  5. cylinder C retracted (C-IN)
  6. cylinder C extended (C-OUT)

Solenoid d, which is also controlled by the computer, controls whether air pressure is provided to the cylinders or is allowed to escape from the system and leave the cylinders un-pressurized.  Sensor 7 detects whether air pressure is present in the system.  An emergency stop (e-stop) switch is also provided to remove electrical power from the mechanisms.  This also causes the air valve to allow air to escape from the cylinders.  Sensor 8 detects whether the emergency stop switch has been pressed and informs the computer accordingly.

The machine contains two additional components which constitute the operator interface.  A CRT is provided to inform the operator about the state of the machine.  An infrared touch screen is also provided to allow the operator to give instructions to the machine by touching various points on the screen.  Information is displayed on the screen by storing the characters to be displayed in special system memory.  When a point on the screen is touched, the touch screen sends the X and Y coordinates of this point to a UART via an RS-232 serial link.  The UART then interrupts the computer and presents it with each of the coordinates.

One additional source of interrupts exists.  This is a timer which interrupts the computer at some regular interval.

The UART, the sensor inputs, and the outputs to the solenoids all interface to the computer through eight (8) bit I/O ports.  For this illustration, assume that the ports are assigned as follows:

Port Bit Description
0 0 sensor 1 (A-IN)
0 3 sensor 2 (A-OUT)
1 4 sensor 3 (B-IN)
1 6 sensor 4 (B-OUT)
2 2 sensor 5 (C-IN)
2 7 sensor 6 (C-OUT)
3 3 sensor 7 (AIR)
3 5 sensor 8 (E-STOP)
4 0 solenoid a
4 7 solenoid b
5 1 solenoid c
5 3 solenoid d
6 0-7 UART data
7 0-4 UART status

All bits of a given byte would normally be assigned to some input or output; however, in this example only two (2) bits were used from each of the first six (6) ports so that servicing the I/O would require several port references.  This better illustrates the principles involved.  A sensor which is activated causes its particular bit to be a 1, while an inactivated sensor causes its bit to be 0.  Whether or not a sensor is activated is determined by doing a read of its port and masking off all other bits by ANDing with a byte whose only 1 is in the sensor's bit position.  The result will be non-zero if the sensor is activated and zero if the sensor is inactivated.  A solenoid is turned on by setting its bit to 1 and off by setting its bit to 0.  Turning a solenoid on is accomplished by ORing the current contents of the port, which is stored in a status byte in RAM, with a byte whose only 1 is in the solenoid's bit position and writing the result to the port.  This same result is then also written to the status byte for later use.  Turning off a solenoid is accomplished by ANDing the current port contents with a byte whose only 0 is in the solenoid's bit position and writing the results to the port and the status byte.

When the computer receives an interrupt, it checks the UART status port which has a bit set if the UART caused the interrupt.  If the UART caused the interrupt and it is the first coordinate in a pair from the touch screen, the coordinate is stored in a byte used to store the X coordinate.  If the UART caused the interrupt and it is the second coordinate in a pair, the coordinate is stored in a byte used to store the Y coordinate.  If the interrupt was caused by the timer, the computer updates all time counters and checks the e-stop and air pressure sensors.  If the e-stop was hit or there is no air pressure, the machine halts and opens the air valve.  These two interrupt functions must operate normally while the machine is running.

The first "job" would look something like this:

extend cylinder A
while sensor 2 not on
    if elapsed time too long
       display A not extended error


retract cylinder A
while sensor 1 not on
    if elapsed time too long
        display A not retracted error


while sensor 5 not on
    do nothing


extend cylinder B
while sensor 4 not on
    if elapsed time too long
        display cylinder B not extended error


retract cylinder B
while sensor 3 not on
    if elapsed time too long
        display B not retracted error

The second job would look something like this:

while no part has been placed in press
    do nothing


extend cylinder C
while sensor 6 not on
    if elapsed time too long
        display C not extended error


retract cylinder C
while sensor 5 not on
    if elapsed time too long
        display C not retracted error

These two "jobs" should be executed simultaneously.  In order to keep the machine cycle time as small as possible, it is important that the interval between the time a sensor changes state and the time that computer actually recognized the change is as short as possible.  Another important point is that while one "job" is waiting for a change, the computer should spend essentially no time looping in that "job" while there is something to be done in the other "job".


Contact mailto:tmiket@recipes4linux.com

Copyright © 2004 Tools Made Tough