Warning - this message is almost 200 lines long.

Dear Anyone:

I have a project that requires about 30 I/O lines, and would like to
multiplex the I/Os of the basic stamp. The project has to be very
small, and I would like to use small outline ICs as much as possible.
One IC I would like to use is the 74HC595 (8 bit shift reg. w/ output
latch).

74HC595 SIMPLIFIED SCHEMATIC:

              /----\/----\                               /----------
              |  74HC595 |                               |  BASIC
    <--OUT2---|QB     VCC|---VCC                         |  STAMP
    <--OUT3---|QC      QA|---OUT1-->                     |
    <--OUT4---|QD     SER|-------------------------------|PIN0 data
    <--OUT5---|QE      /G|---GND                         |
    <--OUT6---|QF    RCLK|------------(TO EACH 'RCLK')---|PIN2 stb
    <--OUT7---|QG    SCLK|------------(TO EACH 'SCLK')---|PIN1 clk
    <--OUT8---|QH   /SCLR|---VCC                         |
        GND---|GND    QH'|---TO 'SER' OF                 \----------
              \----------/    NEXT 74HC595-->

    This circuit can be cascaded to any practical length by connect-
ing the RCLK and SCLK in parallel on all 74HC595s and the QH' pin
(pin 9) on each 74HC595 to the SER pin on the next IC in the chain.

BASIC SUBROUTINE USED WITH 74HC595 CIRCUIT:

symbol	data	= pin0	'serial data line
symbol	clk	= pin1	'clock for data
symbol	stb	= pin2	'strobe signal to latch data
symbol  temp    = b3    'temporary counter var.

	dirs	= 7
        pins    = 7

        'SHift OUT 8
	'subroutine to send b0 out of pin0(data), pin1(clk) & pin2(stb).
	'destroys contents of b0, temp(b3), pin0, pin1, pin2
        'expects pin1 & 2 are already set hi, leaves them hi.
        ' (set b3 to 4 and call 'shout4' to send hi 4 bits of b0 only)

shout8:	for temp = 1 to 8               'shift 8 bits
shout4:	 clk = 0			'drop clock
	 data = bit7			'set pin1 to hi bit of b0
	 b0 = b0 * 2			'shift b0 left (up)
	 bclk = 1			'raise clock
	next
        pulsout stb, 10                 'latch data
	return

The problem is that I cannot find anyone that can sell me any. Even
though MM74HC595Ms are listed on page 63 of the May-June 1933 Digikey
catalog, they tell me they are not available at this time (or the
next 30 days). As an alternative, I am currently using the following
circuit:

           /----\/----\    /----\/----\
           |  74HC273 |    |  CD4015  |              /----------
  <--OUT1--|Q1      D1|----|Q1A       |              |  BASIC
  <--OUT2--|Q2      D2|----|Q2A RESETB|--GND         |  STAMP
  <--OUT3--|Q3      D3|----|Q3A  DATAB|--TO Q4A-->   |
  <--OUT4--|Q4      D4|----|Q4A   CLKB|--TO CLKA-->  |
  <--OUT5--|Q5      D5|----|Q1B       |              |
  <--OUT6--|Q6      D6|----|Q2B RESETA|--GND         |
  <--OUT7--|Q7      D7|----|Q3B  DATAA|--------------|PIN0 data
  <--OUT8--|Q8      D8|----|Q4B   CLKA|--------------|PIN1 clk
           |          |    \----------/              |
      VCC--|CLR    CLK|------------------------------|PIN2 stb
           \----------/                              \-----------

At Digikey, 4015s are not available in small outline, however they
do have MM74HC374WM which can be used in place (with slight
alteration of circuit) of the 74HC273. (I have some on order). I have
also tried Mouser Electronics. Mouser lists the 4015 as being
available as a small outline part, but said they wouldn't be in stock
anytime in the near future when I tried to order some.

The above circuit is useful when you allways have to change all the
output bits at once. In order to change single bits one at a time,
the above circuit could be used if you shadowed the bits somewhere
in memory, or you could use an addressable latch IC like the 74HC259.

74HC259 SIMPLIFIED SCHEMATIC:

              /----\/----\                               /----------
              |  74HC259 |                               |  BASIC
    <--OUT1---|Q0     CLR|---VCC                         |  STAMP
    <--OUT2---|Q1        |                               |
    <--OUT3---|Q2      /G|-------------------------------|PIN4 stb
    <--OUT4---|Q3        |                               |
    <--OUT5---|Q4    DATA|------------(TO EACH 'DATA')---|PIN3 data
    <--OUT6---|Q5    SELA|------------(TO EACH 'SELA')---|PIN0 \
    <--OUT7---|Q6    SELB|------------(TO EACH 'SELB')---|PIN1  sel
    <--OUT8---|Q7    SELC|------------(TO EACH 'SELC')---|PIN2 /
              \----------/                               \----------

This circuit can be expanded by connecting the DATA, SELA, SELB and
SELC lines in parallel on multiple 74HC259s and connecting the /G
line (pin 14) to PIN5, PIN6, ..etc on the basic stamp. It can be
expanded much further by implementing the above 74HC595 circuit on
pins 5,6 & 7 of the basic stamp and using each OUT line of the
74HC595(s) to drive the /G pin on seperate 74HC259s (instead of
PIN4 of the stamp).

BASIC SUBROUTINE USED WITH 74HC259 CIRCUIT:

symbol	data	= pin3	'data line
symbol	stb	= pin4	'strobe signal to latch data
symbol  sel     = b2    'bit selector
symbol  temp    = b3    'temporary var.
symbol  abit    = bit8  'the bit to set

	dirs	= 31
        pins    = 0

        'ADressable OUT
	'subroutine to set abit(bit8) out of pin0-4.
	'destroys contents of pin0-4.
        'expects pin4 is already set lo, leaves it lo.
        'only uses 3 lowest bits of sel(b2).
        'preserves bits 5-7 of b0 in case they're being used
        ' elsewhere.

adout:  temp = pins & 224               'save upper 3 bits
	b0 = sel & 3 | temp             'set selector to desired adr.
        data = abit			'set data bit.
        pulsout stb, 10                 'latch data bit.
	return

I am having the same availability problems with the 74HC259. Digikey
lists it in their catalog, but it's not available. Unfortunately,
the only substitute I have come up with takes 6 parts, two 4051s and
four 4013s. (Which are about the only small outline parts you CAN
get from Digikey or Mouser.) Here is what I ended up with:

         /----\/----\                                     /--------
         | 4013 x 4 |                                     |  BASIC
<--OUT1--|QA   CLK1A|--<            /----\/----\          |  STAMP
<--OUT2--|QB   DAT1A|--<            |   4051   |          |
    GND--|RA   CLK1B|--<    <CLK1A--|I/O0   O/I|----------|PIN4 stb
    GND--|RB   DAT1B|--<    <CLK1B--|I/O1      |          |
    GND--|SA      SB|--GND  <CLK2A--|I/O2   VEE|--GND     |
         >----------<       <CLK2B--|I/O3   INH|--GND     |
<--OUT3--|QA   CLK2A|--<    <CLK3A--|I/O4      |          |
<--OUT4--|QB   DAT2A|--<    <CLK3B--|I/O5  SELA|-TO PIN0> |
    GND--|RA   CLK2B|--<    <CLK4A--|I/O6  SELB|-TO PIN1> |
    GND--|RB   DAT2B|--<    <CLK4B--|I/O7  SELC|-TO PIN2> |
    GND--|SA      SB|--GND          \----------/          |
         >----------<                                     |
<--OUT5--|QA   CLK3A|--<            /----\/----\          |
<--OUT6--|QB   DAT3A|--<            |   4051   |          |
    GND--|RA   CLK3B|--<    <DAT1A--|I/O0   O/I|----------|PIN3 dat
    GND--|RB   DAT3B|--<    <DAT1B--|I/O1      |          |
    GND--|SA      SB|--GND  <DAT2A--|I/O2   VEE|--GND     |
         >----------<       <DAT2B--|I/O3   INH|--GND     |
<--OUT7--|QA   CLK4A|--<    <DAT3A--|I/O4      |          |
<--OUT8--|QB   DAT4A|--<    <DAT3B--|I/O5  SELA|--<PIN0>--|PIN0 \
    GND--|RA   CLK4B|--<    <DAT4A--|I/O6  SELB|--<PIN1>--|PIN1  sel
    GND--|RB   DAT4B|--<    <DAT4B--|I/O7  SELC|--<PIN2>--|PIN2 /
    GND--|SA      SB|--GND          \----------/          |
         \----------/                                     \----------

Pulldown resistors(8 x 100k) (not shown) on CLK1A-CLK4B omitted for
clairity. This circuit is somewhat of an improvement over the
straightforward implimentation of the 74HC259 which would need 8
inverters (2 chips), 8 4-input nand gates (4 chips) and 8 flip-flops
(4 chips). What could cut down on the parts count is an IC with
4 D-type flip-flops (without the NOTQ outputs), but I am not familiar
with a part like this available in small outline.

As for multiplexing input, a 4051 and 4 of the basic stamp lines
can be used to make 8 inputs, two 4051s and 5 basic stamp lines can
make 16 inputs ...etc. The circuit and subroutine are similar to
the 74HC259 example. I can get plenty of 4051s, so making this kind
of circuit is not a problem.

Another way to multiplex input is to use a 8-bit parallel in/serial
out IC like a 74HC165 and subroutine similar to the above 74HC259
example. It should come as no suprise that it is listed in the
Digikey catalog as a small outline part, and it too, is not
available. According to the internal representation in the data
book, it would take 6 inverters (1 chip), 2 AND gates (1 chip), 1 OR
gate (1 chip) and 8 flip-flops (4 chips). This adds up to 7 (or 6
with some diodes) chips to do the same job as a single 74HC165.

In conclusion, what I am asking for are ideas on how to economicly
multiplex the input and output capibility of the basic stamp. Are
there circuit elements and programming strategies I have overlooked?
If you have any ideas or suggestions for subsitute parts or designs,
please let me know.
                                        Sincerely, Eric Johnson
