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
    952


    Did you find this post helpful? Yes | No

    Default My code

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1504&stc=1&d=117511986 5">

    I'm not sure about the ANSEL register. Shall I stay DIGITAL or ANALOG?

    I tried both but I get always the same result.

    I found this in the data-sheet; it's about the TTL levels.<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1505&stc=1&d=117512006 5">

    As far as I can understand, the LOW level will be between Vss and 0,15V and the HIGH level between 2V and Vdd.

    Is this correct?
    Attached Images Attached Images   
    Roger

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Do you have the other side of the LEDs connected to +5v or ground?
    Never mind the above


    Put another pause 1000 after your led1 = 0 : led0 = 0, see what happens.
    You might be missing the 'both leds off state' because it happens too quickly.

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    952


    Did you find this post helpful? Yes | No

    Unhappy

    Both leds are connected to ground.

    I added the PAUSE as you mentionned. Now, Led0 is blinking slowly without any button pressed.

    Before I added the PAUSE, the Led0 was always ON until I pressed the button to make Led1 switch ON.

    So, unfortunately, no big change.

    I can see I never get a Z state (between Low and High TTL).

    I also measured my resistors and the voltage levels are correct.
    Roger

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


    Did you find this post helpful? Yes | No

    Smile

    The only options for a digital input are high or low (1 or 0). If you provide a voltage (on a TTL pin) above 0.15*VDD but below 2 V, then the PIC has to decide whether to read the input as high or low - but the PIC will always pick one or the other, high or low (and this may fluctuate back and forth). If you stay below 0.15VDD or above 2V, then you know what the PIC will do ... if you are between these, then you do not know what the PIC will pick (1 or 0) or whether it will stick with the selected value.

    For your original logic shown in post #10, you would expect one of the LEDs to always be on (Skimask noted this for you). If you add the pause like he suggested, you would always expect to get the blinking you are getting because the pin is always read as high or low. With the pause added, the light goes on for a second, then off for a second and repeats as expected.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

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


    Did you find this post helpful? Yes | No

    Default

    Paul,

    Previously, I have mentionned a doubt I had about the ANSEL (analog) settings because I agree with you, in DIGITAL, I can have only two states (0 & 1).

    Do I have to conclued that the reading of a "3 states ports" can be achieved only by means of software (as stated in the "Tips & Tricks" doc) and that it is not possible by reading the inputs states on the PIC's pins?

    I don't care about the Z state.

    I would like to read only both "0" and "1" states (2 buttons)...
    Roger

  6. #6
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post Valid TTL Levels

    TTL - Transistor-Transistor-Logic, valid logic low between (0 - 0.8v), while valid logic high must be within the region of (2 - 5v) Any where between (0.8 - 2v) may be read as either logic high or low. You can't predict it. Could even oscillate.

    CMOS - Complementary-Metal-Oxide-Semiconductor on the other hand can be feed with up to 26% of VCC for a logic low and a minimum of 73% of VCC for a logic high.

    This industry standard ensures that CMOS is guaranteed to produce no more than 26% of VCC for a low output and no less than 73% of VCC for a high out.

    CMOS is far, far superior to TTL in that it mirror's current from in to out. Some CMOS chips can even partially function even without supply. i.e. if there's something on an input you still get something on an output. TTL is however much more robust. That's the trade off. Plus TTL has a much bigger fanout,
    which means that more inputs can be driven from an output.

    Trent Jackson

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Not tested hastily made after reading post

    Hi,
    This is just an idea using the MChip Tips n' Tricks. No timer, no comparator just an idea. Flotulopex please test it out. Others on the forum please comment if it is crap.

    Name:  SWITCH.jpg
Views: 1152
Size:  13.6 KB
    Code:
    READ_SWITCH:
    TRISA.0 = 0             ' MAKE THE PIN AN OUTPUT
    PORTA.0 = 0             ' MAKE IT LOW
    PAUSE 100               ' WAIT FOR THE CAPACITOR TO DISCHARGE 
    
    TRISA.0 = 1             ' MAKE THE PIN AN INPUT
    PAUSE 100               '
    
    IF PORTA.0 = 1 THEN SWITCH_HIGH   '
    
    LED1    = 0             ' DEFINATELY NOT HIGH
    TRISA.0 = 0             ' MAKE THE PIN AN OUTPUT
    PORTA.0 = 1             ' MAKE IT HIGH
    PAUSE 100               '
    
    TRISA.0 = 1             ' MAKE THE PIN AN INPUT
    PAUSE 100               '
    
    IF PORTA.0 = 0 THEN SWITCH_LOW   '
    LED0       = 0          ' DEFINATELY NOT LOW
    
    GOTO READ_SWITCH
    
    SWITCH_LOW:
    LED0 = 1
    GOTO READ_SWITCH
    
    SWITCH_HIGH:
    LED1 = 1
    GOTO READ_SWITCH
    P.S. - The code can be made shorter!!
    Last edited by sougata; - 29th March 2007 at 11:00.
    Regards

    Sougata

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 19:51
  2. RB0 + Internal Pullup + Interrupt
    By Freman in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th August 2009, 12:11
  3. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 21: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, 02:50
  5. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 23: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