|
|
View previous topic :: View next topic |
Author |
Message |
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Mon Feb 04, 2013 6:22 am |
|
|
It appears that 2 columns are not working not 'some dots' ?
Easy to debug...
First, get rid of all wiring except for the LED display, a resistor and power supply. Play 'computer' and test each row and column combination to verify that the LED module is 100% working. Should take you 10 minutes.
Second, rewire your PIC and parts back up and retest using a 'one LED on' program. Using a simple 'for loop, select LED, delay 1 second' program will 'cycle' all the LED dots.
Third, my hunch is you have NOT disabled some onboard peripheral that is defaulted to control 2 'column' I/O pins.
Fourth, or....you've blown up those pins ! A simple LED-resistor test will confirm this.
It all gets down to basic trouble shooting, start with a known condition and proceed in a logical pattern AFTER you confirm the hardware is 100% working. Also be sure to recheck your wiring..it's real easy to mis-count a pin or plug the 'red' wire where the green one goes.....
hth
jay |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Feb 04, 2013 10:44 am |
|
|
Hi,
Is this a 'real' hardware project? If so, would you kindly snap a picture so
that we can see how you have things wired up?
John |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Mon Feb 04, 2013 6:56 pm |
|
|
OK you've changed your schematic.
Part of your circuit now looks like this:-
Code: | A0 -----------------------------------
A1 --------------------------------- |
A2 ------------------------------- | |
A3 ----------------------------- | | |
A4 --------------------------- | | | |
A5 ------------------------- | | | | |
A6 ----------------------- | | | | | |
A7 --------------------- | | | | | | |
| | | | | | | |
-----------------
| o o o o o o o o |
| o o o o o o o o |
| o o o o o o o o |
| o o o o o o o o |
| o o o o o o o o |
| o o o o o o o o |
| o o o o o o o o |
| o o o o o o o o |
-----------------
330R each | | | | | | | |
K7 -------WWW----------- | | | | | | |
K6 -------WWW------------- | | | | | |
K5 -------WWW--------------- | | | | |
K4 -------WWW----------------- | | | |
K3 -------WWW------------------- | | |
K2 -------WWW--------------------- | |
K1 -------WWW----------------------- |
K0 -------WWW------------------------- |
The terminals A0/7 are the PIC PORTD pins connected directly to the common anodes.
The terminals K0/7 are the outputs from the '595, connected via 330R to the common cathodes.
The display now could go like this.
1) Make PORTD ALL Low.
2) Turn ON cathodes for column 0.
3) Set PORTD0 pin High.
4) Wait for say 1ms.
5) Make PORTD ALL Low.
6) Turn ON cathodes for column 1.
7) Set PORTD1 pin High
8) Repeat till all pins driven High in turn.
...............
Start again from column 0
This will activate each column in turn once every ~8ms.
(i.e. refresh at ~125Hz, should be flicker free.)
When any LED is on the current will be ~10mA.
( Assuming 5V supply, ~2V drop across LED and PORTD leaves ~3V across 330R)
Suppose you want ALL the LEDs ON.
Each cathode current will be ~10mA
Total current drawn from '595 is 8*10mA = 80mA
How does it compare with max ICC rating for '595?
All the 80mA sources from one PORTD pin.
How does that compare to the I/O ratings for the PIC?
Mike |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Feb 05, 2013 5:15 am |
|
|
OK. I've had time to burn your code (not mine) into a PIC16F877, I don't have the 'A' version.
I've had a look with a 'scope.
You've studiously ignored my previous questions about power and 'scopes.
So here goes:-
There does not appear to be anything stuck.
All the PORTD pins waggle up and down in the correct sequence.
All the drives to the '595 operate.
There are groups of 8 pulses on the CLOCK line.
There's activity on the DATA line.
And single pulses on the control lines.
I don't have '595s so can't test that bit.
I have read the data sheet, and suspect it should be working (after a fashion).
Like others have suggested, it looks like you've got a connection problem, or something is stuffed.
Serious testing/debugging called for.
Your operating sequence is wrong.
You're updating the '595 outputs THEN changing the PORTD.
The effect is that you'll get ghosting between LED columns.
Also you're wasting time.
You don't need to reset the '595 outputs.
You could, instead, feed data into its serial register as a background task.
At this stage the ghosting and the time issues may not be important, but they will be if you ever get the stage of driving a larger display.
Mike
EDIT What you're doing is even worse than I realised at first glance.
After the '595 reset, ALL the LEDs of the current column will be turned ON.
They remain ON 'til the following data latch pulse.
The LEDs in the next column also light briefly in the wrong column.
Like I said before, you MUST turn OFF ALL the anodes whilst updating the cathodes.
Bear in mind, I don't have your hardware in front of me, nor do I have '595s to test, so there are other possible problems I have not noticed. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Feb 05, 2013 4:07 pm |
|
|
You may ask, why am I being paranoid about one PIC port sourcing/sinking 80mA.
Quite simply, the manufacturer of your 8x8 matrix more than likely went to the trouble af matching the LEDs.
You're doing your best to defeat that.
For any column with all 8 LEDs ON, the PIC will struggle to handle enough current.
On the other hand driving a column with only one LED ON will be easy.
The visual effect will be that the one LED will be significantly brighter than each of those in the fully lit column.
The display will look odd.
I, for one, would not be happy.
You need to follow temtronic and other's advice regarding testing debugging etc.
The following code will exercise everything for you.
It activates each column in turn.
Whilst one column is active it lights one LED in that column in turn.
So you should see ALL the LEDs light (fairly dim, but equally lit).
You can probe ALL the column and row drivers with a 'scope.
This code should allow you to probe both the PIC and the '595, i.e. everything.
WHEN you know that everything's working THEN proceed with YOUR coding.
Code: | #include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay(clock=20000000)
#define CLR PIN_B0
#define Latch PIN_B1
#define Data PIN_B2
#define CLK PIN_B3
void main()
{
unsigned char column, row;
// Initialise port pins
output_high(CLR); // Force Clear high
output_low(CLK); // Clock pin low
output_high(Data); // data high
output_low(Latch); // Latch pin low
output_d(0); // All columns OFF
while(1)
{
// Outer loop cycles columns
// Makes one column pin high in turn
column = 0x80;
while (column != 0)
{
output_low(Data); // This low propagates through SR
// Inner loop makes one '595 pin low in turn
for (row = 0 ; row < 8 ; row++)
{
output_high(CLK); // Clocks data into SR
output_low(CLK);
output_high(Latch); // Transfers SR to O/P
output_low(Latch);
output_d(column); // Turn column back on
delay_us(150); // Wait here
output_d(0);; // Turn all columns off (could skip this)
output_high(Data); // Makes next data high
}
column >>= 1 ; //Shifts to next column
}
}
}
|
I'm done for now.
Mike
EDIT You'll need to change the PIC to 'A' version.
If you skip the turn columns OFF code, it's easier to sync your scope but the LED currents won't be equal.
Repeat rate is ~100Hz, so you should be able to use either analogue or digital 'scope.
Removing delay_us() seriously increases repeat rate. |
|
|
kein
Joined: 23 Jul 2007 Posts: 103
|
|
Posted: Wed Feb 06, 2013 7:34 pm |
|
|
Gents,
Sorry, I have been out of the scene recovering. I can't thank you enough for your comments, direction and help. I will put them into action between today and tomorrow and will post a response.
Once again thanks for sharing hard earned experiential knowledge with me.
Long live knowledge! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|