kobre98
Full Member level 2
- Joined
- Sep 18, 2011
- Messages
- 145
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Location
- Gaza, Palestine
- Activity points
- 2,523
Define osc 20 'define 20 mhz crystal
TRISB = 0 'define portb as output
TRISC = 0
TRISD = 0
TRISA = 0
PORTB = 0
PORTC = 0
PORTD = 0
PORTA = 0
COL VAR BYTE
CHAR0 VAR BYTE
CHAR1 VAR BYTE
CHAR2 VAR BYTE 'define variable with 1 byte size
CHAR3 VAR BYTE
MAIN : 'label
FOR COL = 0 TO 63 'loop
LOOKUP COL, [ $08, $40, $20, $87, $38, $18, $18, $38,_ 'use array to simplify dealing with items and send them to ports
$78, $78, $F8, $FA, $FC, $4F, $FE, $CE,_
$4C, $CC, $E9, $EB, $83, $C2, $1E, $1E,_
$3E, $0E, $0F, $06, $09, $10, $40, $60,_
$90, $FA, $98, $CA, $F0, $F8, $60, $F8,_
$7D, $F8, $FA, $FC, $F8, $F0, $F8, $FC,_
$F8, $FC, $F8, $FC, $F8, $FC, $F8, $D0,_
$58, $30, $18, $F0, $18, $08, $08, $00],CHAR0
LOOKUP COL, [ $00, $00, $00, $01, $20, $00, $00, $00, _
$00, $00, $08, $03, $1F, $1F, $27, $C7,_
$66, $8F, $83, $80, $00, $80, $00, $00,_
$00, $00, $00, $00, $10, $F8, $FF, $FD,_
$FD, $F9, $F8, $FB, $F3, $F2, $EE, $CF,_
$28, $3F, $0F, $0F, $1F, $FF, $3F, $1F,_
$FF, $3F, $FF, $1F, $0F, $61, $07, $09,_
$07, $00, $00, $80, $00, $00, $00, $00],CHAR1
LOOKUP COL, [ $00, $00, $04, $00, $00, $00, $00, $00,_
$00, $00, $00, $00, $00, $00, $00, $00, _
$00, $01, $07, $FF, $FF, $FF, $7E, $3E, _
$7C, $07, $00, $00, $00, $00, $00, $01, _
$00, $13, $8F, $FF, $FF, $3F, $3F, $01, _
$71, $04, $00, $00, $00, $00, $00, $00, _
$02, $03, $08, $03, $E1, $F2, $FA, $A8, _
$A6, $E4, $C0, $00, $00, $00, $08, $00],CHAR2
LOOKUP COL, [ $00, $00, $00, $00, $00, $00, $00, $00, _
$00, $00, $00, $00, $00, $00, $00, $00, _
$00, $00, $00, $07, $23, $31, $08, $00, _
$00, $00, $00, $00, $00, $00, $00, $00, _
$00, $00, $00, $00, $01, $00, $00, $00, _
$00, $00, $00, $00, $00, $00, $00, $00, _
$00, $00, $00, $00, $00, $00, $00, $00, _
$01, $07, $00, $00, $08, $04, $01, $00],CHAR3
PORTB = CHAR0 'assign the value of char0 to portb
PORTC = CHAR1
PORTD = CHAR2
PORTA = CHAR3
Pauseus 1805 ' 120 / 63
NEXT COL ' increase index
GOTO MAIN
END
View attachment 69457
i've tried it on a bread board with 15 led and it worked well with low delay
but when i used pcb with 29 led and the internal pull up resistors disabled, the led's are connected as shown in figure,
i don't know about the capacitors ?! could u explain more ?
and the switching current thing ?! shouldn't each pin gives 25Ma & 5 volt as output ?
17.0 ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings †
Ambient temperature under bias............................................................................................. -55 to +125°C
Storage temperature ........................................................................................................... -65°C to +150°C
Voltage on any pin with respect to VSS (except VDD, MCLR. and RA4) ......................................... -0.3V to (VDD + 0.3V)
Voltage on VDD with respect to VSS ...................................................................................... -0.3 to +7.5V
Voltage on MCLR with respect to VSS (Note 2) .......................................................................... 0 to +14V
Voltage on RA4 with respect to Vss ......................................................................................... 0 to +8.5V
Total power dissipation (Note 1) .............................................................................................. 1.0W
Maximum current out of VSS pin .............................................................................................. 300 mA
Maximum current into VDD pin ................................................................................................. 250 mA
Input clamp current, IIK (VI < 0 or VI > VDD)........................................................................... ± 20 mA
Output clamp current, IOK (VO < 0 or VO > VDD) ..................................................................... ± 20 mA
Maximum output current sunk by any I/O pin............................................................................... 25 mA
Maximum output current sourced by any I/O pin .......................................................................... 25 mA
Maximum current sunk by PORTA, PORTB and PORTE (combined) (Note 3).......................................... 200 mA
Maximum current sourced by PORTA, PORTB and PORTE (combined) (Note 3)...................................... 200 mA
Maximum current sunk by PORTC and PORTD (combined) (Note 3) .................................................... 200 mA
Maximum current sourced by PORTC and PORTD (combined) (Note 3) ................................................ 200 mA
Note 1: Power dissipation is calculated as follows: Pdis = VDD x {IDD - Σ IOH} + Σ {(VDD - VOH) x IOH} + Σ(VOl x IOL)
2: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up.
Thus, a series resistor of 50-100Ω should be used when applying a “low” level to the MCLR pin rather than
pulling this pin directly to VSS.
3: PORTD and PORTE are not implemented on PIC16F873A/876A devices
Maximum current out of VSS pin .............................................................................................. 300 mA
Maximum current into VDD pin ................................................................................................. 250 mA
i don't play roughly on wires, it's (the led normal light) just keeps coming and going
Are you referring to bypass or decoupling capacitors? It isn't clear as to which capacitors you are referring?
Reference: PIC16F87XA Datasheet, Section: 17.0 ELECTRICAL CHARACTERISTICS, Pg. 173
There are several current limiting specifications, however notice the device, PIC16F877A, is limited by how much current it can sink or source total.
It is going to be difficult to drive 30 LEDs simultaneously from a single PIC. You may want to consider utilizing an LED driver device or port expander to drive the LEDs directly.
The high current requirements maybe the cause of several anomalies, including voltage drop and device reset.
BigDog
Always keep a copy of the devices datasheet handy:
PIC16F87XA Datasheet
As well as any available errata:
PIC16F877A Product Page
BigDog
everything is clear now but i want to ask what is the difference between bypass or decoupling capacitors ?!
could u show me simple schematic for both ?! i've never connected capacitors with power rails and it was working well till this project
The edaboard database had to be restored after quite a few extra questions and answers here, so I'm going to summarise what I said in them all from my memory.
I've no idea how the youtube project works without melting something. If the LED's really are standard LED's, with no resistors and a 5V supply, then both the PIC and the LED's should be molten junk. :shock: Personally, I think there is something we aren't being told about it.
...
With regards to current:
The same quantity of current must flow through every part of a circuit path, unless it comes to a junction where it can split or combine. In that case, you get the sum of the currents at that point. It does not matter which way the current is flowing, it must always be the same. Like water through a pipe - if a litre per minute is flowing through a pipe, the same rate must flow through all of that pipe. If it goes through a junction, it must still be flowing somewhere, in addition to anything else flowing in the subsequent parts from that juncction.
So, if you connect the LED cathode to ground (with its resistor) and the LED anode to a PIC pin, and turn on the PIC pin (set it high):
Conventional current can now flow from the +5V supply, through the PIC's power pins, through the PIC's internal connections to the i/o pin's ouput transistor, through the output pin which is now said to be sourcing that current, through the LED and resistor and finally to ground.
If the LED/resistor combination take 25mA at 5V, then that 25mA will flow through the PIC's i/o pin, and through the PIC itself in addition to whatever esle is already flowing through the PIC's power pins.
If the LED's cathode is connected to the PIC i/o pin, with its resistor, and the LED anode is connected to +5V, and the i/o pin set to zero:
Conventional current can flow from +5V supply, through the LED and resistor, into the PIC's i/o pin which is now said to be sinking that current, through the low-side pin output transistor into the PIC's internal connections, out through the PIC's ground power pin and evetually to circuit ground.
Again, if the LED/resistor combination draws 25mA, then that same 25mA will be flowing through the PIC's i/o pin, and be added to whatever is already flowing through its ground circuit and ground power pins.
Thus, 30 of these LED's, all lit, will each source or sink (depending which way you wire them) 25mA through its i/o pin, and the PIC itself will see an additional 30x25 = 750mA of current through either the +5V power pins or the ground power pins, again depending which way you have wired them. But in either direction, the PIC still has to have that 750mA flow through it. No way to avoid that without using more external components.
Hope that has made the current situation clearer.
Now, the ways around this are:
1. Use external current buffers of some description, including driver/buffer ic's or transistors.
2. Drop the LED current to around 9mA and use the PIC pins to sink current. That is, connect the LED anode to +5V and the cathode to the PIC. That way we can use the PIC's 300mA maximum sink (9mAx30 = 270mA, leaving a little bit of current for the PIC itself to use). A resistor of 360 ohm is probably a good value for an average red LED. This sill not be very bright with standard LED's - maybe switch to very high brightness types to offset the effect of the lower than optimum current.
3. Use low power LED's (generally around 2-3mA), running them at full current with an appropriate resistor. I guess around 1.2K would be correct for an average low-current red LED.
...
I just remebered another point that was made about current:
Components are not given a current as such. They are given a potential difference, or voltage, across them and that causes or allows a current to flow that depends on the characteristics of the component.
The PIC does not get involved in how much current flows into or out of its output pins, other than acting merely as a switch which connects the pin to either Vdd or Vss (or some other way on some of the pins, but the principles still apply).
It will not control the current, even if it is more than the PIC pin's transistors can handle, or more than the entire PIC itself can handle. Allow too much current and the PIC will be damaged.
if a device has components that consumes .5 ampere and i have 5 volt source with 1 ampere as an input there shouldn't be a problem since the device with take only .5 ampere and nothing will melt down ?
isn't that the case ? or it depends on how much the pin can handle ?
the final question here what cause the device to damage/meltdown (high volt or high current)? and depending on what ?
is it related to the fact that pic takes only 250ma from the main source so it won't be able to give what leds+resistors want (750ma) so no damage happens ?
--
i think the damage will happens for sure when i connect the cathode directly to resistor and +5v power rails and send 0's from pic cause in this case each 25ma will go to pic as 750ma as a whole which the pic can't handle and in this case melt down ?? hope that was true :d
Yes - you are getting there. Sourcing or sinking, the PIC still has the current flow through it.
360 ohms will give about 9mA with an average red LED, assuming the LED drops 1.8V. So, 30 of them will draw 270mA. That should just be safe if you connect them with the PIC sinking current (LED's and resistors between PIC pin and +5V) because the PIC can tolerate up to total 300mA when sinking current.
If you want to connect the LED's so the PIC sources current, then you have the 250mA sourcing limit - call it 240mA to allow 10mA for the PIC itself. So, 240mA/30 = 8mA, (5V-1.8V)/8mA = 400 ohm. You need to use 400 ohm resistors if you want to connect the PIC to source current.
Really, both the above currents are too high for comfort. It is poor practice to run things near their maximum ratings. Things like a slight over-voltage from your power supply due to mains fluctuations, tolerences in the resistors giving values that are a bit low, even the room being warm can cause problems if you are already at the maximum. Personally I would drop the current by a further 10% (at least) to give a safety margin. That means changing the 360 ohm resistors to 400 ohm for the PIC-sinking circuit, or the 400 ohm for at least 440 ohm on the PIC-sourcing circuit.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?