PDA

View Full Version : Matrix _16f877 need help, please



MINHLE
- 5th February 2009, 02:47
Currently i write a code to run a led matrix. the following is a one led set to be lighted up. the positive pin of the LED is connected to port B0. and negative, to port C1.

the X-tal OSC is 20Mhz, HS_osc is placed in the 16F877.INC file; OSC. set to HS
MCLR is connected directly to the 5V source.

i use PBP
-----------------------
; 16F877A

ADCON1 = 7

A VAR BYTE

PORTB = 0 ; SET PORTB AS OUTPUT
PORTC = 0 ; set port c as output

PORTC.1 = 0 ; set port C1 to low

pause 300
LOOP:

FOR A = 0 TO 8 loop to repeat

PORTB.0 = 1 set port B0 to high
PAUSE 500

PORTB.0 = 0 ; set port B0 to low
PAUSE 300

NEXT A

GOTO LOOP
END

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

the Voltage measurement on the two pins of the LED is 1.65V!!!!!!!

something wrong!!!!!!!!!!

any help from you i do appreciate, thanks

Archangel
- 5th February 2009, 03:09
Hi MINHLE,
try this


ADCON0 = 0
ADCON1 = 7

A VAR BYTE

PORTB = 0 ; SET PORTB AS OUTPUT
PORTC = 0 ; set port c as output
trisB = %00000000 'all ports B as outputs
TrisC = %00000000 'all ports C as outputs

PORTC.1 = 0 ; set port C1 to low wich enables leds ground pin
CCP1CON = 0 ' turn off CCP Module which affects portC
pause 300

LOOP:
FOR A = 0 TO 8 'loop to repeat
PORTB.0 = 1 'set port B0 to high, turn on led
PAUSE 500
PORTB.0 = 0 ; set port B0 to low, turn off led
PAUSE 300
NEXT A

GOTO LOOP ' Flash forever
END

The only difference is I set Tris registers and disabled Capture Compare Module. and turned off A/D converter. Now how have you set your config fuses? You have specified 20 mhz and this will not work with the default config statement found in the C:\PBP\16f877.inc file.

MINHLE
- 5th February 2009, 10:20
THANKS jOE,

I TRY AGAIN AS YOUR SUGGESTION.

I WILL SET THE OSC TO 20MHZ, AND CHECK THE DATA SHEET

THANKS

mister_e
- 5th February 2009, 13:41
In case you change XT to HS osc in your .inc file, make sure you've made the change for the right assembler... this is 1 reason why I set my fuses in code, not in the .INC file.

MINHLE
- 7th February 2009, 04:17
hi, Joe and Steve,
thanks for your concern. I tried testing but no thing happen. is it possible the two capacitors of the osc-xtal is the main problem.

I saw in the data sheet, for the Hs (20Mhz) xtal osc, the capacitors are range 15-33pF. but i use only 10uF! (table 14-2 page 144 of the data sheet).

Archangel
- 7th February 2009, 04:59
hi, Joe and Steve,
thanks for your concern. I tried testing but no thing happen. is it possible the two capacitors of the osc-xtal is the main problem.

I saw in the data sheet, for the Hs (20Mhz) xtal osc, the capacitors are range 15-33pF. but i use only 10uF! (table 14-2 page 144 of the data sheet).µ is Way bigger than pf Way too big !10µF will oscillate in kilohertz, not mhz.

MINHLE
- 7th February 2009, 05:02
thanks, I should replace them tomorrow.

Dave
- 7th February 2009, 11:53
MINHLE, What exactly is the question? Are you concerned that the voltage across the led is too low? What is the value of the resistor in series with the led? Do you have any resistor in series with the led at all? If there is no resistor in series with the led then the current is too great for the PIC and the voltage is being dropped too low for the oscillator to operate... What is the voltage across the 2 PIC pins you are using to drive the led? You should start out with maybe a 680 Ohm resistor in series with the led and see if that doesnt cure the problem...

Dave Purola,
N8NTA

MINHLE
- 7th February 2009, 14:21
Hi Dave,


thanks for your concern,

the voltage drop across the LED is an important issue here. if the voltage different across the LED is '0" then the LEd cannot be lighted up. a resistor in serial with the LED is to protect the LED when the high pulse current flowing through the LEd aND TO PROTECT THE PIC FROM HIGH IN PUT CURENT . so we do have to consider the voltage drop on the resistor.

in this case the positive pin of the LED is 1.65V, then the negative pin of the LED has to be '0' as set up. however the situation different, both side of the LED is 1.65 so it means that either open circuit (no current flowS through the LED) , the bad PIC or the program not well set up( i.e conf, ...).

I wish getting some suggestion , ideal from you,

thank agian

aratti
- 7th February 2009, 17:27
Since you didn't use a limiting resistor, you have fried the pic!
Replace it and put a 330 ohms resistor in series to every leds. Then use Joe snippet, given in post # 2 and you will see that leds will switch on and off without burning another pic.
You will always read 1.6 - 1.7 V across a led, unless you have shorted one!

Al.

MINHLE
- 7th February 2009, 21:14
hello Arrati,

yes I have 200 ohms resistors connected in serial with each input of the PIC to limit the current into the pic.

I guest some thing wrong, because when I use OHM meter to test the LEDs. at the two pins on the socket (removing the PIC out of the socket) every thing is ok! so the circuit is not open.

I try to figure out

thanks for your comment.

Minh le

MINHLE
- 8th March 2009, 23:07
hi every boDy,

I removed the two capacitors of the X-TAL OSCILLATOR then it works. i am sorry for long time not to post the reply