|
|
View previous topic :: View next topic |
Author |
Message |
NeoMatrix
Joined: 03 May 2005 Posts: 23
|
Need Help 74595.C |
Posted: Sun May 08, 2005 8:32 am |
|
|
Hello Eveyone
i need help i am working on 7 x 10 moving message display but i not able to understand the 74595.c code when i look to the datasheet of 74595 its written there
RCK Pin 12
SCLR Pin 10
SCK Pin 11
SI Pin 14
in 74595.c its written like this
#define EXP_OUT_ENABLE PIN_A2
#define EXP_OUT_CLOCK PIN_A1
#define EXP_OUT_DO PIN_A0
#define NUMBER_OF_74595 2
can anybedy explain me which pin i have to connect to EXP_OUT_ENABLE,n Which to Enable and with to EXP_OUT_DO PIN
pls any one can take little time to explain me i am trying since 2 hrs
waiting for ur reply... |
|
|
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Sun May 08, 2005 9:55 am |
|
|
This is just getting to be ridiculous, I am going to let loose the lab-instructor personality...
Representative data sheet from Fairchild Semi, similar available from TI, Philips and others:
http://www.fairchildsemi.com/ds/MM%2FMM74HC595.pdf
74x595 control pins are:
RCK = Register Clock. A rising edge on this clock transfers data from the internal shift register to the output pins, simultaneously. This is the key difference between the '164 and '595 parts.
SCK = Shift clock. Data shifted into part (from SER pin) on rising edge. SER pin data must be stable prior to rising edge of SCK.
SCLR- = Shift register clear. Level sensitive, LOW = clear shift registers, HIGH = normal operation.
G- = Output enable. HIGH = outputs 3-state, LOW = normal operation.
Look at the code in 74595.C. What are they doing with EXP_OUT_ENABLE? At the start of the routine it is brought low, held low for the duration and then brought high. Now look at the '595 data sheet. What pin should be doing that? How about RCK.
EXP_OUT_ENABLE = RCK
Look at the code in 74595.C. What are they doing with EXP_OUT_CLOCK? It is brought low at the start and then inside the "for" loop it is toggled. Looks very much like what SCK should be doing to shift data into the registers.
EXP_OUT_CLOCK = SCK
Look at the code in 74595.C. What are they doing with EXP_OUT_DO? They change its state inside the "for" loop depending on the value of the MSbit of data pointed to by "eo". So that must be the serial data to be shifted into the part(s).
EXP_OUT_DO = SER
I get the feeling that English is not your first language and I understand that can make it difficult to figure out the datasheet and the code but really this isn't that hard. The first page of the Fairchild Semi datasheet has a pictorial "TRUTH TABLE" representation of the chip function in a table in the lower right corner. Don't particularly need to understand English to understand the table. This is assuming you already understand how a shift register, flip-flop and output-enable function works. Page 2 of the Fairchild Semi datasheet has a schematic logic representation of what is happening inside the chip. Again, don't need to understand English to read that schematic. Page 6 has sample timing diagrams. Also shows how the chip works.
If you don't understand those things and you are having trouble understanding "for" loops in C and some bit manipulation functions then perhaps you are trying too complex of a project.
Start smaller, blink a single LED & limiting resistor attached to a single pin of the PIC. Then try multiple LEDs and multiple limiting resistors on a single port of the PIC. Then start adding the shift registers. Then start experimenting with PWM to control the current to the LEDs.
The schematics you posted earlier (which by the way are very small and difficult to read) do not show limiting resistors on the LEDs. While you might get away with the output current limit of the chips themselves, you will probably be going over the maximum power rating for the chips or LEDs and end up with lots of dead parts. If you don't understand how to use PWM to limit the current through the LEDs, you need to add the resistors.
The lab instructor is now going back under his rock to chew on the bones of previous victims... _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
|
NeoMatrix
Joined: 03 May 2005 Posts: 23
|
Thank You.. |
Posted: Sun May 08, 2005 10:03 am |
|
|
hello young
thanks for the reply thanks for the datasheet u sended to me its very clear the datasheet i was having very confusing so i have to attach the resisteor for port as i directly connected the rows to porta i will use 120ohms this is my code that i am doing for 7x10 i think u told right 1st i will do small projects then go for this thanks for ur advice
i appreciate ur help
#include <16F628.h>
#fuses NOWDT,XT, NOPUT, NOPROTECT, NOBROWNOUT, NOMCLR, NOLVP, NOCPD
#use delay(clock=4000000)
#define EXP_OUT_ENABLE PIN_A2
#define EXP_OUT_CLOCK PIN_A1
#define EXP_OUT_DO PIN_A0
#define NUMBER_OF_74595 2
#include <74595.C>
void display (void);
#define BUFFER_SIZE 16
byte buffer[BUFFER_SIZE];
byte Data [16];
byte next_in = 0;
byte next_out = 0;
#byte port_a=5 /* define the location of register port_b */
#byte port_b=6 /* define the location of register port_b */
char const pat[80]={0,255,255,24,24,255,255,0,0,255,255,219,219,195,195,0,
0,255,255,192,192,192,192,0,0,255,255,192,192,192,192,0,
0,60,126,195,195,126,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
// array holds the character maps for HELLO which scrolls//
// This needs to be converted to 8 x 8 bitmaps
main() {
int i ;
display (); // the display function
}
//***************************** This is the display part *****************************************************
void display (void)
{
int mask[4];
int data[4]; // array to store our data since i am
int startposition;
int index;
int i;
int delaycount;
set_tris_a(0);
set_tris_b(0);
port_a = 0;
port_b = 0;
startposition = 0;
while(1)
{
delaycount = 3; // adjust this value to control scrolls speed
while (delaycount)
{
index = startposition;
mask[0]=0x01; // Initialize our mask
mask[1]=0x00;
mask[2]=0x00;
mask[3]=0x00;
for (i=0; i<10; i++) // we have 32 columns to drive
{
// store our mask in an array. we need to do this because
// the call to write_expanded_outputs will destroy the value
// passed in.
data[0] = mask[0]; // store which column we are driving
data[1] = mask[1]; // in an array
data[2] = mask[2];
data[3] = mask[3];
index = i + startposition; // point to the next pattern to display
if (index >= sizeof(pat)) // make sure that we don't exceed the array
index -= sizeof(pat);
port_b = 0; // disable driving the LEDs
write_expanded_outputs(data); // enable our column driver
port_b = pat[index]; // drive our LEDs
if (shift_left(mask,4,0))
mask[0] = 0x01;
// shift to the next column for next time
delay_us(700); // adjust this value to control the drive time
//for the leds
}
--delaycount; // decrement our delay loop counter
}
++startposition; // Point to the next data pattern
if (startposition >= sizeof(pat)) // make sure that we don't exceed the array
{
startposition = 0;
}
}
} |
|
|
|
|
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
|