Shop OBEX P1 Docs P2 Docs Learn Events
Interface — Parallax Forums

Interface

DavidicusDavidicus Posts: 20
edited 2008-11-13 14:41 in BASIC Stamp
Hello,

I want to use the Stamp as a Data Logger for a piece of equipment that uses 8 contact closures to reveal its internal state (shown on the left side of the schematic). I've configured 8 input pins on the stamp using resistors (as shown in the center portion of the schematic). I hooked up the Stamp to the piece of equipment and it works perfectly. The problem I have is that the equipment needs to reveal its internal state to another piece of hardware that connects to it (shown on the right side of the schematic).

I need to buffer the Stamps inputs from the equipment on the right. I tried to use DPDT relays but the back voltage was too great and caused the equipment to malfunction. I'm hoping to be able to use something non-mechanical (Transistors, solid state relay, etc) but I do not know enough about how to configure the circuit.

Any help would be greatly appreciated!!

Thanks, Dave
600 x 400 - 67K

Comments

  • Lee HarkerLee Harker Posts: 104
    edited 2008-11-08 18:57
    Dave,

    The schematic is not quite enough information to know how to connect the 2 pieces of equipment and the Stamp. You show the contacts on the left side but you will need to know the characteristics of the other unit. It is common for an input to expect a pullup when not active and to be pulled low when active. That seems to match the functionality from the left. Your Stamp interface uses a pull down. It may be as easy as reversing that but more details would be needed to be sure.
  • DavidicusDavidicus Posts: 20
    edited 2008-11-08 19:21
    The equipment on the right is internally configured and only expects a contact closure from each of the eight inputs. Unfortunately, the internal aspect of the right-hand equipment is not known. In the usual configuration, the two pieces of equipment would simple join in the middle. I want to tap into the state of the relays without affecting the way the two pieces of equipment work currently.

    I updated the schematic to show what I would like to do. I believe I need to electrically separate the stamp from the right-hand equipment so that they do not interfere (i.e.-short, voltage problems, etc.) with each other.

    DAve
    600 x 400 - 83K
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-08 20:17
    You do not need to know the internals of the right-hand equipment, but you do need to know what the voltage at each pin will be when the left-hand equipment is presenting (1) an open circuit, and (2) a contact closure. Find this out by measuring, with the equipment hooked up and operating.

    When you know what voltage appears at each of the eight terminals in each of its two possible conditions, it will be trivial to devise a way to present these two conditions to the inputs of a Stamp. Until you know that, you cannot devise a way.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • DavidicusDavidicus Posts: 20
    edited 2008-11-08 21:20
    The reason I'm concerned about hooking this up this way is shown in my latest schematic. I am worried that by closing one contact, all eight of the other contacts will be bypassed, essentially closing all of them. I only put two of the connections to the Stamp up to save space, but won't the same be true for all eight contacts? Don't I need to buffer them from each other?

    I appreciate the help.

    Dave
    600 x 400 - 104K
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-08 21:51
    When a Stamp pin is an input, it is very nearly an open circuit. It will not connect anything to anything. Because the Stamp input will conduct essentially no current (maybe a millionth, or less, of what is already flowing between your two devices) it wil not affect them in any way. If you find that the voltages present are too large for Stamp inputs, you will of course need to use a voltage divider at each Stamp input, as shown in your drawing. This, however, can consists of resistors in the hundreds of thousands of ohms, so it will not have any effect on the existing circuit between your two devices. And it certainly will not close all of them, or any of them.

    You show the "common" lead of your two ultra-mysterious devices connected to the +Vdd of the Stamp, the positive supply. If your measurements show that the voltages at the eight pins of your right-side device swing negative from common, this would be correct. But if they swing positive from that common -- much more likely -- you'd want to connect that common to Vss, the negative. Either way, it's not going to affect your two devices at all, though getting it wrong might fry your Stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • DavidicusDavidicus Posts: 20
    edited 2008-11-11 22:42
    Hello again,

    I was able to measure the voltage and it was right around 8 volts. I know Ohms law to get the values of the resistors, but I do not know the current that will be applied to the stamp Input pins because the right-hand equipment will be using some of the current (but I don't know how much).

    I'm thinking that I should base my calculations as if the stamp used all of the current in the circuit since this will only make the resistor values more conservative. Does this sound like the right way to go?

    Dave
    83K
    Schem4 83.4K
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-12 00:33
    Any Stamp pin, when set as an input by an INPUT statement, is very nearly an open circuit. That means the current into it, or out of it, is very nearly zero. Use "zero" as what you call "the current that will be applied to the stamp Input pins".

    If you base your calculations "as if the stamp used all of the current in the circuit" that will be the wrongest you can possibly get, since it will actually use none. None at all. NONE!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • DavidicusDavidicus Posts: 20
    edited 2008-11-12 06:35
    I was thinking about my circuit while I was driving tonight (Don't remember how I got home [noparse];)[/noparse] ) and I realized that the way I had it configured could probably be simplified. By connecting it to the voltage source on the right-hand (on the schematic) equipment and changing the Stamp's code to look for an active low, I can use just one resistor.

    Carl, I appreciate your input and help. I do have a question, though. The Stamp Handbook says, "General-purpose I/O pins: each can source and sink 30 mA." I thought this meant that I needed to limit the current going to the IO pin using a resistor. If the IO pin was like an open circuit, no resistor would be necessary. I think that it is the resistor that causes the pin to act very much like an open circuit as it limits the current going to the pin to 20-30 mA.

    The simplified circuit makes things much easier as it only requires calculation of the value of one resistor. Using Ohm's Law, I get 8/.02 = 400 Ohms. This will limit the current to 20 mA.

    I don't claim that this is correct. This is only according to my limited knowledge.

    Can anyone confirm this for me?

    Dave
    600 x 400 - 84K
  • KyeKye Posts: 2,200
    edited 2008-11-12 14:22
    Okay, you're schematic is fine now. I'm guessing that when the +8V is grounded is activates a switch or something in the mystery device.

    So, this is how the INPUT statement works, simply, the basic stamp essentially becomes an open circuit on the line. Line a voltage meter the stamps internal resistance raises to well over a million ohms. So there is basically no current. However, in reality there is some current...but you would need to know the internal resistance of the stamp to calculate the voltage drop needed across the external resistor as to not damage the stamp.

    Just replace your resistor with a 10k or something resistor to ensure that the current can never get to high. Since there is basically no voltage drop the stamp will see the 0v or 8v potential so you have nothing to worry about.

    Your current design is also fine. However, not as safe as one with a larger resistance.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-12 14:32
    Each pin can source or sink 30 ma when it is an output.· When it is an input it is an open circuit and passes essentially no current at all, in either direction.· Forget about those resistors -- don't need'em.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • DavidicusDavidicus Posts: 20
    edited 2008-11-12 14:36
    I understand now.

    Thank you, Thank you, Thank you. I appreciate the help.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-12 19:06
    Well, you may need those 22Kohm in-series resistors.

    The reason is, yes, the BS2 input pin, when set as an input, is a high-impedance, UNTIL the input voltage goes below -0.6 volts, or above 5.6 volts. When that happens two 'protection diodes' begin conducting to protect the rest of the chip.

    The effect of this is to 'clip' the signal the BS2 sees to 0 to 5 volts. BUT, when this "clipping" happens, you MUST have a 22 Kohm resistor in-series to drop the current those "clipping" diodes see -- they're pretty small, and they burn out easily.

    Now, if you're reading either an 'open circuit' or 'closed circuit', then you DO also need a 'pull-up' or 'pull-down' resistor to give your input pin a signal. Otherwise, an open input pin connected to nothing is technically an "antenna", and will pick up random noise (typically 60 Hz line noise). So you really can't "forget" about either resistor on your input pins -- you need both of them.
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-12 19:17
    Allan makes a good point, I think.· You mentioned that you measured 8 volts at the signal line between your devices.· I guess I'd put those resistors in, after all.· I'd make them bigger, say 100K, but 22K actually ought to be sufficient.

    On the other hand, with those series resistors in place your pull-ups (or pull-downs), if you need them at all,·would have to be quite large values -- else the mystery boxes could not overcome them when working through a 22K or 100K resistor.· You really need to know the voltages at those pins in BOTH states, and you mention measuring only one state (8 volts).· If those lines swing between two voltages (as surely they must) when the two Iron Curtain Enigmas talk to each other, then you won't need pull-ups or pull-downs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • DavidicusDavidicus Posts: 20
    edited 2008-11-13 01:38
    In the last schematic I posted (Schem5), isn't the Stamp's IO pin pulled up by the 8 volts and pulled to ground when the relay contact closes?

    If I replaced the 400 Ohm resistor with a 100K, would that make the circuit work?
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-13 14:11
    Yes, that should make the circuit work.

    My one remaining concern is that the circuit as shown seems to 'short' 8 volts to ground. That will only work if the 8-volt signal has some resistance in the line -- I'm assuming there must be some to the right of the box, as none is shown to the left of the box.

    So, if internally to the box, it has some 'pull-up' resistor to +8 volts, then yes the BS2 (with the 100K in-series resistor) should read that as a "one", and you don't need an additional pull-up resistor near the BS2.
  • DavidicusDavidicus Posts: 20
    edited 2008-11-13 14:41
    The equipment in the right-hand portion of the schematic has internal components and is not simply a source of 8 volts and a ground so it will not short.

    Thanks for your help Kye, allan and Carl.
Sign In or Register to comment.