Shop OBEX P1 Docs P2 Docs Learn Events
How would I wire a B1 to a BS2...? — Parallax Forums

How would I wire a B1 to a BS2...?

NewAgeServerNewAgeServer Posts: 18
edited 2008-11-14 21:33 in BASIC Stamp
Here's my dilemma. I will have a device that will be at one end of a 2-wire cable. It has to be 2-wire, no more, no less. This device will contain a BS1. At the other end of the cable will be a BS2. The BS1 needs to transmit data to the BS2 so the BS2 can log it. I know I can use VDD, VSS and Data, but it needs to be two wires. How would I do this?


| Device |----------------------------| Basic Stamp 2 |
|........|----------------------------|...............|




That's what it must be.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm not new at basic stamp, but i am new at the LCD AppMod

Post Edited (NewAgeServer) : 11/11/2008 4:28:02 PM GMT

Comments

  • Farmer ScottFarmer Scott Posts: 30
    edited 2008-11-11 04:48
    Write an I2C-like protocol to communicate between the two.· I've done that (using different timings and triggers) to put together a multi-device data bus that's about 100m long.
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2008-11-11 05:12
    NewAgeServer

    In the future please try to use a descriptive subject for your posts. "How would I...?" doesn’t convey what you need help with. This will often limit potential useful responses as those who can help may never see your message.

    By your request do you mean that you ONLY have two wires to work with? ... At what speed do you need to communicate?· ... What current demands are required of the BS1 and connecting circuitry?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • metron9metron9 Posts: 1,100
    edited 2008-11-11 06:09
    Another question is how long is the cable and do both devices have their own power supply or are you using the two wires to also provide power to one of the devices.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • GICU812GICU812 Posts: 289
    edited 2008-11-11 08:12
    I would imagine if you only had the 2 wires and they had to carry power on them, you could either use a large cap, or a rechargable battery, and just tie one pin to the power source, then use a transistor on the other end, and send signals by turning the power off and on. This would only provide one way comms though.

    If you have power allready, and the two lines are for comms, an I2C protocol would work, or even use one line for timing and the other as a common transmit line, or use one line as RX and the other as TX and to async transmissions, which would be easiest.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-11 14:48
    Are you allowed to have a battery at the BS1 end? If so, one wire should be ground, the other serial data from the BS1 to the BS2.
  • NewAgeServerNewAgeServer Posts: 18
    edited 2008-11-11 16:25
    The BS1 must get power from the BS2. It cannot have it's own power source.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not new at basic stamp, but i am new at the LCD AppMod
  • FranklinFranklin Posts: 4,747
    edited 2008-11-11 16:33
    Not that it can't be done but you are going to need more that a bs1 and bs2. you will need some form of power storage at the bs1 end for powering the chip when you are sending data and a form of communications that uses ground and one wire Dallas/Maxim have chips called 1-wire and the protocol might be of use. This will not be a simple project.
    Again, what are your distances?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • NewAgeServerNewAgeServer Posts: 18
    edited 2008-11-11 16:35
    What about connecting the BS1's VDD to a pin on the BS2, then HIGH that pin and it's powered, then just send data from the BS1 to that pin on the BS2?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not new at basic stamp, but i am new at the LCD AppMod
  • FranklinFranklin Posts: 4,747
    edited 2008-11-11 16:37
    What data would you send that will never take that line low?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • NewAgeServerNewAgeServer Posts: 18
    edited 2008-11-11 16:44
    All it needs to send to the BS2 is a four-digit number. The BS2 does not need to send data to the BS1.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not new at basic stamp, but i am new at the LCD AppMod
  • FranklinFranklin Posts: 4,747
    edited 2008-11-11 16:50
    The question still stands. Neither device can take the line low or power is cut and the bs1 will reset.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-11 20:55
    You would be better off using more wires, but perhaps the wires are already in place.

    Anyway, you must have a way to combine power & data going into your line on one end, and extract them separately on the other end.· This is not particularly difficult, and is far from being a new poblem.

    The solution is to make sure your data is entirely AC.· This is easy if you use capacitors to pass AC and block DC, and inductors to pass DC and block AC.· Schematic attached.· The resistors can all be about 100K ohms.· The capacitors should be sufficient to pass your AC, and the inductors should be suffcient to block it.· If you are sending data at 9600 baud, probably 0.1 microfarad would be·OK for the series capacitors, and 10 microfarads for the electrolytics.· The inductors can actually be substituted by resistors sufficient to drop, say, 5 volts (2.5 volts in each resistor) at whatever supply currents you need for the respective Stamps.· You'd have to calculate that yourself after measuring the currents.

    R1 and R2 are a voltage divider to make sure the input to the receiving Stamp swings about the midway point between Vdd and Vss of the receiving Stamp.·



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
    1000 x 364 - 4K
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-11 21:04
    I got a little overeager with the resistors. You can delete the resistor I show on the left end (shown as a pulldown on the transmitting Stamp's output pin).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-11 21:10
    Would you have to 'encode' your data, too? I mean, some Ascii characters have very few 'ones' in the bit-pattern. As a worst case, sending 0x55 (%01010101) for a 'one' and 0xAA (%10101010) for a 'zero' might get through the line better than straight 'ascii' characters.
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-11 21:26
    No, not really. If the bias tends to swing too much at idle (between transmissions), it may be necessary to adjust the bias resistors R1 and R2 a bit. In that case you might want to use, say, a 100K potentiometer for R1 and R2, instead of two fixed resistors. Experimentation is always a good thing.

    Alternatively, it might be better to add a couple of diodes to prevent the input signal swinging below Vss or above Vdd. This would automatically charge the coupling capacitor on the receiving end to the correct bias point, as soon as the Start bit arrived. You'd still need R1 and R2, of course. Experiment!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i

    Post Edited (Carl Hayes) : 11/11/2008 9:34:53 PM GMT
  • GICU812GICU812 Posts: 289
    edited 2008-11-11 21:48
    Franklin said...
    The question still stands. Neither device can take the line low or power is cut and the bs1 will reset.

    What I was thinking, if you had a form of power storage, either a battery or a large cap, that could power the BS1 for several seconds at least, you could tie VDD to an input pin, then when you drop VDD, the BS1 is still running off the cap, and the input pin sees the line go low, indicating a bit of data. You would have to encapsulate it a little, probably make up your own serial protocol, but it wouldnt be hard.

    I dont think you could run it right off the pin on the BS2 though, especially when the cap is drained, I think it would overload the pin. It would be far easier to use a transistor, then you know you are protected.

    Or you could go really high tech, and impose a freqency on top of the VDD voltage, but I would think you would need circutry at either end to read the line.
  • GICU812GICU812 Posts: 289
    edited 2008-11-11 21:52
    Oh, and if you need bidirectional comms, then have the BS2 'poll' the BS1 every x seconds, by dropping the power, only after a 'poll' code, the BS2 would listen, and the BS1 would know it could transmit. Then transmit by tying the VDD to ground at the BS1, and have circuitry to watch for the dip on the BS2 end.

    So the BS2 could transmit anytime it wanted, by cutting power to the BS1.

    The BS1 could transmit only after it recieved a 'poll' command from the BS2, and it would signal by pulling the VDD line low.

    The BS1 would be running on its own power supply, either a large cap or a rechargable battery, so loss of VDD would not impact its operation. Also the power supply would need to have an input diode, so it could not impose its power back onto the VDD line.
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-11 22:08
    If you need bidirectionality, just make the left side (of my earlier schematic) identical to the right side. The system then has no inherent directionality and can go both ways. It can even go both ways simultaneously if instead of connecting directly to the Stamps you add modems.· But bidirectionality was not part of the original problem statement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2008-11-13 06:21
    A couple of other techniques that could be used here:

    1) The transmitter simply reverses polarity through an H-Bridge, depending on if it's a "1" or "0" being sent. On the receiver end you have a bridge rectifier and a sense line going to an I/O through a resistor to one of the power leads.

    2) Another way would be to modulate the current and/or voltage without dropping the voltage below a level that the BS1 or BS2 will brown-out at.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-11-13 06:37
    Beau -

    Do you still have the diagram of the first technique you mentioned? I remember it from your old web site. It's one of the most clever applications of a full-wave bridge I've ever seen.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.

    Post Edited (Bruce Bates) : 11/13/2008 6:50:11 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2008-11-13 07:22
    Bruce,

    webpages.charter.net/schwabelove/BasicStamp/OctalSerialCascade.gif

    In concept, the idea is the same as what you would use in the link above with reference to the MODE,GND, and Vcc ... but with this design, power would need to originate from the Transmitter side.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Beau SchwabeBeau Schwabe Posts: 6,563
    edited 2008-11-13 08:01
    Here is an (untested) Current modulation method that I simulated, but did not build. It works very well if the load demands of the BS1 do not widely vary, and that the LOAD is adjusted to match the load of the BS1.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
    1265 x 707 - 347K
    CMDT.JPG 347.2K
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-13 13:57
    Beau Schwabe (Parallax) said...
    A couple of other techniques that could be used here:

    1) The transmitter simply reverses polarity through an H-Bridge, depending on if it's a "1" or "0" being sent. On the receiver end you have a bridge rectifier and a sense line going to an I/O through a resistor to one of the power leads.

    Yes, that's commonly used in model train layouts.· It works extremely well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-13 17:25
    After long and hard thought (half a minute, at least), I think Beau's suggestion stacks up against my method as follows:

    Advantages:·

    (1) Beau's method is likely to be more noise-immune than my method.
    (2) Beau's method is likely to be less expensive than my method.
    (3) Beau's method is likely to be easier to to get working than my method.
    (4) Beau's method is likely to be more fun than my method.

    Balance all that, however, against the following:

    Disadvantages:

    (1) I didn't think of it.

    Surely all will agree that the disadvantage of Beau's method outweighs all its advantages.· Won't they?

    Beau's method requires nothing more than a single ULN2803 to drive the two lines, running from two Pins on the transmitting Stamp.· On the receiving end, it requires only a bridge rectifier and filter capacitor·(to feed·power to the receiving Stamp)·and a 22K resistor (to feed data to the receiving Stamp).· A ULN2803's outputs can easily power a Stamp.· Run the ULN2803s from a nine-volt supply and feed Vin (rather than Vdd) on both Stamps.

    No contest.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • NewAgeServerNewAgeServer Posts: 18
    edited 2008-11-13 19:54
    Thank you everyone for your help. I will not be doing this project for a little while, so that gives you guys plenty of time to discuss a better solution for me, but the ones currently here look great! [noparse]:D[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not new at basic stamp, but i am new at the LCD AppMod
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-13 20:35
    Carl,
    Beau's current modulating scheme should work with the BS2 end supplying power to the BS1 end and the data going the opposite way. The ULN2803 scheme won't work with the data going in the opposite direction from the power. I suggest using something like the 1-wire protocol, but using standard serial I/O. One wire is a common ground. The other wire is signal / power. You have a stiff pullup at the BS2 end to +9V or +12V, something that will conduct maybe twice as much current as the entire BS1 end will need. You have a 22K resistor at each end to an I/O pin used as an input. You also have a switching transistor (like a 2N2222A) to ground with an appropriate base resistor to another I/O pin used for output. At the BS1 end, you also have a Shottky diode and large filter capacitor connected as a half wave rectifier to supply power to Vin. If you want, you could use a logic threshold MOSFET instead of the bipolar switching transistor.

    When the switching transistors at each end are off (the default), the pullup at the BS2 end supplies power to the BS1 end. Once the capacitor is mostly charged, both ends will see the line as idle (active high) for the purpose of a SERIN. Either end (BS1 or BS2) can transmit using SEROUT in open collector / drain mode which will short the line to ground briefly to transmit zero bits while the Shottky diode keeps the capacitor from discharging. The other end can see the transmission using SERIN. The only problem is that you can't transmit long strings of zero bits without allowing the line to go back to high for a while to let the capacitor recharge. The simplest way to do this is to only transmit a few characters before doing a PAUSE for a few milliseconds. The receive end can all be done in a single SERIN if you want because the SERIN will wait for the rest of the characters. You can experiment to see how long a series of characters can be sent before the BS1's Vin will drop too low. It'll depend partly on the mix of ones and zeros in the characters. You may not even need to break up a SEROUT into pieces.
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-14 21:33
    Mike, I thought he wanted to provide power and data in the same direction. At least, that's how I read it. Lessee, let's have another look ... by golly you're right. The receiving Stamp must transmit the power! Missed that.

    Back to the frequency-division multiplexing. One signal (the power, at zero frequency) goes one way, and the other signal (the data, at nonzero frequency) goes the other way. Good thing it's inherently bidirectional.

    Dang! I liked Beau's approach.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
Sign In or Register to comment.