Newby questions regarding pull-down/up resistors and designing circuits...
New to BASIC stamp, just received the stamp 2 usb discovery kit and very excited so far! I have some basic questions though. I'm trying to wrap my mind around the whole pull-up pull-down resistor thing talked about in Chapter 3 (page 79). I think I understand that from the pin point of view the resister is pulling the voltage to either 5V or 0V by where it's connected. What I do not understand is why a 10KΩ is there? I figured it had something to do with protecting the STAMP because the book said that's what the 220Ω resistor was for... but on the pushbutton circuit it's only on the Vdd side and not the Vss side. So I'm confused. Also, in the back of the book (Appedix F) it talks about rules for mA on the pins being 20 Ma. So I'm assuming that there is actually no current through the pin to the Vss side? Because there's only a 220Ω resister along that path which would equate to 22.73 mA, which is above the 20 Ma limit. ?? but that doesn't make sense either Can someone please explain what's happening here?
Comments
In normal use, one I/O pin 'drives' while another I/O pin is an 'input' recieving the 'driven' signal. It's only an accident to put two 'drivers' on the same I/O wire at the same time -- and the 220 ohm resistor prevents hardware damage should that occur.
• An I/O pin can “source” 20 mA. In other words, if you send the HIGH signal to an
I/O pin, it should not supply the LED circuit with more than 20 mA.
• If you rewire the LED circuit so that the BASIC Stamp makes the LED turn on
when you send the LOW command, an I/O pin can “sink” up to 25 mA.
• P0 through P7 can only source up to 20 mA. Likewise with P8 through P15. If
you have lots of LED circuits, you will need larger resistors so that you don’t draw
too much current.
My question is on the third point. Does this mean the combination of the current that all the circuits on the group of pins together (0-7 together and 8-15 together) can not draw more than 20mA combined? If not it seems like it's just restating what the first bullet says. If I have 5mA on each pin 0-8 that's a no-no because it add up to 40mA total on that group of pins correct? Can you clarify?
Also, just to make sure I'm understanding the way the pins work: When a pin is set to output and it's HIGH (sourcing) it's basically connecting the circuit to the battery's + terminal (Vdd) and when it's set to LOW (sinking) it's connecting to the battery's - terminal (Vss). When a pin is set to input, it's "sensing" whether the circuit is connected to Vdd or Vss. Correct? When it's an input pin there is still current passing through the pin though right? So do the terms "sourcing" and "sinking" still refer to a pin when it's in an input state and do the rules in appendix F about the mA limits still apply?
If any of you can recommend any good books for a beginner on the rules of circuit design I would greatly appreciate it. I've got a "dummies" guide to electronics but it doesn't go into much detail beyond basics and giving you schematics to build. I love building projects but my primary goal for getting into this is to be able to really understand circuit design myself so I can build my own. Understanding where, when and why to use resistors and how strong of resistors to use seems to be my sticking point right now.
When a pin is set to input mode, it's a high impedance. The current flow is very small (microAmperes). The terms "sourcing" and "sinking" don't really apply (although strictly speaking they're still valid).
The BS1, BS2 and BS2e use a PIC processor and the datasheets describing the devices are available from MicroChip. The other Stamps use an SX processor and those datasheets are available from Parallax.
The limitation per group (or Port, rather) is not 20 mA/25 mA...It's 40 mA Source and 50 mA sink per port. One other thing to consider is that in most cases, not all LEDs on a 7-Segment display will be on at the same time. Nonetheless it is within tolerance of the specifications. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Jeff T.
Actually when a Stamp pin is configured as an input, the terms source and sink still apply but not to the Stamp.·It would be in reference·to the device that is driving the Stamp input. The device supplying the signal must be able to source or sink the current necessary to drive the input which is almost nothing.
Just for my own satisfaction, and so that no Stamps get fried due to a typo or misunderstanding, let me state the I/O current limitations this way for the PBASIC Stamp BS-2:
Ampacity per INDIVIDUAL pin port (1 pin)
· Source···· Sink
·· 20 mA·· 25 mA
Ampacity per ENTIRE I/O port (8 pins)
· Source····· Sink
··· 40 mA·· 50 mA
BOTH limitations MUST be considered. They are NOT mutually exclusive.
Now I'm happy :-)
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Veni, Vidi, Velcro! - I came, I saw, I stuck around!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
"Thank you for the very informative posts. One more question, in appendix F, I see this:
• An I/O pin can “source” 20 mA. In other words, if you send the HIGH signal to an
I/O pin, it should not supply the LED circuit with more than 20 mA.
• If you rewire the LED circuit so that the BASIC Stamp makes the LED turn on
when you send the LOW command, an I/O pin can “sink” up to 25 mA.
• P0 through P7 can only source up to 20 mA. Likewise with P8 through P15. If
you have lots of LED circuits, you will need larger resistors so that you don’t draw
too much current.
"
1. An I/O pin can "source" 20 mA WITHOUT DAMAGE. It CAN source much MORE than 20 mA for a short time before the output transistor burns out -- which is NOT something you want to have happen. An I/O pin does NOT have any inherent current limiting feature on it. So, whatever you do, don't try to drive a load with more than 20 mA (at 5 volts, that means any load with a resistance of less than 250 ohms. Okay, 220 ohms will work).
2. An LED does not have any inherent current limit on it either. It CAN have 25 mA go through it for a short time before the LED burns out -- again, NOT something you want to have happen. So it's CRITICALLY IMPORTANT you put some current limiting resistor in the line with the LED and the I/O pin. 470 Ohms makes a good one for red LED's.
3. If you DO have 'lots of LED circuits', you can only have a certain number of the LED's on at the same time. It's up to you to limit the number you turn on, such that the BS2 is only sinking or sourcing 50 mA -- I'm not sure what happens if you try to source or sink more than 50 mA with the BS2 -- but hardware destruction is likely.
Finally -- these 'current ratings' are LIMITS of DESTRUCTION. There's nothing about the device to prevent destructive currents from going through it. So you, as a builder, MUST design your circuits so they DO NOT take that much current from the BS2.· And the typical, very simple way to do this is to add a single resistor of the appropriate value (220, 330, 470 ohms are common) to limit the current from the BS2 and through the LED.
Post Edited (allanlane5) : 1/18/2008 12:49:32 AM GMT