Pages: 1 2 3 [4]   Go Down
Author Topic: Multiplex IR LED's?  (Read 6712 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok So I got hold of a 0.1uf capacitor, and wired it to the ground and 5v pin on the shift registers. Nothing worked still..., I decided to test different parts of the cuircut and i found a few intereresting things:

1. 2 Shift register pins on the row shift register, when connected light the LED
2. When row 1 & 2 are  plugged in with/without ground, the LED's in wierd places light up
3. When i change the output of the walk to say of B00000001, for column 1 and B00000000 for col 2, i touch the shift register pins to ground with an led and it lights up on all of them?
4. The first row data seemed to be working for a bit, now it seems lost when I changed the columns to a non walking value the pins in the row always output 1??? im soo confused Lol
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The shift register pattern must be data followed by the walking one. Remember that the first two shift outs define the walking 1 pattern and the last out is the data.
So output 0x0, 0x8, 0xff in that order.
That should light up one complete column the left hand one. If it does not then look at the signal on the pins of the shift register outputs and see that the first one has its outputs all set at one, and the other two have the outputs all at zero except for pin 7 on the middle shift register.
If you don't see this then you have a miss match between your software and your hardware. So either change the software or change the wiring so they match.
There is no need to put 5V on the pin 10 of the darlingtons.  You have not got pin 13 connected to ground on the last shift register.
Logged

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

Should I disconnect pin 13 from the ground and the 5v from the darlingtons because that is what I have? And Ill try the pattern after school smiley I needa go smiley-razz
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Should I disconnect pin 13 from the ground
No the schematic shows it NOT connected to ground on the last shift register, it should be connected to ground on all shift registers.

Quote
and the 5v from the darlingtons
Yes remove it. It probably will not stop things from working, but in the context of your circuit it is wrong and could lead to trouble if you powered the LEDs with more than 5V. They are designed as flyback protection when driving motors and should be connected to the motor supply. For your application you do not need them so just disconnect it.
Logged

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

Quote
Should I disconnect pin 13 from the ground
No the schematic shows it NOT connected to ground on the last shift register, it should be connected to ground on all shift registers.

Quote
and the 5v from the darlingtons
Yes remove it. It probably will not stop things from working, but in the context of your circuit it is wrong and could lead to trouble if you powered the LEDs with more than 5V. They are designed as flyback protection when driving motors and should be connected to the motor supply. For your application you do not need them so just disconnect it.

Ok now this is really wierd, I put your code in, shifting out the bytes like so:

  shiftOut(dataPin, clockPin, MSBFIRST, 0x0);
  shiftOut(dataPin, clockPin, MSBFIRST, 0x8);
  shiftOut(dataPin, clockPin, MSBFIRST, 0xff);

But awkwardly enough, the board starts with 1 column of some led's lit, moves up to 2, 3, 4, 5, 6, 7, 8 then just goes column 1,2,3,4,5,6,7,8 and the whole board then stays lit, with some few maybe badly wired exceptions?, 2 rows etc are not lit and sometimes randomly get lit?

The full code:
Code:
const int clockPin = 11;
const int latchPin = 12;
const int dataPin = 13;

long int refreshDue;
long int refreshTime = 100;

void setup() {
  pinMode(dataPin, OUTPUT); //Data
  pinMode(clockPin, OUTPUT); //Clock
  pinMode(latchPin, OUTPUT); //Latch
 
  digitalWrite(dataPin, LOW);
  digitalWrite(clockPin, LOW);
  digitalWrite(latchPin, LOW);
}
void loop(){
    if(millis() >= refreshDue){
    refreshDue = millis() + refreshTime;
    refreshDisplay();
  }
}

void refreshDisplay(){
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 0x0);
  shiftOut(dataPin, clockPin, MSBFIRST, 0x0);
  shiftOut(dataPin, clockPin, MSBFIRST, 0x8);
  shiftOut(dataPin, clockPin, MSBFIRST, 0xff);
  digitalWrite(latchPin, HIGH);
}

Thanks Mike smiley
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think it is not wired up like you think it is. For the time being forget the matrix and just put out one pattern to the shift registers. Then go round with a meter or LED and resistor and see if this pattern corresponds to what you expect. Then change the pattern and repeat. Do this five or six times until you spot the fault or you verify that what you send out is what you get on the shift register outputs.
Logged

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

