Shop OBEX P1 Docs P2 Docs Learn Events
Derive signal indicating direction of a prop pin — Parallax Forums

Derive signal indicating direction of a prop pin

KhrushchevKhrushchev Posts: 7
edited 2012-08-24 13:22 in Propeller 1
What simple external logic circuit could produce a signal that would be a 1 if the pin were configured as an output, and 0 if the pin was configured as input (high Z)?
Or stated otherwise, what simple logic that would produce the following truth table?



Prop Pin

Output



0
1


1
1


Z
0









Sort of a tri-state buffer in reverse.
if a pull down/up resistor is involved, what value would be appropriate?

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-08-23 20:38
    Khrushchev wrote: »
    What simple external logic circuit could produce a signal that would be a 1 if the pin were configured as an output, and 0 if the pin was configured as input (high Z)?
    Or stated otherwise, what simple logic that would produce the following truth table?



    Prop Pin

    Output



    0
    1


    1
    1


    Z
    0








    Sort of a tri-state buffer in reverse.
    if a pull down/up resistor is involved, what value would be appropriate?

    First off can I just say that it would be far better to describe what you are trying to achieve with a brief description of that part of the project. What you have presented could be answered perfectly and yet a far better solution may be wanting but not discerned from the very narrow criteria you have presented.

    That said I would simply go with a cheap dual comparator and bias resistors (resnet) so you can pick if it's above or below the bias point meaning that it's an output. But I kind of feel that's dumb already as I can't see a purpose for such a thing but I'm sure you will enlighten us!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-08-23 21:33
    Khrushchev,

    Welcome to the Parallax forum! The "dual comparator" circuit that Peter mentioned is often called a window detector. Since most comparators are open-collector, you can tie the two outputs together and pull them up to Vdd. The Prop pin should be biased via a voltage divider just above or just below the logic threshold. 3/8*Vdd or 5/8*Vdd would be just about right.

    -Phil
  • KhrushchevKhrushchev Posts: 7
    edited 2012-08-23 23:34
    Thanks Phil & Peter,

    Sorry Peter about not providing detail, but I've found that telling your life story in your first post is a good way to get people to tune out completely! So I tried to be very terse in my question. Being mostly a software guy, stuff that lives between 0 and 1 is a bit challenging for me. But now I've learned a little about comparators.

    So here's what we're trying to do.We're building a multipurpose data collection and control interface to a +5v outside world. I need to some bidirectional lines that can be independently configured as inputs or outputs, depending on the external device attached to each. When a line is configured as an output, we will need to clock it via a cog PWM. The devices not only use the clock to return data (similar to SPI), but they are powered by it and require +5v @ about 8mA drive (at dc only about 3.5mA). Different models require different frequencies and duty cycles, but average in the 2000Hz range. Still other devices don't require clocking, but supply two sets of low frequency pulses at irregular intervals (under 25Hz) In this case, we require two inputs rather than one output and one input. And there are other scenarios such as solid-state relays as well.

    Bottom line, we need to use a bunch of prop pins that can be configured as outputs or inputs, and we need to do level shifting between the prop's 3.3V and the 5.5V devices. We're considering using an octal switch-type level translator, like the TI TXS0108, which can auto-sense direction, but then there's the drive problem. If we put a open-drain pull-up on the output, then it has to be disabled when we configure for input, so we figure we need to switch the pull-up on and off. If we know whether the prop pin is configured for output then we can enable the pull-up, etc. We could use a separate set of prop pins for the pull-up, but then we run out of pins.

    We're also considering optoisolators for the 5v outside stuff. Does anybody know how to do bidirectional communications with optoisolators (afford ably?). That probably deserves a separate thread.

    --K
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2012-08-24 07:45
    For a visual indicator, you could use something like this...
                 150           1k           150       
    + 3.3V >-----/\/\----o----/\/\-----o----/\/\----< Vss
                         |             |
                         |  //     //  |
                         o-->|--o-->|--o
                                |
                         Led1   |  Led2
                                o------------< Input
    
    Input = LOW	Led1 = ON	Led2 = OFF
    Input = HIGH	Led1 = OFF	Led2 = ON
    Input = HiZ	Led1 = OFF      Led2 = OFF 
    

    No need for a window comparator, since you are going to use OPTOs eventually anyway, the LED's in the schematic above could be replaced with OPTOs for a singular style output.

    Bi-directional communication? in full-duplex or singular duplex? I mean would the communication need be simultaneous in BOTH directions? Basically the data is either HIGH or LOW if the transmitter and receiver are in agreement with one another. If they disagree, then the signal is 1/2 Vdd (floating)
  • KhrushchevKhrushchev Posts: 7
    edited 2012-08-24 09:28
    Thanks Beau!

    Singular duplex would be quite sufficient, since our application will be configuring a line for input or output and leaving it in that state until reconfigured in the future.

    For a visual indicator, you could use something like this...
                 150           1k           150       
    + 3.3V >-----/\/\----o----/\/\-----o----/\/\----< Vss
                         |             |
                         |  //     //  |
                         o-->|--o-->|--o
                                |
                         Led1   |  Led2
                                o------------< Input
    
    Input = LOW    Led1 = ON    Led2 = OFF
    Input = HIGH    Led1 = OFF    Led2 = ON
    Input = HiZ    Led1 = OFF      Led2 = OFF 
    

    No need for a window comparator, since you are going to use OPTOs eventually anyway, the LED's in the schematic above could be replaced with OPTOs for a singular style output.

    Bi-directional communication? in full-duplex or singular duplex? I mean would the communication need be simultaneous in BOTH directions? Basically the data is either HIGH or LOW if the transmitter and receiver are in agreement with one another. If they disagree, then the signal is 1/2 Vdd (floating)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-08-24 11:44
    For simplicity, reliability, and output drive capability, I would use something like this:

    attachment.php?attachmentid=95128&d=1345833677

    You don't have the advantage of a single pin connecting to the external device; but if you really need a single-pin connection, you could simply add a three-pin header and use a jumper to select input vs. output.

    -Phil
    453 x 286 - 2K
  • KhrushchevKhrushchev Posts: 7
    edited 2012-08-24 12:26
    Thanks Phil,

    Nice and simple. One challenge though, the device will be located in remote locations, and the installers will be limited to swapping boxes and wiring terminal blocks. The application processor will be an ARM running embedded Linux. Communication to the device will mostly be M2M wireless, using SMS for simple configuration changes, and uploaded XML documents for complex changes, such as protocol, PWM programming, and data collection parameters. We'd like to make the input/output configuration part of the general parameter set.
  • RickInTexasRickInTexas Posts: 124
    edited 2012-08-24 13:07
    Phil, just curious why you specified 74LVC and 74ACT parts. Would 74HCx work as well?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-08-24 13:22
    Rick,

    74LVC devices running from 3.3V are 5V-tolerant on their input pins. 74ACT devices running at 5V have a low logic threshold that's suitable for 3.3V inputs, and the buffered parts can source and sink 24mA. 74HC devices satisfy none of those criteria.

    -Phil
Sign In or Register to comment.