Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How does 74HC575's Serial Out works?

Status
Not open for further replies.
Joined
Dec 4, 2012
Messages
4,280
Helped
822
Reputation
1,654
Reaction score
791
Trophy points
1,393
Location
Bangalore, India
Activity points
0
I know that DS is the Serial data input and MSB is sent first to 74HC595 in Matrix project. On every Clock Pulse on SH_CP the Serial data goes in. After 8 bits are sent into the devices' Shift register a clock pulse on ST_CP transfers the contents on Shift registers to Storage registers which appear at the output in parallel. Ther is Q7S which is used for cascading 74HC595. I want to know how to send data so that if there is 3 74HC595 cascaded then how to send the first 8 bits to the 3rd 74HC595 and second 8 bits to the second 74HC595 and the last 8 bits to the 1st 74HC595. I have connected Q7S or one to DS of another.
 

Yes, All MR are connected and all OE are connected, and all SH_CP are connected, and all ST_CP are connected. Thanks for the answer. I was trying to send 8 bits and then clocking ST_CP once.


Thank you bigdogguru. I will try those tutorials.

Edit: Why this is not working? Files attached. I am scanning rows (anodes). Character arrays are ok. Matrix are scanned top to bottom. Three characters A, B and C are transferred in 74HC595 3 times 8 bits at a time. So, 24 bits are transferred at a time. Array is like this

A0, A1, A2, A3, A4, A5, A6, A7, B0, B1, B2, B3, B4, B5, B6, B7, C0, C1, C2, C3, C4, C5, C6, C7

A0, B0, C0 is transferred to 74HC595 with 3 * 8 clocks and then one clock is given to ST_CP

then row 1 is turned on for 1 ms and then row is shifted. next A1, B1, C1 is shifted into 74HC595 and STCP is applied and then pow 2 is turned ON for 1 ms and then row is shifted. I am having problem in turning OFF the row after a data is displayed for 1 ms. How to turn OFF PORTD. I can't use 0x00 as I need to shift from 0x00 to 0x80 continuously.


PHP:
For Character 'A'


Matrix is

11000011
10111101
10111101
10111101
10111101
10000001
10111101
10111101
 

Attachments

  • Matrix rev2.rar
    55 KB · Views: 102
  • Matrix rev3.rar
    180 KB · Views: 116
Last edited:

There was some error in the code. I fixed it but now I don't see any signal on DS line. I am now using col scanning. rows are connected to 74HC595. I debugged in Proteus but DS never toggles. I am attaching rev6 file. Please check it and tell me what is wrong. This time I am sending A A A to the three displays. If any pin of PORTD is 1 then col connected to that line is active.


Here is the code. I don't know what is causing DS to be always 0.

Edit: Fixed the problem but still not getting the characters.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#define SH_CP RC0_bit
#define ST_CP RC1_bit
#define DS PORTC.F2
 
unsigned char matrixData[] = {0x00, 0xFE, 0x21, 0x21, 0x21, 0x21, 0xFE, 0x00, 0x00, 0xFE, 0x21, 0x21, 0x21, 0x21, 0xFE, 0x00, 0x00, 0xFE, 0x21, 0x21, 0x21, 0x21, 0xFE, 0x00};
unsigned int count = 0, repeat = 0, datastored = 0;
 
void Send_Data(){
 
unsigned int t, num, Flag, Mask, index = 0;;
 
    PORTD = 0x01;
    
    for(count = num*8;count < (num*8+8);count++){                     //sends array elements 0,1,2,3,4,5,6,7 and 8,9,10,11,12,13,14,15 and 16, 17, 18, 19, 20, 21, 22, 23
 
        index = num;                                                  //first loop index is 1 then 2, 3, 4, 5, 6, 7, 8, 9, ...
        for(datastored = 0; datastored < 3; datastored++);{           //loops 0 to 2 (loops three times)
                Mask = 0x80;                                          //Mask
                for (t=0; t<8; t++){                                  //loops 8 times and sends 8 bits of an array element to 74HC595, Character 'A' is sent 3 times
                                                                      //3 * 8 = 24 bits is transferred to 74HC595
                   if(matrixData[index] & Mask)DS = 0;
                    else if(!(matrixData[index] & Mask))DS = 1;
                         SH_CP = 1;                                   //SH_CP is clocked for every bit
                         Delay_us(10);
                         SH_CP = 0;
                         Mask = Mask >> 1;                            //Mask is shifted to test next bit. (MSB to LSB)
                }
                index =  index + 8;                                   //index is incremented 8 times, A1, A1, A1 is sent (elements 0, 8, 16), second loop (elements 1, 9, 17 is sent)...
                                                                      //array is like this...
                                                                      //A0, A1, A2, A3, A4, A5, A6, A7, A0, A1, A2, A3, A4, A5, A6, A7, A0, A1, A2, A3, A4, A5, A6, A7,
        }
 
        //OE = 0;
        ST_CP = 1;                                                    //ST_CP is clocked after transferring 24 bits.
        Delay_us(10);
        ST_CP = 0;
        Delay_ms(2);                                //display each col 2 ms.
        //OE = 1;
        PORTD = PORTD << 1;                                          //PORTD (col) is shifted
 
    }
}
 
void main(){
 
      TRISC = 0x00;
      TRISD = 0x00;
      PORTC = 0x00;
      PORTD = 0x01;
 
      while(1){
             Send_Data();
      }
}





Edit 2: Now matrix is working but I am not getting characters. All the leds light up.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define SH_CP RC0_bit
#define ST_CP RC1_bit
#define DS PORTC.F2
#define OE PORTC.F3
 
unsigned char matrixData[] = {0x00, 0xFE, 0x21, 0x21, 0x21, 0x21, 0xFE, 0x00, 0x00, 0xFE, 0x21, 0x21, 0x21, 0x21, 0xFE, 0x00, 0x00, 0xFE, 0x21, 0x21, 0x21, 0x21, 0xFE, 0x00};
unsigned int count = 0, repeat = 0, datastored = 0;
 
void Send_Data(){
 
unsigned int t, num, Flag, Mask, index = 0;;
 
    PORTD = 0x01;
    
    for(count = num*8;count < (num*8+8);count++){                     //sends array elements 0,1,2,3,4,5,6,7 and 8,9,10,11,12,13,14,15 and 16, 17, 18, 19, 20, 21, 22, 23
 
        index = num;                                                  //first loop index is 1 then 2, 3, 4, 5, 6, 7, 8, 9, ...
        for(datastored = 0; datastored < 3; datastored++);{           //loops 0 to 2 (loops three times)
                Mask = 0x80;                                          //Mask
                for (t=0; t<8; t++){                                  //loops 8 times and sends 8 bits of an array element to 74HC595, Character 'A' is sent 3 times
                                                                      //3 * 8 = 24 bits is transferred to 74HC595
                    if(matrixData[index] & Mask)DS = 0;
                    else if((matrixData[index] & Mask) == 0)DS = 1;
                         SH_CP = 1;                                   //SH_CP is clocked for every bit
                         Delay_us(10);
                         SH_CP = 0;
                         Mask = Mask >> 1;                            //Mask is shifted to test next bit. (MSB to LSB)
                }
                index =  index + 8;                                   //index is incremented 8 times, A1, A1, A1 is sent (elements 0, 8, 16)
                                                                      //array is like this...
                                                                      //A0, A1, A2, A3, A4, A5, A6, A7, A0, A1, A2, A3, A4, A5, A6, A7, A0, A1, A2, A3, A4, A5, A6, A7,
        }
 
        OE = 0;
        ST_CP = 1;                                                    //ST_CP is clocked after transferring 24 bits.
        Delay_us(10);
        ST_CP = 0;
        Delay_ms(2);
 
        OE = 1;
        PORTD = PORTD << 1;                                          //PORTD (col) is shifted
 
    }
}
 
void main(){
 
      TRISC = 0x00;
      TRISD = 0x00;
      PORTC = 0x00;
      PORTD = 0x00;
      CMCON = 0x07;
      
      while(1){
             Send_Data();
      }
}

 

Attachments

  • Matrix rev6.rar
    55.8 KB · Views: 108
  • matrix.rar
    16.5 KB · Views: 113
Last edited:

I wrote a new code using XC8. The array I am using for character data is wrong. The array which is commented out at the top is the right array but if I use that not is displayed. I have added 160 ms delay to see the scanning of columns. I am trying to send character 'A' 3 times into 74HC595 so that I get 'A 'A' 'A' on the 3 matrices. There is no scrolling. Just the 'A' is shifted into 3 74HC595. cathodes are columns and anodes are rows. coloumns are scanned using PORTD. Each character has 8 elements in array.

