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 support@ccsinfo.com

74hc595

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







74hc595
PostPosted: Thu Oct 30, 2008 11:19 pm     Reply with quote

Hi friends,
I am Chandrika. I'm new to using 74595. In my project I have used pic
16F505 and four 74595 shift regs. One LED & 7 relays are connected to
each 74595. My problem is how can I shift data & how can I turn ON/OFF
the LED and relays. Please help me.
triple_x



Joined: 01 Dec 2005
Posts: 10

View user's profile Send private message

PostPosted: Fri Oct 31, 2008 4:55 am     Reply with quote

hi,
there are numerous discussion on 74595 shift register (serial-parallel). u can search the forum.

btw, here I attached my modified version, I'm not sure if anyone has already implemented this method, if so pls excuse. the code as below:

Code:

NOTE: This is a modified version from "\PICC\Drivers\74595.c" - what shown here is only on modified part!

////        (C) Copyright 1996,2003 Custom Computer Services           ////

// I currently use only 1 x 74595.. u can modify to suit your project

void write_expanded_outputs(BYTE* eo) {
  BYTE i;
  BYTE tmp; // ++added, to hold data passed by pointer

  // ++reason: if u manipulate data passed by pointer, ORIGINAL data will also be changed!

  // re-assign data to temp variable
  tmp = *eo;

  output_low(EXP_OUT_CLOCK);
  output_low(EXP_OUT_ENABLE);

  for(i=1;i<=NUMBER_OF_74595*8;++i) {       // Clock out bits from the eo array
  //if((*(eo+(NUMBER_OF_74595-1))&0x80)==0) // ++commented
  if ((tmp & 0x80) == 0)                    // ++manipulate temp data
    output_low(EXP_OUT_DO);
  else
    output_high(EXP_OUT_DO);
   //shift_left(eo,NUMBER_OF_74595,0);  // ++ commented
   tmp <<= 1;                           // ++manipulate temp data, shift 1 bit to the left
   output_high(EXP_OUT_CLOCK);
   output_low(EXP_OUT_CLOCK);
  }
  output_high(EXP_OUT_ENABLE);
}


Ok, thats it! Code below shows u how to use the function. To test this function, I hooked up 8 LEDs to 74595. Inside main program, there are counter which counts from 1 to 255. (2 ^ 8 = 256). Pls set IO port necessarily inside your main file.

Code:

//
// MAIN.C
//
// ok, here's my main program

void main()
{
  BYTE cnt = 1;

  while(1)
  {
     write_expanded_outputs(&cnt);
     
     if(cnt >= 255);
       cnt = 1;

     // keep counting
     cnt++;
     
     // delay a bit so u can see the LED is counting
     delay_ms(500);
  }
}



hope this help, as I'm able to have another 16-output by using 74595, 7404 and 2 x 74573 from 4-pins of 16F877A.

rgds.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Fri Oct 31, 2008 6:21 am     Reply with quote

Note that the EXP_OUT_ENABLE in Triple_X's code doesn't go to the enable line of the 74595, but to the RCLK input (pin 12, in the DIP package). If you want an on/off control for all the 595's outputs, the enable line is on pin 13. Tie it low if you don't need that feature. And tie the clear input (pin 10) high.

The outputs of the 595 don't change until you send a highgoing transition into pin 12, and then they all change at once. The serial data input is compatible with SPI, by the way, if you ever wanted to try it.
chandrika
Guest







Re: 74hc595
PostPosted: Tue Nov 04, 2008 1:48 am     Reply with quote

Hi friends,

Thanks for giving me reply for 74hc595, but my problem is I have pic16f505 and 4x74595s. I am connecting 3 push buttons to 3 pins of pic as inputs and 4 pins of pic connected to 4x74595's. I assume 4x74595's as 4 channels. When I am pressing a push button, channel change to one by one. My problem is how can I send same 1 byte data from pic 4 to 4x74595 or how can I load data into 4x74595 ? Please help me.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Nov 04, 2008 2:03 am     Reply with quote

The HC595 needs at least 3 signals (clock, data, latch), thus four HC595 need to be series conncted to a 32-bit shift register, if you want to control them individually. If you actually want to send the same data to four devices, you can connect the control signals in parallel of ourse.
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Tue Nov 04, 2008 9:01 am     Reply with quote

The fact that you're talking about 4 pins of the PIC being needed to send data to 4 74595's gives me a bad feeling for how much you know about using the '595. You only need 3 pins, no matter how many '595 chips you're using! I think you should either study the data sheet for this chip, or get someone to explain exactly how to use it. The code posted by Triple_X looks right; that should give you an idea of what to do.
Guest








load data to 4X74595 from 4 pins of 16f505 or 676
PostPosted: Wed Nov 05, 2008 4:44 am     Reply with quote

[quote="chandrika"]Hi friends,

thanks for giving me solution to my problem triple- x.......

but my problem is how can i load data in 4x674595's from 7 pins of 16f505
1-clk 2.latch 3 RB2 is connected to sdata of frist 74595

4. Rc0 is connected to sdata of second 74595

4. Rc1 is connected to sdata of third 74595
4. Rc2 is connected to sdata of fourth 74595

sorry.............. for troubling u triple-x .i hope u send solution.......
Guest








load data to 4X74595 from 4 pins of 16f505 or 676
PostPosted: Wed Nov 05, 2008 4:46 am     Reply with quote

[quote="chandrika"]Hi friends,

thanks for giving me solution to my problem

but my problem is how can i load data in 4x674595's from 7 pins of 16f505
1-clk 2.latch 3 RB2 is connected to sdata of frist 74595

4. Rc0 is connected to sdata of second 74595

4. Rc1 is connected to sdata of third 74595
4. Rc2 is connected to sdata of fourth 74595

sorry.............. for troubling u friends .i hope u send solution.......
chandrika
Guest







Re: load data to 4X74595 from 4 pins of 16f505 or 676
PostPosted: Wed Nov 05, 2008 4:48 am     Reply with quote

[quote="Anonymous"]
chandrika wrote:
Hi friends,

thanks for giving me solution to my problem

but my problem is how can i load data in 4x674595's from 7 pins of 16f505
1-clk 2.latch 3 RB2 is connected to sdata of frist 74595

4. Rc0 is connected to sdata of second 74595

4. Rc1 is connected to sdata of third 74595
4. Rc2 is connected to sdata of fourth 74595

sorry.............. for troubling u friends .i hope u send solution.......
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Wed Nov 05, 2008 8:17 am     Reply with quote

You are not trying very hard to find the info on this. The chips are wired in series.

Googling on "74595" returned numerous good hits. The second link it found had what you need.

See the following diagram.

www.tayloredge.com/reference/Circuits/74595.pdf
chandrika
Guest







how to send data to 74595
PostPosted: Thu Nov 06, 2008 2:31 am     Reply with quote

no my chips(74595) are connected in parallel but these r conneccted to the 16f505 IC.each 74595 datapin(14)is connectd to pic 16f505 I/O pins .how to send data to 4x74595
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Nov 06, 2008 8:42 am     Reply with quote

You will have a BIG problem making this work at all.

The clk and latch signals going to all chips will cause the chip not getting data to clock all "0"s in during a load cycle... You need to be moving the C/S (LCLK) not the data line to each chip for this to work using the CCS driver.

It can be done but it will be complicated and you will NOT be able to use the CCS driver for this. You will have to write your own.

Why is it done this way? Is it a school project?
chandrika
Guest







PostPosted: Fri Nov 07, 2008 12:05 am     Reply with quote

thanks for ur suggestion thank u so much......
triple_x



Joined: 01 Dec 2005
Posts: 10

View user's profile Send private message

PostPosted: Sun Nov 09, 2008 7:32 pm     Reply with quote

hi,
dyeatman is right. Chandrika, u must get your hands dirty though, I mean must experiment the device from info u have, from there u can have the understanding, then u can expand as u wish.

As for 74595, test single chip first before proceeding to 4. Once u understand how the chip is working, implementing the others I believe will be easy.

Most of the guys here won't be doing others homework, but they are willing to give u help where possible. I'm also learning from the experts here...
gm_yu@vtech.com
Guest







74hc595 c
PostPosted: Tue Jan 06, 2009 4:38 am     Reply with quote

void write_expanded_outputs(BYTE* eo) {
BYTE i;
BYTE j;
BYTE tmp; // ++added, to hold data passed by pointer

// ++reason: if u manipulate data passed by pointer, ORIGINAL data will also be changed!

// re-assign data to temp variable
// tmp = *eo;

output_low(EXP_OUT_CLOCK);
output_low(EXP_OUT_ENABLE);
for(j=1;j<=NUMBER_OF_74595;++j) { //
tmp = *(eo+j-1);
for(i=1;i<=8;++i) { // Clock out bits from the eo array
//if((*(eo+(NUMBER_OF_74595-1))&0x80)==0) // ++commented
if ((tmp & 0x80) == 0) // ++manipulate temp data
output_low(EXP_OUT_DO);
else
output_high(EXP_OUT_DO);
//shift_left(eo,NUMBER_OF_74595,0); // ++ commented
tmp <<= 1; // ++manipulate temp data, shift 1 bit to the left
output_high(EXP_OUT_CLOCK);
output_low(EXP_OUT_CLOCK);
}
}
output_high(EXP_OUT_ENABLE);
}
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