How can I configure input ports?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
I have a question. I have an AT90SLS8535. The PORTA was configured as input. If a voltage 3V is feed into the pin (PA0) from digital circuit, when a program read the pin (PINA), can the pin be considered as logic high?
If a voltage 0V is feed into the pin (PA0) from digital circuit, when a program read the pin (PINA), can the pin be considered as logic low?
I appreciate anyone can let me know.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess the first question is what power supply voltage are you feeding the chip ?

if you are powering off roughly 3v to begin with then the answer would yes, logical 1 for sure.

if you are powering off 5v, then you are starting to get into a gray area for the logic 1 which you want to avoid.

The 0v is definately logic 0 (low) at any power supply voltage.

if you are powering off approximately 5v, consider doing one of these things to make the circuit reliable:

1) put a diode pointing away from the pin in your circuit, this turns it into an "open collector like" design. enable the pullup in the pin, or add your own resistor to 5v will give you a reliable logic high, and when you drive the input low, if you make sure the diode drop is small, you will be guaranteed your logic 0. To guarantee a small diode drop, use a high power diode, or alternatively a germanium diode with a .3v instead of .7v nominal junction drop.

2) don't use that pin at all and use the analog comparator in the chip instead and use a vref of say 1.5-1.8v (3 silicon diode drops in series.)

3) use that pin and stick your own comparator in such as 1/4 of a lm339

4) make a clipping amplifier (inverting but you can fix that in software) out of a 2n2222 and some resistors.

You have a lot of options to get the job done, so it should not be a problem.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

3 volt is considered as HIGH for portA if supply voltage is 5 volt or lower. If you read the data sheet Electrical specifications, you will find that voltage level for digital input should be minimum 0.6 x supply voltage to be considered as HIGH input. 3 volt is just 0.6 x 5 volt, and it satisfies the requirement.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On this topic, I use a NPN transistor to switch relays on and off with my AVR as follows:

INPUT>-------/\/\/\/\-----[>1N4148]---- BASE

the COLLECTOR is connected to the GND of the relay, and the EMITTER is connected to GND of the circuit.

The other end of the relay coil is connected to 5VDC, and there is a diode across the relay poles.

I haven't had problems with this (yet) and the input on the base can be pretty darn small for the transistor to switch the relay.

Considering I am a backyard hobbyist, I have no idea whether this is a good or a bad circuit, but as I am planning on using it in a production environment, I would greatly appreciate any comments!

BTW, why I posted in this thread, I figure it is an easy way to force anything above 0.5V to read as logical 1 ;-) Obviously the sensitivity depends on the transistor and resistors used.

admin's test signature