PIC184520 with 74HC595

Status
Not open for further replies.

djc

Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
4,554
HI,

Can anybody plz tell me how to program 74HC595 with said controller when both clock and latch pins of 74HC595 are shorted together.
How should i start? I am using mikroC PRO for PIC. Plz guide.

Thanking you
 

hi pillai,

I have 12 FND's which will be selected by 2 74HC595 and third 74HC595 will be used to display the data.
 

Hi,
While using 74HC595 we have to shift the data bit by bit. Now if I have 7 segment display data for nos from 0-9. I have stored that data in an array in binary form as follows,
int arr[10] = {0b00010001,0b01111101,0b00100011,0b00100101,0b01001101,0b10000101,0b10000001,0b00111101,0b00000001,0b00000101};

Now i have a doubt that how to access this data bit by bit and send it on Data line of 74HC595. Because arr[0] or arr[1] would mean 0th or 1st element of an array? then how to access it bit wise? Plz guide.
 

Hi all,
Facing problem once again this is my modified code.
Code:
#define Select_DS     PORTD.B7       //May only DS,STCP and SHCP pins are used
#define Select_Clk     PORTD.B6
#define Data_DS       PORTD.B5
#define Data_Clk      PORTD.B4
#define Relay         PORTD.B3
#define Buzzer        PORTD.B2

   int k=0,i=0,j=0,l=0;
   int arr_large[10] = {17,125,35,37,77,133,129,61,1,5};
   
   void main() {
          long int decimalNumber,remainder,quotient;
          int binaryNumber[100],i=1,j,k;


          TRISD = 0x00;
          
          Select_Clk = 0;

          Select_DS = 1;            //1
          Select_Clk = 1;
          Select_Clk = 0;

          Select_DS = 0;            //2
          Select_Clk = 1;
          Select_Clk = 0;

          Select_DS = 0;            //3
          Select_Clk = 1;
          Select_Clk = 0;

          Select_DS = 0;            //4
          Select_Clk = 1;
          Select_Clk = 0;

          Select_DS = 0;            //5
          Select_Clk = 1;
          Select_Clk = 0;

          Select_DS = 0;            //6
          Select_Clk = 1;
          Select_Clk = 0;

          /*Select_DS = 0;          //7
          Select_Clk = 1;
          Select_Clk = 0;

          Select_DS = 0;          //8
          Select_Clk = 1;
          Select_Clk = 0;*/
          
          while(1){
          for(l=0;l<=9;l++){
          quotient = arr_large[l];
          //quotient = arr_large[7];
          while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                             for(j = i -1 ;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Data_Clk = 0;
                             Delay_us(10);
                             }
                 Data_Clk = 1;
                 Data_Clk = 0;
                 Delay_ms(1000);
            }
      }
}

In this code i have used decimal no and converted it to binary no to send it on 74hc595. To access array i used variable l then convert it to binary no. By using select clock i am selecting particular FND. But issue is it's displaying only first no that is zero and variable is not incrementing. Why it is happening? can any body plz guide.
 

hi jestin,
issue is solved now. It was correcting just one variable.

Thanking you.
 

Hi all,

i am facing new issue in above project. When i display the data on particular FND , data displays perfectly however remaining segments of FND also glows little bit. Why is this happening ? After displaying the data i am sending one blanking pulse too/, but issue still remains same. Can u guys plz guide me. I cannot change the hardware. Code is as follows
Code:
#define Select_DS     PORTD.B7
#define Select_Clk     PORTD.B6
#define Data_DS       PORTD.B5
#define Data_Clk      PORTD.B4
#define Relay         PORTD.B3
#define Buzzer        PORTD.B2

 // unsigned long int k=0,i=0,j=0,l=0;
 unsigned int arr_small[10] = {24,222,52,148,210,145,17,220,16,144};
 unsigned  int arr_large[10] = {17,125,35,37,77,133,129,61,1,5};
 unsigned  int arr_med[10] = {20,126,140,44,102,37,5,124,4,36};
 //unsigned  int Select_FND[12] = {16,32,64,128,256,512,1024,2048,4096,8192,16384,32768};
 unsigned int  decimalNumber,remainder,quotient,decimalNumber_1,remainder_1,quotient_1;
 unsigned int  binaryNumber[100],binaryNumber_1[100],i=1,j,k,l=0,m=0,q=0;


