Shop OBEX P1 Docs P2 Docs Learn Events
Rotary switch and basic stamp, managing 8 outputs with less pins used, possible? — Parallax Forums

Rotary switch and basic stamp, managing 8 outputs with less pins used, possible?

CuriousOneCuriousOne Posts: 931
edited 2012-12-10 10:09 in BASIC Stamp
Hello.

I have a task. There's a rotary switch for 8 positions, that connects to apropriate pins of basic stamp. There are also 8 outputs.

When I set switch to position #1 - signal is high on output 1. When I set to position #2 - signal is high on outputs 1 & 2, when I set to position #3 - signal is high on outputs 1, 2, & 3. And so on, till 8.

Of course, I can do this all in software and it's quite easy. But, it consumes a lot of IO pins, which I'd like to use for other purposes. So, maybe there's some simple additional hardware available, which will handle these outputs and inputs, freeing IO pins. Usage of rotary encoder not possible, due to specific requirements (device may be switched off, switch set to arbitrary position and then powered on, so ouput should correspond to switch setting).

Also, I can do it with diode matrix, without using basic stamp at all, but I don't think that to be the elegant solution.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-12-10 06:24
    The 74HC595 and 74HC165 are normally used as 8-bit output and input expanders respectively. The StampWorks Manual shows how to use them. Each requires 3 or 4 I/O pins. In your case, you'd use one 74HC595 for your outputs and one 74HC165 connected to your rotary switch. There's a version of the 74HC595 from TI that includes output MOSFETs for power switching to ground (TPIC6595).
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-12-10 07:56
    There are schemes that use RCTIME for the inputs. The rotary switch would be connected to a string of resistors to set a unique time. One Stamp pin.

    Also there are i/o multiplexers that operate on an i2c buss, and are configurable as either inputs or outputs. For example, NXP (Philips) PCA9535. That is easiest to implement on the BS2p series with built-in I2C commands.
  • CuriousOneCuriousOne Posts: 931
    edited 2012-12-10 10:09
    thanks, both ideas seem to be fine. RCTIME is easier to understand, but I suspect, temperature instability/etc. may introduce some problems. Shift register idea looks more modern, but I'll need some time for reading to cleverly understand how shift registers work in conjuction with basic stamp.
Sign In or Register to comment.