The registers are still connected, but im only outputting B1000000, and the first shift register is NOT getting this? I dont get it, its just displaying random data still, I placed a 0.1uf capacitor on the ground connecting to the 5v and its still random? Its killing me smiley-razz

Edit: Must be a big error, I used the following code to output 1's and 0's based on what I enter in the serial from the pc:
Code:

int latchPin = 12;
int clockPin = 11;
int dataPin = 13;

#define latchPin 12
#define clockPin 11
#define dataPin 13


void setup(){
  // Set the pins for controlling the 595(s)
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

  Serial.begin(9600);

  digitalWrite(latchPin, LOW);
  for(int chipnumber=0;chipnumber<3;++chipnumber){
    shiftOut(dataPin, clockPin, MSBFIRST, 0);
  }
  digitalWrite(latchPin, HIGH);
}

void loop(){
  if (Serial.available() > 0) {
    int butval = Serial.read();
    delay(5); // This delay and the top if loop are to debounce the button
    if(butval==48){
      digitalWrite(latchPin, LOW);
      digitalWrite(clockPin, LOW);
      digitalWrite(dataPin, LOW); //This should already be low, so it's sort of redundant. It's here for clarity
      digitalWrite(clockPin, HIGH);
      digitalWrite(latchPin, HIGH);
    }else{
      digitalWrite(latchPin, LOW); // First, set the latch low to allow new data to be written
      digitalWrite(clockPin, LOW); // Next, set the clock pin low to tell the chip to start listening
      digitalWrite(dataPin, HIGH); // Set the data bit high to write out a high bit to the register
      digitalWrite(clockPin, HIGH); // Set the clock high to save the high data bit
      digitalWrite(latchPin, HIGH); // Finally, set the latch high to display the new contents of the register
      digitalWrite(dataPin, LOW); // Just to keep to data path clear
    }
    Serial.println(butval);
  }
}




I start off entering 1,1,1,1,1,1,1,1,1,1,,1,1,1,1,,1,1,,1,,,11 just a bunch of 1's, the output is random

Then i tried outputting 0's, the output followed the same pattern as what happend with 1's

Alas, when I finished entering a bunch of 0's, I entered the 1's slowly to see what got lit, these are the results


Key: Row, Col 1, Col 2

(Im shifting bits not bytes)

Shifted: 1
Returned: 00000000,00000000,00000000

(NOTE NOTHING RETURNED)

Shifted: 1
Returned: 00000001,00000000,00000000

Shifted: 0
Returned: 00000011,00000000,00000000

Shifted: 0
Returned: 00000110,00000000,00000000

Shifted: 1
Returned: 00001100,00000000,00000000

Shifted: 1
Returned: 00011001,00000000,00000000

Notice that the delay returning between shifts? this is manual shifting btw, with the code above...

So thats interesting right? then it got me :3, y not try add a random 1 before every shift out to see if that fixes the order? And it....
(Im doing this while I work on it so as I type Im updating results)

Doesnt work smiley-razz, yet Im getting close, for some reason the shift out is screwy... whenever I use my own single bit shifting it works, but whenever I try to bit shift the whole byte, it doesnt?

I am going to try something else after dinner, hopefully it will work smiley



« Last Edit: September 19, 2012, 02:32:17 am by xXN1pplefaceXx » Logged

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

I GOT IT WORKING smiley

one small kind of major issue, it only works if I turn the latch on and off every time I change a bit, when I try it any other way it wont work, so every led is a little bit on...
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34246
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I GOT IT WORKING
smiley smiley smiley smiley smiley

Quote
it only works if I turn the latch on and off every time I change a bit,
That is most odd and not correct. Have you got the clock and latch mixed up or are they some how shorted together?
Logged

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

Quote
I GOT IT WORKING
smiley smiley smiley smiley smiley

Quote
it only works if I turn the latch on and off every time I change a bit,
That is most odd and not correct. Have you got the clock and latch mixed up or are they some how shorted together?

depends, I dont think so, if I do that would be embarrasing... i have to hand it in tomorrow, my "teacher" wont mind too much if its unfinished yet if I explain there shouldnt be a problem, im gonna fix this when hes finished marking it I hope ;P

Thanks Grumpy Mike for all your help smiley +1
Logged

Pages: 1 2 3 [4]   Go Up
Jump to: