CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How can connect more than 10 74595

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 17, 2003 6:31 pm     Reply with quote

Here is some code I once used to test driving an 7-segment
LCD with five 74HC595 chips. I used a 16F628 for that project.

This is just a piece of the code. It's not the whole program.
Hopefully it will work in your application.

I've modified the pin numbers below, to match your
description. You should check it and verify it.

Code:
#define SDATA_PIN  PIN_B2   // SER (pin 14 of first 74HC595)
#define SCLK_PIN   PIN_B1   // SRCLK  (pin 11 of all 74HC595)
#define RCLK_PIN   PIN_B0   // RCLK    (pin 12 of all 74HC595)

char data[5];

//================================
void main()
{

// Initialize the 74HC595 control pins.
output_low(SDATA_PIN);
output_low(SCLK_PIN);
output_low(RCLK_PIN);

// Send out 5 bytes of data to the chain of five
// 74HC595 chips. 
send_byte(data[4]);
send_byte(data[3]);
send_byte(data[2]);
send_byte(data[1]);
send_byte(data[0]);

// After shifting out the data to the 74HC595 chips,
// issue a clock pulse to load it into the output registers
// inside those chips.
load_reg();

while(1);
}

//================================
// This function loads the output registers
// of all the 74HC595 chips.

void load_reg(void)
{
output_high(RCLK_PIN);     // Make a positive clock pulse
output_low(RCLK_PIN);
}

//-------------------------------------
// This function sends one byte to the chain of
// 74HC595 shift registers.

void send_byte(char data)
{
 char i;

 for(i = 0; i < 8; i++)           // Send 8 bits
    {
     if(data & 0x80)
       {     
        output_high(SDATA_PIN);
       }
     else
       {
        output_low(SDATA_PIN);
       }

     output_high(SCLK_PIN);     // Make a positive clock pulse
     output_low(SCLK_PIN);
 
     data <<= 1;                // Get next bit into MSB position       
   }
}
kamyip



Joined: 14 Oct 2003
Posts: 10

View user's profile Send private message

PostPosted: Fri Oct 17, 2003 11:05 pm     Reply with quote

If your are using 74595 to display Leds and lots of them, than I suggest you looks into using SAA1064 i2c chip. One SAA1064 allows you to control 16 leds and if you use two of them in matrix, you would be able to control 256 leds! All this just by using 2 pin ie SDA and SCL.
elphi



Joined: 17 Apr 2007
Posts: 20
Location: tijuana,bajacalifornia,mexico

View user's profile Send private message MSN Messenger

PostPosted: Mon Jun 08, 2009 1:00 am     Reply with quote

Hi PCM Programmer, I have used this code to handle 10 seven segments displays, and I make a entire system and it work ok, so I am making a second system, this time it has only 8 displays, but it is working with a very unusual bug, if I send 10 diferent values (e.g 12345678), but when I sent 8 values of the same value (e.g. 11111111), the display show a lot of garbage, do you have any idea of why I have this bug in my system.

I have modificated the code you have built to display 7 segments values, ad I make a source file to be called for the main file each time it has to display new values, the source file is shown below:

Code:

void send_byte(int num)
{
   int data;
   char i;
   switch(num){
      case 0:data=63;break;
      case 1:data=6;break;
      case 2:data=91;break;
      case 3:data=79;break;
      case 4:data=102;break;
      case 5:data=109;break;
      case 6:data=125;break;
      case 7:data=7;break;
      case 8:data=127;break;
      case 9:data=103;break;
      case '0':data=63;break;
      case '1':data=6;break;
      case '2':data=91;break;
      case '3':data=79;break;
      case '4':data=102;break;
      case '5':data=109;break;
      case '6':data=125;break;
      case '7':data=7;break;
      case '8':data=127;break;
      case '9':data=103;break;
      default: data=0;
   }
   for(i = 0; i < 8; i++)           // Send 8 bits
   {
      if(data & 0x80)
      {
        output_high(SDATA_PIN);
       }
     else
       {
        output_low(SDATA_PIN);
       }
     output_high(SCLK_PIN);     // Make a positive clock pulse
     output_low(SCLK_PIN);
     data <<= 1;                // Get next bit into MSB position

   }
}


void load_reg(void)
{
output_high(RCLK_PIN);     // Make a positive clock pulse
output_low(RCLK_PIN);
}

void init595()
{
output_low(SDATA_PIN);
output_low(SCLK_PIN);
output_low(RCLK_PIN);
}


and this a piece of the main code, the part of the code that calls the 749595:

Code:

void todsp()
{
   init595();
   for(i=0;i<=7;i++)
   {
      if(num[i]==32)num[i]=15;//this code is to convert “spaces” in blank displays
   }
   
   numd[7]=num[0];
   numd[6]=num[1]+10;
   numd[5]=num[2];
   numd[4]=num[3];
   numd[3]=num[4];
   numd[2]=num[5]+10;
   numd[1]=num[6];
   numd[0]=num[7];
      for(i=0;i<=7;i++)
   {
      send_byte(15);//before sent the desires values I send 8 blanks to clear the displays
   }
   load_reg();
   for(i=0;i<=7;i++)
   {
      send_byte(numd[i]);//now I send each digit.
   }
   load_reg();
   for(i=0;i<=7;i++)
   {
      if(num[i]==15)num[i]=32;
   }
   }


I hope you can help me because I don understand why this bug is only in this system and not in my first system, the only difference between the first and the second system is that the first one has 10 digits and the second one has only 8.
_________________
Every little thing gonna be alright
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 08, 2009 11:51 am     Reply with quote

Disconnect the last two 74595 chips on your new board, and connect it
to be the same as your previous board. Also use the software for your
previous board. Then see if it works.
elphi



Joined: 17 Apr 2007
Posts: 20
Location: tijuana,bajacalifornia,mexico

View user's profile Send private message MSN Messenger

PostPosted: Tue Jun 09, 2009 8:13 pm     Reply with quote

Thanks PCM Programmer, I found the solution, it was the wire, I have 16 PCB, with 7 segments x 12 LED's each segment, so I wasn’t working in a PCB, they were wired one by one with wire, so I was using an inappropriate wire, so if some one needs to do some similar, be advise, you better use UTP cable or some similar one, you can't imagine how much is the difference if you don’t use the appropriate wire.
_________________
Every little thing gonna be alright
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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