void main()
{

          TRISD = 0x00;

          Select_Clk = 0;
          Select_DS = 1;
          Delay_us(5);

          while(1){
          Select_DS = 1;
          Delay_us(5);

            for(l=0;l<=4;l++){
            quotient = arr_small[l];
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(5);
                             Data_Clk = 0;
                             Delay_us(5);
                             }
                 Data_Clk = 1;
                 Delay_us(5);
                 Data_Clk = 0;

                 Select_Clk = 1;
                 Delay_us(5);
                 Select_DS = 0;
                 Select_Clk = 0;
                 Delay_ms(1000);
                 
                           quotient = 255;                          //Data for blanking
                           i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(2);
                             Data_Clk = 0;
                             Delay_us(2);
                             }
                 Data_Clk = 1;
                 Delay_us(2);
                 Data_Clk = 0;
                 }

           for(l=0;l<=4;l++){
            quotient = arr_large[l];
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(5);
                             Data_Clk = 0;
                             Delay_us(5);
                             }
                 Data_Clk = 1;
                 Delay_us(5);
                 Data_Clk = 0;

                 Select_Clk = 1;
                 Delay_us(5);
                 Select_DS = 0;
                 Select_Clk = 0;
                 Delay_ms(1000);
                           quotient = 255;
                           i=1;
                           while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                           for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(2);
                             Data_Clk = 0;
                             Delay_us(2);
                             }
                 Data_Clk = 1;
                 Delay_us(2);
                 Data_Clk = 0;

                 }



           for(l=0;l<=6;l++){
            quotient = arr_med[l];
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(5);
                             Data_Clk = 0;
                             Delay_us(5);
                             }
                 Data_Clk = 1;
                 Delay_us(5);
                 Data_Clk = 0;

                 Select_Clk = 1;
                 Delay_us(5);
                 Select_DS = 0;
                 Select_Clk = 0;
                 Delay_ms(1000);


            quotient = 255;
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(2);
                             Data_Clk = 0;
                             Delay_us(2);
                             }
                 Data_Clk = 1;
                 Delay_us(2);
                 Data_Clk = 0;

          }
            //Delay_us(5);
         }
}

- - - Updated - - -

Hi all,

i am facing new issue in above project. When i display the data on particular FND , data displays perfectly however remaining segments of FND also glows little bit. Why is this happening ? After displaying the data i am sending one blanking pulse too/, but issue still remains same. Can u guys plz guide me. I cannot change the hardware. Code is as follows
Code:
#define Select_DS     PORTD.B7
#define Select_Clk     PORTD.B6
#define Data_DS       PORTD.B5
#define Data_Clk      PORTD.B4
#define Relay         PORTD.B3
#define Buzzer        PORTD.B2

 // unsigned long int k=0,i=0,j=0,l=0;
 unsigned int arr_small[10] = {24,222,52,148,210,145,17,220,16,144};
 unsigned  int arr_large[10] = {17,125,35,37,77,133,129,61,1,5};
 unsigned  int arr_med[10] = {20,126,140,44,102,37,5,124,4,36};
 //unsigned  int Select_FND[12] = {16,32,64,128,256,512,1024,2048,4096,8192,16384,32768};
 unsigned int  decimalNumber,remainder,quotient,decimalNumber_1,remainder_1,quotient_1;
 unsigned int  binaryNumber[100],binaryNumber_1[100],i=1,j,k,l=0,m=0,q=0;


void main()
{

          TRISD = 0x00;

          Select_Clk = 0;
          Select_DS = 1;
          Delay_us(5);

          while(1){
          Select_DS = 1;
          Delay_us(5);

            for(l=0;l<=4;l++){
            quotient = arr_small[l];
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(5);
                             Data_Clk = 0;
                             Delay_us(5);
                             }
                 Data_Clk = 1;
                 Delay_us(5);
                 Data_Clk = 0;

                 Select_Clk = 1;
                 Delay_us(5);
                 Select_DS = 0;
                 Select_Clk = 0;
                 Delay_ms(1000);
                 
                           quotient = 255;                          //Data for blanking
                           i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(2);
                             Data_Clk = 0;
                             Delay_us(2);
                             }
                 Data_Clk = 1;
                 Delay_us(2);
                 Data_Clk = 0;
                 }

           for(l=0;l<=4;l++){
            quotient = arr_large[l];
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(5);
                             Data_Clk = 0;
                             Delay_us(5);
                             }
                 Data_Clk = 1;
                 Delay_us(5);
                 Data_Clk = 0;

                 Select_Clk = 1;
                 Delay_us(5);
                 Select_DS = 0;
                 Select_Clk = 0;
                 Delay_ms(1000);
                           quotient = 255;
                           i=1;
                           while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                           for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(2);
                             Data_Clk = 0;
                             Delay_us(2);
                             }
                 Data_Clk = 1;
                 Delay_us(2);
                 Data_Clk = 0;

                 }



           for(l=0;l<=6;l++){
            quotient = arr_med[l];
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(5);
                             Data_Clk = 0;
                             Delay_us(5);
                             }
                 Data_Clk = 1;
                 Delay_us(5);
                 Data_Clk = 0;

                 Select_Clk = 1;
                 Delay_us(5);
                 Select_DS = 0;
                 Select_Clk = 0;
                 Delay_ms(1000);


            quotient = 255;
            i=1;
                     while(quotient!=0){
                             binaryNumber[i++]= quotient % 2;
                             quotient = quotient / 2;
                             }
                             for(i=i;i<=8;i++)
                             {
                                 binaryNumber[i] = 0;
                             }

                      for(j = i-1;j> 0;j--){
                             Data_DS = binaryNumber[j];
                             Data_Clk = 1;
                             Delay_us(2);
                             Data_Clk = 0;
                             Delay_us(2);
                             }
                 Data_Clk = 1;
                 Delay_us(2);
                 Data_Clk = 0;

          }
            //Delay_us(5);
         }
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…