TTL input - 3rd states possible?


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    913

    Default TTL input - 3rd states possible?

    Hello,

    I was asking myself about the possibility of using any TTL input of my PIC to "read" 3 different levels.

    Roughtly, for TTL values, the LOW level is from 0V to 1V and the HIGH is from 3,5V to 5V.

    Assuming this is not completely wrong, would it be possible to read 3 different states on the PIC?

    I tried to make it a simple way with a 2 resistor divider between Vdd and Vss. The middle point of the divider is logically connected to the pin.

    Two buttons are parallel connected each to a resistor.

    In theory, I can simulate 3 states:
    1.- 0V (if button "A" is pressed)
    2.- something around 2V (no button is pressed)
    3.- 5V (if button "B" is pressed)

    I can't achieve to read state 2.- but is it really possible... or am I dreaming?
    Roger

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Hello,

    I was asking myself about the possibility of using any TTL input of my PIC to "read" 3 different levels.

    Roughtly, for TTL values, the LOW level is from 0V to 1V and the HIGH is from 3,5V to 5V.

    Assuming this is not completely wrong, would it be possible to read 3 different states on the PIC?

    I tried to make it a simple way with a 2 resistor divider between Vdd and Vss. The middle point of the divider is logically connected to the pin.

    Two buttons are parallel connected each to a resistor.

    In theory, I can simulate 3 states:
    1.- 0V (if button "A" is pressed)
    2.- something around 2V (no button is pressed)
    3.- 5V (if button "B" is pressed)

    I can't achieve to read state 2.- but is it really possible... or am I dreaming?
    You can do 3 states with a regular ol' TTL pin right now, but it takes a bit of programming.
    1 and 0 are self explanatory, set the pin to an input and read it...
    then you can read the 3rd state...open...
    set the pin to an output, output a 1, read the input back...if it's a 0, it's being held to a 0 (in other words, not open), then set the output to 0, read the pin back, if it's a 1, it's being held to a 1 (again, not open)...however if you read back exactly what you put out, then the pin can be reasonably assumed it's open.

    But the way you described works well too, if you're using a button sort of thing.

  3. #3
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    See tip #3:

    http://ww1.microchip.com/downloads/e...doc/40040b.pdf

    Best regards,

    Luciano

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    913


    Did you find this post helpful? Yes | No

    Default Good documentation

    Thanks to both of you,

    The Tips & Tricks documentation is cool :-)

    I'll have a try with tis stuff.
    Roger

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    913


    Did you find this post helpful? Yes | No

    Unhappy Can't get it working...

    Well,

    After a few hours trying to get a positiv result, I just got nothing working.

    I would like to read two buttons connected to one pin.

    The states are "0" and "1". The third "Z" state is not relevant to me here.

    To make sure I have an intermediate level, I use a 2 resistor divider like described in the first post.

    Currently, I can't get clear "0" or "1" states.

    Any idea?

    Code:
    OSCCON       = %01100000  '4MHz
    OPTION_REG   = %10000000  'D I S A B L E PORTB's Pull-Ups for buttons
    ANSEL        = %00000000  'Disable Analogue Inputs
    TRISB        = %00010000  'Inputs/Outputs
    PORTB        = %00000000  'Drive all ports low
    
    MAIN:
        IF PORTB.5 = 0 THEN PORTB.0 = 1
        IF PORTB.5 = 1 THEN PORTB.1 = 1
        PAUSE 1000
        PORTB.0 = 0
        PORTB.0 = 0
        Goto MAIN
        end
    I use PORTB.5 of my PIC16F88 for buttons because it is a TTL input only.
    Roger

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Code:
    TRISB        = %00010000  'Inputs/Outputs
    you have PORTB.4 set as input, not PORTB.5
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  2. RB0 + Internal Pullup + Interrupt
    By Freman in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th August 2009, 11:11
  3. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 20:31
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  5. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts