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

control 8x8 matrix with 74HC595
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kikoou



Joined: 25 Oct 2011
Posts: 10

View user's profile Send private message MSN Messenger

control 8x8 matrix with 74HC595
PostPosted: Sun Feb 12, 2012 4:36 am     Reply with quote

hi everybody im new in this forum and i like to know how can i programm 8x8 led matrix with pic16F877 ,shift register 74HC595
but the first thing taht i need t know is how can i send data from the SDO pin(like 0x3F) to the SD of 74HC595 and how can i control the SH_CP,ST_CP(input of 74HC595) from the pic specially im using the picC compiler
Lemosek



Joined: 15 Oct 2011
Posts: 36

View user's profile Send private message

PostPosted: Sun Feb 12, 2012 4:46 am     Reply with quote

Hello,
This is a simple diagram how you must connect led matrix to uk.



Best regards
R.L.
kikoou



Joined: 25 Oct 2011
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Sun Feb 12, 2012 4:57 am     Reply with quote

thank you for reply
but the problem that i can't make a clear programm its so difficult and im beginner on PICC compiler i want to creat for exemple the diferent number on this led matrix but i can't send my data for exemple i need to send on the(SDO(pic)to (data)74hC595)like(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code pour char Espace
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code pour char Espace
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Code pour char Espace
0x00, 0x00, 0x00, 0x00, 0xBF, 0x00, 0x00, 0x00, // Code pour char !
0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00, // Code pour char #
0x00, 0x26, 0x49, 0x49, 0xFF, 0x49, 0x32, 0x00, // Code pour char $
0x00, 0x46, 0x26, 0x10, 0x08, 0x64, 0x62, 0x00, // Code pour char %
0x00, 0x70, 0x8E, 0x89, 0x99, 0x76, 0xC0, 0x00, // Code pour char &
0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // Code pour char '
0x00, 0x7E, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, // Code pour char (
0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x7E, 0x00, // Code pour char )
0x00, 0x00, 0x0A, 0x04, 0x0A, 0x00, 0x00, 0x00, // Code pour char *
0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00, // Code pour char +
0x00, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x00, // Code pour char ,
0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, // Code pour char -
0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, // Code pour char .
0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, // Code pour char /
0x00, 0x7E, 0xC1, 0xB1, 0x8D, 0x83, 0x7E, 0x00, // Code pour char 0
0x00, 0x04, 0x02, 0x01, 0xFF, 0x00, 0x00, 0x00, // Code pour char 1
0x00, 0xE6, 0x91, 0x91, 0x89, 0x89, 0x86, 0x00, // Code pour char 2
0x00, 0x42, 0x81, 0x89, 0x89, 0x89, 0x76, 0x00, // Code pour char 3
0x00, 0x30, 0x28, 0x24, 0x22, 0xFF, 0x20, 0x00, // Code pour char 4
0x00, 0x4F, 0x89, 0x89, 0x89, 0x89, 0x71, 0x00, // Code pour char 5
0x00, 0x7E, 0x89, 0x89, 0x89, 0x89, 0x72, 0x00, // Code pour char 6
0x00, 0x01, 0x01, 0xF1, 0x09, 0x05, 0x03, 0x00, // Code pour char 7
0x00, 0x76, 0x89, 0x89, 0x89, 0x89, 0x76, 0x00, // Code pour char 8
0x00, 0x4E, 0x91, 0x91, 0x91, 0x91, 0x7E, 0x00, // Code pour char 9
0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, // Code pour char :
0x00, 0x00, 0x80, 0x68, 0x00, 0x00, 0x00, 0x00, // Code pour char ;
0x00, 0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, // Code pour char <
0x00, 0x00, 0x28, 0x28, 0x28, 0x28, 0x00, 0x00, // Code pour char =
0x00, 0x00, 0x00, 0x44, 0x28, 0x10, 0x00, 0x00, // Code pour char >
0x00, 0x06, 0x01, 0xB1, 0x09, 0x09, 0x06, 0x00, // Code pour char ?
0x00, 0x7E, 0x99, 0xA5, 0xA5, 0xB9, 0x5E, 0x00, // Code pour char @
0x00, 0xE0, 0x1C, 0x13, 0x13, 0x1C, 0xE0, 0x00, // Code pour char A
0x00, 0xFF, 0x89, 0x89, 0x89, 0x8E, 0x70, 0x00, // Code pour char B
0x00, 0x7E, 0x81, 0x81, 0x81, 0x81, 0x42, 0x00, // Code pour char C
0x00, 0xFF, 0x81, 0x81, 0x81, 0x42, 0x3C, 0x00, // Code pour char D
0x00, 0xFF, 0x89, 0x89, 0x89, 0x81, 0x81, 0x00, // Code pour char E
0x00, 0xFF, 0x09, 0x09, 0x09, 0x01, 0x01, 0x00, // Code pour char F)
kikoou



Joined: 25 Oct 2011
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Sun Feb 12, 2012 5:20 am     Reply with quote

all that im asking you is helping me to know how can i write just one number and evrything gone be clear in mind it depend only in one number no more
and thank you again for helping me Lemosek
and now im using the ULN2804
temtronic



Joined: 01 Jul 2010
Posts: 9240
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 12, 2012 6:48 am     Reply with quote

I suggest you start with the '595 example that CCS kindly supplies in the Examples folder that you got with the compiler. By experimenting with it, you'll quickly see the code required to control the '595.

Sending data to the '2803 is a simple byte transfer

Taking what you learn from both and merging the two programs will give you what you to do.
Lemosek



Joined: 15 Oct 2011
Posts: 36

View user's profile Send private message

PostPosted: Sun Feb 12, 2012 9:13 am     Reply with quote

Hello I also suggest to see EX_EXPIO.c in PICC/Example folder.

If it help you, I have some code for gcc compiler, so You can transfer this to CCS.
Code:

void writeOutputs()
{

uint8_t j;

   ClrGPIOBit(EXP_OUT_CLOCK_PORT, EXP_OUT_CLOCK_BIT);
   ClrGPIOBit(EXP_OUT_ENABLE_PORT, EXP_OUT_ENABLE_BIT);


   for(j=1;j<=NUMBER_OF_74595*8;++j)
   {
      if(OUT.Outputs[j]==1)
      {
         SetGPIOBit(EXP_OUT_DO_PORT,EXP_OUT_DO_BIT);

      }

      if(OUT.Outputs[j]==0)
      {
         ClrGPIOBit(EXP_OUT_DO_PORT,EXP_OUT_DO_BIT);

      }

      SetGPIOBit(EXP_OUT_CLOCK_PORT,EXP_OUT_CLOCK_BIT);

      ClrGPIOBit(EXP_OUT_CLOCK_PORT,EXP_OUT_CLOCK_BIT);


   }

   SetGPIOBit(EXP_OUT_ENABLE_PORT, EXP_OUT_ENABLE_BIT);

}

void Set74Bit(uint8_t BitNumber, uint8_t State)
{
    OUT.Outputs[BitNumber] = State;
    writeOutputs();
}

void Set74Byte(int ByteNumber, unsigned char Value)
{


   OUT.Outputs[ByteNumber*8+1] = ((Value & 0x01) ? 1 : 0);
    OUT.Outputs[ByteNumber*8+2] = ((Value & 0x02) ? 1 : 0);
    OUT.Outputs[ByteNumber*8+3] = ((Value & 0x04) ? 1 : 0);
    OUT.Outputs[ByteNumber*8+4] = ((Value & 0x08) ? 1 : 0);
    OUT.Outputs[ByteNumber*8+5] = ((Value & 0x10) ? 1 : 0);
    OUT.Outputs[ByteNumber*8+6] = ((Value & 0x20) ? 1 : 0);
    OUT.Outputs[ByteNumber*8+7] = ((Value & 0x40) ? 1 : 0);
    OUT.Outputs[ByteNumber*8+8] = ((Value & 0x80) ? 1 : 0);

    writeOutputs();
}


Best regards
R.L.
kikoou



Joined: 25 Oct 2011
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Sun Feb 12, 2012 10:09 am     Reply with quote

plz somebody help me to find this code because we are beginner in programing on PICC and i need to know how can i program things like that.
temtronic



Joined: 01 Jul 2010
Posts: 9240
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 12, 2012 12:25 pm     Reply with quote

You've got to crawl before you can run let alone walk.

Please, you must try the examples for the 595 that CCS supplies.Get familiar with the style of coding, and create your own programs, simple stuff like turning on specific LEDS using the 595 driver that CCS supplies.
Most everyone here is happy to help but you have to show effort to try it on your own, especially the basics like 'blinking LED' programs.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Make it simpler
PostPosted: Mon Feb 13, 2012 8:10 am     Reply with quote

If you want to make things a lot simpler, throw out the peripheral chips and drive the LED matrix directly from two PIC ports.

Say drive the anodes from port D and cathodes from port C. Don't forget to include sufficiently large value resistors in series with the anodes as shown in Lemosec's schematic.

The display may be rather dim, but you should not run the risk of burning out your LEDs. LED matrix driving has been discussed many times, and at length, on this forum.

Like temtronic says you must do some work yourself, then people are willing to help you.

Mike
kikoou



Joined: 25 Oct 2011
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 13, 2012 11:49 am     Reply with quote

I don't know how can i put my schematics on ccsinfo. And it will be better if you can see my schematics because thats make you feeling how much I'm good on electronics. But my problem is that I'm beginner on PICC compiler. Just all that i need is the right code because thats help me to know how can i do things right.
For your attention I did it with 20 8x8 matrix and without 16f877 but now i like to control it with 16f877.
kikoou



Joined: 25 Oct 2011
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Mon Feb 13, 2012 12:56 pm     Reply with quote

plz at least help me to create just one number because i tried really so hard but i can't find the way to accomplish my desire just to give you some information about my schematic
pic 16f877:
pin_C5==data 74HC595
pin_C6==clk74HC595
pin_C3==RCLK74HC595
all what can i do to create M is:
Code:

#include <16F877.h>
#use delay(clock=40000000)
#define   DATA   pin_c5
#define   CLOK   pin_c3
#define   RCLOK pin_c6

void main()
{
int i,const byte  DIG[]={ 0x7F,0x7F, 0x02, 0x04, 0x02, 0x7F,0x7F } //  M

for(i=0;i<8;i++)
{
output_c(i)
}

I know that I'm wrong but just i need some help to make things right.
Thanks in advance for helping me to accomplish what I'm doing.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Start from simple beginnings
PostPosted: Mon Feb 13, 2012 3:09 pm     Reply with quote

I'm suggesting you connect your matrix as:-

Port D driving anodes.

Port C driving cathodes via current limiting resistors.

Code:

                        -----------------
RD7 -------------------| o o o o o o o o |
RD6 -------------------| o o o o o o o o |
RD5 -------------------| o o o o o o o o |
RD4 -------------------| o o o o o o o o |
RD3 -------------------| o o o o o o o o |
RD2 -------------------| o o o o o o o o |
RD1 -------------------| o o o o o o o o |
RD0 -------------------| o o o o o o 0 0 |
                        -----------------
                         | | | | | | | |
RC7 -------WWW-----------  | | | | | | |
RC6 -------WWW-------------  | | | | | |
RC5 -------WWW---------------  | | | | |
RC4 -------WWW-----------------  | | | |
RC3 -------WWW-------------------  | | |
RC2 -------WWW---------------------  | |
RC1 -------WWW-----------------------  |
RC0 -------WWW-------------------------



The CCS example EX_LED.C shows how to drive 2 seven segment LEDs.

This arrangement is the same expanded to 8.

Like temtronic says start by flashing one LED and grow from there.

You can control individual LEDs with statements like output_high(PINxx) and output_low(PINxx).

Then move on to driving complete ports all at one go, and finally the entire matrix of 8 columns in sequence.

You say you've driven 20 8*8 devices before. So you must know about multiplexing.

It's all there in the CCS example. You've got 8 LED columns instead of the two separate seven segment displays. You simply expand on their sample.

Mike.
temtronic



Joined: 01 Jul 2010
Posts: 9240
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Feb 13, 2012 3:14 pm     Reply with quote

I like using 'W's for resistors instead of '_/\/\/\_' !!
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Mon Feb 13, 2012 3:22 pm     Reply with quote

Thanks

Mike
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

To kikoou
PostPosted: Mon Feb 13, 2012 4:21 pm     Reply with quote

You keep asking for complete compilable code to drive your matrix.

The reasons we're not doing it include:-

(1) A lot of us charge $$$$$ or ££££ for that kind of work.
(2) You will learn nothing.
(3) You'll come back to us again the next time you have any sort of problem, and expect another freebie .

Do a search on "matrix" on this forum. There are loads of discussions on how to do your job. Don't expect complete code.

Mike
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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