Maker Pro
Maker Pro

PIC I/O Questions

A

Allen Bong

Jan 1, 1970
0
Hi Group,

The schematic below (in ASCII art, please view with Fixed font) shows
how my friend connects a switch and an LED to one port, so he can make
use the port to read a switch in input mode and then changes the port
direction to light up the LED.

My questions are:

1. Would this design cause the port to overload and eventually get
destroyed if the switch is pressed too long?

2. Isn't it advisible to have a diode or resistor added between the
switch and the port to prevent the above from happening?

3. If 26 LEDs each consuming 15mA, were connected to the PIC, and all
were switched ON during startup test for a few seconds. Would this
endanger the PIC (say 16F877 as an example)?

4. I have seen in schematic examples that 10 LEDs were connected to a
4017 without any current limiting resistor. Does the CMOS output has
some special properties to limit its output current?

5. The PIC datasheet says that each port can source or sink 25mA. Is
this the Max current or working current?

Thank you for reading. Any feedback is welcomed.

Merry Christmas and regards.

Allen Bong





VCC
|
|---o---|
.-----------------------. | | |
| | \ o\ o\ o
| PIC | \ \ \
| | \. \. \.
'-----|------|-----|----' sw1o o o
| | | |sw2|sw3|
o------|-----|---------o | |
| o-----|---------|---o |
| | o---------|---|---o
| | | | | |
V -> V -> V -> | | |
-LED1 -LED2 -LED3 | | |
| | | | | |
| | | | | |
.-. .-. .-. .-. .-. .-.
| | | | | | | | | | | |
220| | 220| |220| | | | | | | |
'-' '-' '-' '-' '-' '-'
| | | 10k|10k|10k|
| | | | | |
o------o-----o---------o---o---|
|
|
GND
(created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)
 
D

David L. Jones

Jan 1, 1970
0
Allen said:
Hi Group,

The schematic below (in ASCII art, please view with Fixed font) shows
how my friend connects a switch and an LED to one port, so he can make
use the port to read a switch in input mode and then changes the port
direction to light up the LED.

My questions are:

1. Would this design cause the port to overload and eventually get
destroyed if the switch is pressed too long?

If the output is low and you hit the switch then you could damage the
output.
You'd force the LED on too when a switch is pressed, I assume that is
acceptable?
Although it is possible to have the software ensure that the output is
never activated *and* low at the same time.
2. Isn't it advisible to have a diode or resistor added between the
switch and the port to prevent the above from happening?

Only if the softare does not do as described above..
3. If 26 LEDs each consuming 15mA, were connected to the PIC, and all
were switched ON during startup test for a few seconds. Would this
endanger the PIC (say 16F877 as an example)?

Could very well do.
The PIC will have a maximum rating for its power pin. 200mA for the
16F88 for example.
Why do you need 15mA for each LED anyway, that is a lot for most
purposes. 5mA is usually enough, some LEDs even work fine on 1mA or
less.
Each "port" on the PIC also has it's own maximum rating.
4. I have seen in schematic examples that 10 LEDs were connected to a
4017 without any current limiting resistor. Does the CMOS output has
some special properties to limit its output current?

Yes, it has a higher output resistance.
Probably not the best practice though!
5. The PIC datasheet says that each port can source or sink 25mA. Is
this the Max current or working current?

That is the absolute maximum figure before damage could occur.

Dave :)
 
A

Allen Bong

Jan 1, 1970
0
1. Would this design cause the port to overload and eventually get
destroyed if the switch is pressed too long?

If the output is low and you hit the switch then you could damage the
output.
You'd force the LED on too when a switch is pressed, I assume that is
acceptable?
------------------------------------

Yes, it's supposed to light the LED when the switch is hit. Then the
PIC would take over using its internal latch.
The LED would flash at 1Hz and become permanently on once the PIC
receives acknowledgement from another PIC on the Remote end.
------------------------------------

Although it is possible to have the software ensure that the output is
never activated *and* low at the same time.

-----------------------------------------

How would you do it if it were your project, Please ?
OR some pointers would be appreciated! I am using PIC Basic Pro.

Allen Bong
 
A

Anthony Fremont

Jan 1, 1970
0
Allen Bong said:
Hi Group,

The schematic below (in ASCII art, please view with Fixed font) shows
how my friend connects a switch and an LED to one port, so he can make
use the port to read a switch in input mode and then changes the port
direction to light up the LED.

My questions are:

1. Would this design cause the port to overload and eventually get
destroyed if the switch is pressed too long?

If the pin is set to be an output pin and it is set to low (0), then yes
it could damage the port pin. This is not a very good design.
2. Isn't it advisible to have a diode or resistor added between the
switch and the port to prevent the above from happening?

IMHO, yes. Resistors are cheap.
3. If 26 LEDs each consuming 15mA, were connected to the PIC, and all
were switched ON during startup test for a few seconds. Would this
endanger the PIC (say 16F877 as an example)?

Yes. It would greatly exceed the maximum capacity of each port and of
the entire device.
4. I have seen in schematic examples that 10 LEDs were connected to a
4017 without any current limiting resistor. Does the CMOS output has
some special properties to limit its output current?

Just some resistance. Depending upon the design, this resistance might
be very low. This would be yet another example of how not to do
something.
5. The PIC datasheet says that each port can source or sink 25mA. Is
this the Max current or working current?

I think you mean that each individual pin of a port can source/sink that
much current. AIR that device has a limit of 100mA per port and a total
device limit of 200mA. I didn't check the data sheet, but you should.
;-)
 
D

David L. Jones

Jan 1, 1970
0
Allen said:
If the output is low and you hit the switch then you could damage the
output.
You'd force the LED on too when a switch is pressed, I assume that is
acceptable?
------------------------------------

Yes, it's supposed to light the LED when the switch is hit. Then the
PIC would take over using its internal latch.
The LED would flash at 1Hz and become permanently on once the PIC
receives acknowledgement from another PIC on the Remote end.

Ok, sounds good then.
Although it is possible to have the software ensure that the output is
never activated *and* low at the same time.

This is a common technique and works as follows:
Simply write a "HIGH" to all the output pins and leave it like that.
Then you acually toggle the output state by setting the mode enable
line for that pin. So the output pin actually toggles between
"Output-HIGH" and "Input", and never has a chance to go "Output-LOW"
i.e. you never actually write a LOW to the output pin.

Hope that makes sense?

Dave :)
 
A

Allen Bong

Jan 1, 1970
0
This is a common technique and works as follows:
Simply write a "HIGH" to all the output pins and leave it like that.
Then you acually toggle the output state by setting the mode enable
line for that pin. So the output pin actually toggles between
"Output-HIGH" and "Input", and never has a chance to go "Output-LOW"
i.e. you never actually write a LOW to the output pin.

Hope that makes sense?


Dave :)

got it. Thanks very very much, Dave!

Allen
 

Similar threads

M
Replies
6
Views
4K
David L. Jones
D
J
Replies
2
Views
906
Jon Yaeger
J
D
Replies
13
Views
2K
Wouter van Ooijen
W
R
Replies
2
Views
1K
Robert Monsen
R
Top