First 0th, 8th, 16th elements are shifted (24 bits) into 74HC595 and then stored and then the 1st col is scanned
Next

1st, 9th, 17th elements of arrays are shifted and stored and 2nd col is scanned

2nd, 10th, 18th elements...
...
 

Attachments

  • XC8.rar
    131.3 KB · Views: 139

Hi;

See attached ...
(I don't have XC8 so MikroC was used)

Had to change the source and the DSN too ...
The most important thing is that we had to replace (Y mirror) the matrix row and column sides (and also no invertings, see the properties).
There are little unusual (reversed) chained HC595 (see my other DSN examples).
In the source were many errors, too ...

-This line
PORTB = PORTB >> 1;
- does not work on a PIC18, use this instead
LATB = LATB >> 1

Hope this helps
zuisti
 

Attachments

  • Matrix_zuisti_to_jajanth.zip
    24 KB · Views: 155
Thank you very much zuisti. I will test it and reply soon.

- - - Updated - - -

Thank you very much zuisti. I will test it and reply soon.

Please explain this...
The most important thing is that we had to replace (Y mirror) the matrix row and column sides

I was using NOT gate because my coloums were cathodes and rows anodes. I was providing 1 from PORTD and then shifting it to select columns. coloumns had to be grounded. Not gate were grounding the respective column.


In your file are rows cathodes or anodes. The Proteus matrix is so confusing.


In your code you are scanning the matrix from top to bottom and not left to right, right? That is you are scanning columns with PORTD but row data are sent one row at a time from top row to bottom row. Right?



Does giving a pulse to SH_CP and ST_CP once every while(1) loops shifts the characters on the matrix display?
 
Last edited:

Please explain this...
Hi;
This is YOUR dsn and YOUR source, with my little modifications, now it is working as you expected.

Seems you are mistaken about the matrix rows and columns.
In this case (4 x 8x8 matrix) we have 8 horizontal rows and 4x8=32 vertical columns, right?
PORTD controls the rows (now without inverting, active high, bit 1 = row is selected, ie it's switched on) and the 595 chain controls the columns, also active high (bit 1 = led on).
You can see we are using the row-scanning method.
To avoid the external inverters the matrix property was modified: the default row inverting line {INVERT=A,B,C,D,E,F,G,H} is switched off (commented out using a semicolon).
Note the matrix row pins are named as A,B,C ... and NOT as 1,2,3 ... in that position what you are using in the "matrix bckp5.DSN" (this was modified by me) so have to a vertical (Y) mirroring.

The project is using the COF file (instead of the HEX) so you able to use the source level debugging in step-by-step mode too (also see the logic state of pins).

zuisti
 
In this case (4 x 8x8 matrix) we have 8 horizontal rows and 4x8=32 vertical columns, right?

No, we have 3 * 8X8 matrices = 8 rows and 24 columns.
I added a delay and saw that row is being scanned that is matrix is scanned from bottom row to top row. (horizontal)
PORTD is controlling the rows and I see that initially PORTD is 0x80, so, bottom row is the starting point for scanning. Right?

To avoid the external inverters the matrix property was modified: the default row inverting line {INVERT=A,B,C,D,E,F,G,H} is switched off (commented out using a semicolon).
I need an example of real matrix. rows are not inverted in your example. so, rows are anodes and columns are cathodes. Right?

Please add labels to row and columns of matrix and send it to me. I get confused when matrix is flipped and rotated.

Another question. How to scroll? I tried different ways like.

1, shifting each element of array 1 bit to right or left and then also shifting the array elements to right or left (rotating array with reloading of original array after 24 hifts).
2. Keeping array as it is and just providing one more SH_CP after 24 bits are shifted into 595 and then giving a ST_CP.

Like I sift 24 bits of data and then give one extra SHCP and then ST_CP. (second loop)
Shift 24 bits of data and then give 2 more SH_CP and then ST_CP. (second loop)
...
Shift 24 bits data and then give 24 more SH_CP and then ST_CP. (24th loop) (display will be blank) (scrolling but not rotating display)

But they are not working.
 

No, we have 3 * 8X8 matrices = 8 rows and 24 columns
Yes, my mistake, sorry ...

I added a delay and saw that row is being scanned that is matrix is scanned from bottom row to top row. (horizontal)
PORTD is controlling the rows and I see that initially PORTD is 0x80, so, bottom row is the starting point for scanning. Right?
No, see the logical levels and the individual leds, the matrix top row is its H pin, tied to PORTD.7

I need an example of real matrix. rows are not inverted in your example. so, rows are anodes and columns are cathodes. Right?
No, now (in this DSN) both are anodes :)-D) ie active high for a simple and fast simulation. The reality is an other thing: the necessary high-current drivers may be inverting at the row side. In this simplified case use (row side) common anode matrices. To control the common cathode (active low) columns have to invert the bit for DS:


