Pages: [1]   Go Down
Author Topic: Current leakage with SPI?  (Read 979 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm selecting the line and column of my 8x8 matrix with SPI. I have a problem, sometimes one or more LEDs are selected when they shouldn't. I checked the decoding code that decodes the 64bits and iterates over each bit, and I'm sure that it is correct (I displayed the value in ascii in the console and it's good).

Moreover I know that it's not a decoding problem because depending on the order on how I call the SPI transfer, the LEDs that are displayed and should not are different.

For instance when writing this code:

Code:
void matrix2_display_dot(char line, char column)
{
    digitalWrite(RCLKPin, LOW);
    SPI.transfer(1<<line);
    digitalWrite(RCLKPin, HIGH);

    digitalWrite(RCKPin_tpic6b595, LOW);
    SPI.transfer(1<<column);
    digitalWrite(RCKPin_tpic6b595, HIGH);
}

I get a different result than when writing this code:

Code:
void matrix2_display_dot(char line, char column)
{
    digitalWrite(RCKPin_tpic6b595, LOW);
    SPI.transfer(1<<column);
    digitalWrite(RCKPin_tpic6b595, HIGH);

    digitalWrite(RCLKPin, LOW);
    SPI.transfer(1<<line);
    digitalWrite(RCLKPin, HIGH);
}

What's the problem? Is there some current leakage or something?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8975
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps there is a problem elsewhere in your code.  Could you post a small sketch that lights one LED and demonstrates the problem?  Are you sure your shift registers are wired correctly? Did you include bypass capacitors near your shift registers?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is there some current leakage or something?
No it is either lack of decoupling or code and as you have not described either we can not help.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I display the LEDs one by one and slowly they are displayed correctly. The code for displaying a picture is like this:

Code:
void pic_display(pic_t pic)
{
    int line;
    int column;
   
    for(int i = 0; i < 64; i++) {
        line = i / 8;
        column = i % 8;

        if(pic & (0x8000000000000000 >> i)) {
            matrix2_display_dot(line, column);
        }
       
    }
}



I didn't used capacitors, should I?

But I have a new idea, maybe the problem is that when the 74HC595 is selected the PREVIOUS value of the TPIC tpic6b595 is still active for a fraction of time, and thus display the wrong value?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I didn't used capacitors, should I?
Yes always use a capacitor on every external chip.

There is nothing wrong with that code appart from the fact that is is just a small part of the code. Wee need to see it all. Add it as an attachment if it is too big to post.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The whole code is available here http://bit.ly/15ruDRL but there isn't much more than what I posted.

Could you refer me to a tutorial explaining what type of capacitors I need, and on which IC pins I need to connect them?

Could the few displayed LEDs that shouldn't be displayed due to the lack of synchronisation between the select of the line and the select of the column? If so how can I synchronize both? Do I need to chain the TPIC.... with the 74HC.... ?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Read this
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

It would also help to see the schematic as code is very specific to hardware.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5744
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't used capacitors, should I?

Yes. This is the most likely cause of the problem.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Pages: [1]   Go Up
Jump to: