>
> Thanks for the response Richard, it is a great help. I'm really
> impressed with how friendly this group is and willing to share!
>
> Conceptually I'm still a little lost with the idea of sinking current
> through the IO pins, do I need to do something in software to put the
> relevant lines into a "current sinking" mode, or will the PWM control
> just 'work' and somehow recognise that during the active part of the
> duty cycle it's supposed to be sinking current, not providing it.
>
> Sorry if this is exposing a fundamental (and embarrassing) lack of
> knowledge of electronics, I'm using this project as a learning
> experience!
>
> I've got the PIC16F877A datasheet and will be reading it through.
>
> Jim
>
A pin can be high or low (I'll ignore PWM for a moment). Suppose it
is high and the load is connected between the pin and ground. In this
case, current flows out of the pin and through the load to ground.
The pin is the SOURCE of the current and is considered SOURCING. If
the pin is low, no current flows.
Suppose you connect your LED anode to +5V and then, through a
resistor, connect it to a pin. It is clear that when the pin is high,
no current will flow (or, at least, it is insignificant). But, when
you set the pin low, current will flow from +5V through the LED,
through the resistor and into the pin and on to ground. The current
is flowing into the pin and the pin is SINKING it to ground. Think of
the drain on a sink if that helps.
So, if we want the LED to light, we need to set the pin low. If we
want if off, we set it high. PWM can be added to the pin to set the
pin on or off some percentage of the time. The more it is OFF (low),
the brighter the LED. This nay be upside down from the way you would
think about PWM but that a result of the fact you are SINKING current
rather than SOURCING it.
A couple of suggestions: In the beginning, put 330 ohm resistors
between your pins and external things. That will keep you from frying
your chip. VERY IMPORTANT for chip life. Consider an input signal
driven from some souce with high current capability. Then consider
what happens if you accidentally define the pin as an output, pull it
low and the input signal is high. A very high current will flow into
the pin and probably let the magic smoke escape.
Later on when you have a lot of experience put 330 ohm resistors
between your pins and external things because you will know that they
have saved your chip more than once.
Second: Put the statement OOPIC.Delay = 500 to get a 5 second delay
on startup. If you write an errant program, the chip will try to
execute it and not acknowledge the next attempt to program the chip.
With the delay, you will be able to get the chip's attention before it
goes out to lunch.
Richard
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
No comments:
Post a Comment