Code C - [expand]
1
2
3
4
5
//DS = the corresponding bit:
                    if (value & mask)
                       DS = 0; // inverted !!!!!!!!!!!!!
                    else 
                       DS = 1;



Please add labels to row and columns of matrix and send it to me. I get confused when matrix is flipped and rotated.
There are labels in the DSN: simply place the cursor over a matrix pin while the simulation is off and see the status line.
The row labels are A (bottom),B,C, .. H while the column labels are 1, 2, 3 .. 8
.
How to scroll?
Sorry but I don't have more time, this is your task. There are a lot of solutions (even here, on the forum) ...

However, here is a 'new' source:

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
Using a two-dimensional bitmap array it's more clear I hope.
(some more little modifications and verbose comments).
*/
#define SH_CP LATC0_bit
#define ST_CP LATC1_bit
#define DS    LATC3_bit
 
const char matrixData[][8] = {
{// char 'A' = 41h
0b00110000, //top line (row)
0b01111000,
0b11001100,
0b11001100,
0b11111100,
0b11001100,
0b11001100,
0b00000000
},
{// char 'B' = 42h
0b11111100,
0b01100110,
0b01100110,
0b01111100,
0b01100110,
0b01100110,
0b11111100,
0b00000000
},
{// char 'C' = 43h
0b00111100,
0b01100110,
0b11000000,
0b11000000,
0b11000000,
0b01100110,
0b00111100,
0b00000000
}};
 
unsigned char datastored; //for max 255 chars, for larger msg use unsigned int here
 
void Send_Data(){         //display Characters A B and C no scrolling
    unsigned char bitcnt, value, mask, rows, PortDvalue;
 
    PortDvalue = 0x80; //first the top row (matrix H pin) is on, reversed row order:
    for(rows = 0 ; rows < 8 ; rows++) {  // 8 rows (0..7)
        for( datastored = 0 ; datastored < 3 ; datastored++) { //3 chars (0..2)
                //get and temporaly store the actual byte:
                value = matrixData[datastored][rows];
                mask = 1; //first the bit 0, reversed column order in DSN
                for (bitcnt = 0; bitcnt < 8; bitcnt++) { //8 bits (0..7)
                    //DS = the corresponding bit:
                    if (value & mask)
                       DS = 1;
                    else 
                       DS = 0;
                    //positive pulse to shift in the bit:
                    SH_CP = 1;
                    SH_CP = 0;
                    mask = mask << 1; //prepare to next bit
                }
        }
        LATD = 0;   //lines off to avoid shadows
        //positive pulse to load the HC595 output regs (store the new col datas):
        ST_CP = 1;
        ST_CP = 0;
        LATD = PortDvalue; //switch on the actual line
        Delay_ms(1);       //time to see it
        PortDvalue >>= 1;  //prepare to next row
    }
}
 
void main(){
      //port C and D are outputs and set to zero
      TRISC = 0x00;
      TRISD = 0x00;
      PORTC = 0x00;
      PORTD = 0x00;
 
      while(1) Send_Data(); //infinite loop
}



Good luck
zuisti

Added:

Just to learn: programs you written here have one common (and usual) error, one redundant semicolon (;):
for( datastored = 0 ; datastored < 3 ; datastored++);{
//... body ...
}
Perhaps we should not write down also here, but this means that only the empty 'datastored for-loop' is running three times , the 'body' only once.
 
Last edited:
Hello Sir Zuisti, I have a out of topic question. Can use please make a CE majority and minority charge carrier flow simulation using 3 * 8X8 matrix. You can place E and B matrices near and B and C matrices a little far for the depletion regions.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top