Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Software pullup on 16F627? (Also, TTL question)

Status
Not open for further replies.

Random

New Member
I have a bunch of these PIC's I'm programming for video game controllers. Problem is, I don't want to have to solder a lot of extra resistors onto the PCB, and the datasheet says there's a pullup option for the bottom (RB) half of the I/O pins. How does the microcontroller recognize a float? I need it to work in reverse logic - a button press will ground that pin. If there's a way to do this in the software, I'd be one happy camper.


And regarding TTL - since my inputs will be coming from physical switches, I need a way to debounce them. All the inputs on the RA half have Schmitt triggers on them, which is what I'd want, but they don't have that pull-up that'd save me a lot of work. They do, however, have "TTL" on them - will that debounce the switch? I'm generally familiar with what TTL is and does, but I'm not sure how it'll work in this case.


Any help would be most appreciated. Thank you!
 
The pullups on PortB are quite high values, but do what you want, by pulling the pins high when the switch isn't pressed, the switches simply ground the pins when pressed.

Logic inputs, either TTL or Schmitt, WON'T bebounce the inputs, you need to either do it externally in hardware, or internally in software.

Check my tutorials for some examples of how to read switches.
 
Nigel Goodwin said:
The pullups on PortB are quite high values, but do what you want, by pulling the pins high when the switch isn't pressed, the switches simply ground the pins when pressed.
That's correct about the switches, but I'm a little confused as to what exactly they mean by "pull-up". Does this work the same as a pull-up resistor? The documentation doesn't mention anything about which polarity (+V or ground) it pulls it to, and measures in amps, so suffice to say, I'm a little lost.


Nigel Goodwin said:
Logic inputs, either TTL or Schmitt...
What's the difference in this case? I was under the impression that TTL was the alternative to CMOS. Will I need to handle the two sets of pins differently in my code because of it?


Nigel Goodwin said:
Check my tutorials for some examples of how to read switches.
Sounds great! I'll do that. Thanks for the advice!
 
Random said:
Nigel Goodwin said:
The pullups on PortB are quite high values, but do what you want, by pulling the pins high when the switch isn't pressed, the switches simply ground the pins when pressed.
That's correct about the switches, but I'm a little confused as to what exactly they mean by "pull-up". Does this work the same as a pull-up resistor? The documentation doesn't mention anything about which polarity (+V or ground) it pulls it to, and measures in amps, so suffice to say, I'm a little lost.

Pull-UP is the giveaway, it's pulls UP to the positive rail, as opposed to a pull-DOWN which goes to ground.

Nigel Goodwin said:
Logic inputs, either TTL or Schmitt...
What's the difference in this case? I was under the impression that TTL was the alternative to CMOS. Will I need to handle the two sets of pins differently in my code because of it?

No, they are both logic inputs, it's just that the schmitt trigger inputs include hysterisis - but that's a hardware thing, which can be useful at times, it doesn't affect the software at all.

As you say TTL and CMOS are two different logic families, and the PIC is actually of CMOS construction, but the pins are essentially TTL compatible.
 
Nigel Goodwin said:
Pull-UP is the giveaway, it's pulls UP to the positive rail, as opposed to a pull-DOWN which goes to ground.
Gotcha. Sounds obvious now, but it always does after you understand it, eh? ~_^

Nigel Goodwin said:
No, they are both logic inputs, it's just that the schmitt trigger inputs include hysterisis - but that's a hardware thing, which can be useful at times, it doesn't affect the software at all.
Ah, OK I understand why there are Schmitt triggers there now. (Just had to wiki hysteresis.) With that, I see why the ST won't do any good against debouncing. However, I think my problem, if indeed one exists, is a little different than the debouncing used in your tutorial.

The circuit I'm replicating is written up in the attachment - the microcontroller sends three bytes along the DATA line, then takes 'snapshots' of the values at PORTA for the fourth and PORTB for the fifth. In this case, a bounced switch wouldn't bother the microcontroller's operation, as long as it stops bouncing by the time the snapshot is taken. I'm only worried about the case where it bounces right at that moment, in which case the button would act as if it were not pressed.

I'm a little stumped as to how to solve this problem, if indeed it needs to be solved. With those conditions in mind, should I be worried about bounce? If so, would you have any ideas on where to start coding to fix it? My current code's fairly light as is.


Thank you so much! I'm always amazed with how helpful and insightful the users of this forum are. ^_^
 

Attachments

  • psx_controller_information.doc
    138 KB · Views: 320
For reliable operation, switches (and relay contacts) need at least 5 Volt across them when open and a current of at least 1 mA when closed. So the pullups in PICs are too high.

I use 4k7 resistor networks. They are available as either single in line (SIL) or dual like ICs. The SILs come in various options (eg. 4 pin, 5 pin 9 pin, etc. and save a lot of PCB space.

Incidentally, why use TTL? CMOS Is much better.

Debouncing can be done easily in software - as Nigel said.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top