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

8x8 dot Matrix not displaying proper message
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
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

8x8 dot Matrix not displaying proper message
PostPosted: Sat Feb 02, 2013 9:58 am     Reply with quote

Gentlemen,
I'm having problem displaying message on my 8x8 dot matrix display. I've modified a small c code rewriting it in C using CCS C compiler. In as far as my hardware is concern, I'm using a pic16f877a, a 74HC595, NPN transistors and a CD4017. As you would note in the code, I'm emulating serial communication by connecting the 74hc595 serial data pin to PIN_D2 as the serial port pins on the micro will be used for other purpose.
Scrolling is as expected except that the message being displayed is garbage. I have a strong feeling that I'm emulating the serial communication properly. The code is as attached below. Would anyone kindly assist.
Appreciate your help in advance.
javascript:emoticon('Shocked')

Code:
#include <16F877A.h>
#include <string.h>

//#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay(clock=20000000)
#define mask 0x01
#define Shift 8

#define ButInput PIN_E0
// Define LCD module connections.
/* sbit Serial_Data at LATC2_bit;
SH_Clk at LATC6_bit;
ST_Clk at LATC7_bit;
CD4017_Clk at LATA2_bit;
CD4017_RST at LATA1_bit;*/
#define SH_CLK     PIN_D0
#define ST_CLK     PIN_D1
#define SER_DATA   PIN_D2
#define CD4017_CLK PIN_D3
#define CD4017_RST PIN_D4

char columns [8] ={1,2,4,8,16,32,64,128};
//char const pat[8]={0x3f,0x02,0x04,0x02,0x3f,0xff,0x06, 0x0f};
const unsigned char CharData[][8] ={
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000},
{0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000000, 0b00000100},
{0b00001010, 0b00001010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000},
{0b00000000, 0b00001010, 0b00011111, 0b00001010, 0b00011111, 0b00001010, 0b00011111, 0b00001010},
{0b00000111, 0b00001100, 0b00010100, 0b00001100, 0b00000110, 0b00000101, 0b00000110, 0b00011100},
{0b00011001, 0b00011010, 0b00000010, 0b00000100, 0b00000100, 0b00001000, 0b00001011, 0b00010011},
{0b00000110, 0b00001010, 0b00010010, 0b00010100, 0b00001001, 0b00010110, 0b00010110, 0b00001001},
{0b00000100, 0b00000100, 0b00000100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000},
{0b00000010, 0b00000100, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00000100, 0b00000010},
{0b00001000, 0b00000100, 0b00000010, 0b00000010, 0b00000010, 0b00000010, 0b00000100, 0b00001000},
{0b00010101, 0b00001110, 0b00011111, 0b00001110, 0b00010101, 0b00000000, 0b00000000, 0b00000000},
{0b00000000, 0b00000000, 0b00000100, 0b00000100, 0b00011111, 0b00000100, 0b00000100, 0b00000000},
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000110, 0b00000100, 0b00001000},
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00001110, 0b00000000, 0b00000000, 0b00000000},
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000100},
{0b00000001, 0b00000010, 0b00000010, 0b00000100, 0b00000100, 0b00001000, 0b00001000, 0b00010000},
{0b00001110, 0b00010001, 0b00010011, 0b00010001, 0b00010101, 0b00010001, 0b00011001, 0b00001110},
{0b00000100, 0b00001100, 0b00010100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00011111},
{0b00001110, 0b00010001, 0b00010001, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00011111},
{0b00001110, 0b00010001, 0b00000001, 0b00001110, 0b00000001, 0b00000001, 0b00010001, 0b00001110},
{0b00010000, 0b00010000, 0b00010100, 0b00010100, 0b00011111, 0b00000100, 0b00000100, 0b00000100},
{0b00011111, 0b00010000, 0b00010000, 0b00011110, 0b00000001, 0b00000001, 0b00000001, 0b00011110},
{0b00000111, 0b00001000, 0b00010000, 0b00011110, 0b00010001, 0b00010001, 0b00010001, 0b00001110},
{0b00011111, 0b00000001, 0b00000001, 0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00010000},
{0b00001110, 0b00010001, 0b00010001, 0b00001110, 0b00010001, 0b00010001, 0b00010001, 0b00001110},
{0b00001110, 0b00010001, 0b00010001, 0b00001111, 0b00000001, 0b00000001, 0b00000001, 0b00000001},
{0b00000000, 0b00000100, 0b00000100, 0b00000000, 0b00000000, 0b00000100, 0b00000100, 0b00000000},
{0b00000000, 0b00000100, 0b00000100, 0b00000000, 0b00000000, 0b00000100, 0b00000100, 0b00001000},
{0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00001000, 0b00000100, 0b00000010, 0b00000001},
{0b00000000, 0b00000000, 0b00000000, 0b00011110, 0b00000000, 0b00011110, 0b00000000, 0b00000000},
{0b00010000, 0b00001000, 0b00000100, 0b00000010, 0b00000010, 0b00000100, 0b00001000, 0b00010000},
{0b00001110, 0b00010001, 0b00010001, 0b00000010, 0b00000100, 0b00000100, 0b00000000, 0b00000100},
{0b00001110, 0b00010001, 0b00010001, 0b00010101, 0b00010101, 0b00010001, 0b00010001, 0b00011110},
{0b00001110, 0b00010001, 0b00010001, 0b00010001, 0b00011111, 0b00010001, 0b00010001, 0b00010001},
{0b00011110, 0b00010001, 0b00010001, 0b00011110, 0b00010001, 0b00010001, 0b00010001, 0b00011110},
{0b00000111, 0b00001000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00001000, 0b00000111},
{0b00011100, 0b00010010, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010010, 0b00011100},
{0b00011111, 0b00010000, 0b00010000, 0b00011110, 0b00010000, 0b00010000, 0b00010000, 0b00011111},
{0b00011111, 0b00010000, 0b00010000, 0b00011110, 0b00010000, 0b00010000, 0b00010000, 0b00010000},
{0b00001110, 0b00010001, 0b00010000, 0b00010000, 0b00010111, 0b00010001, 0b00010001, 0b00001110},
{0b00010001, 0b00010001, 0b00010001, 0b00011111, 0b00010001, 0b00010001, 0b00010001, 0b00010001},
{0b00011111, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00011111},
{0b00011111, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00010100, 0b00001000},
{0b00010001, 0b00010010, 0b00010100, 0b00011000, 0b00010100, 0b00010010, 0b00010001, 0b00010001},
{0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00011111},
{0b00010001, 0b00011011, 0b00011111, 0b00010101, 0b00010001, 0b00010001, 0b00010001, 0b00010001},
{0b00010001, 0b00011001, 0b00011001, 0b00010101, 0b00010101, 0b00010011, 0b00010011, 0b00010001},
{0b00001110, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00001110},
{0b00011110, 0b00010001, 0b00010001, 0b00011110, 0b00010000, 0b00010000, 0b00010000, 0b00010000},
{0b00001110, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010101, 0b00010011, 0b00001111},
{0b00011110, 0b00010001, 0b00010001, 0b00011110, 0b00010100, 0b00010010, 0b00010001, 0b00010001},
{0b00001110, 0b00010001, 0b00010000, 0b00001000, 0b00000110, 0b00000001, 0b00010001, 0b00001110},
{0b00011111, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100},
{0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00001110},
{0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00001010, 0b00000100},
{0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010001, 0b00010101, 0b00010101, 0b00001010},
{0b00010001, 0b00010001, 0b00001010, 0b00000100, 0b00000100, 0b00001010, 0b00010001, 0b00010001},
{0b00010001, 0b00010001, 0b00001010, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100},
{0b00011111, 0b00000001, 0b00000010, 0b00000100, 0b00001000, 0b00010000, 0b00010000, 0b00011111},
{0b00001110, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00001110},
{0b00010000, 0b00001000, 0b00001000, 0b00000100, 0b00000100, 0b00000010, 0b00000010, 0b00000001},
{0b00001110, 0b00000010, 0b00000010, 0b00000010, 0b00000010, 0b00000010, 0b00000010, 0b00001110},
{0b00000100, 0b00001010, 0b00010001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000},
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00011111},
{0b00001000, 0b00000100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000},
{0b00000000, 0b00000000, 0b00000000, 0b00001110, 0b00010010, 0b00010010, 0b00010010, 0b00001111},
{0b00000000, 0b00010000, 0b00010000, 0b00010000, 0b00011100, 0b00010010, 0b00010010, 0b00011100},
{0b00000000, 0b00000000, 0b00000000, 0b00001110, 0b00010000, 0b00010000, 0b00010000, 0b00001110},
{0b00000000, 0b00000001, 0b00000001, 0b00000001, 0b00000111, 0b00001001, 0b00001001, 0b00000111},
{0b00000000, 0b00000000, 0b00000000, 0b00011100, 0b00010010, 0b00011110, 0b00010000, 0b00001110},
{0b00000000, 0b00000011, 0b00000100, 0b00000100, 0b00000110, 0b00000100, 0b00000100, 0b00000100},
{0b00000000, 0b00001110, 0b00001010, 0b00001010, 0b00001110, 0b00000010, 0b00000010, 0b00001100},
{0b00000000, 0b00010000, 0b00010000, 0b00010000, 0b00011100, 0b00010010, 0b00010010, 0b00010010},
{0b00000000, 0b00000000, 0b00000100, 0b00000000, 0b00000100, 0b00000100, 0b00000100, 0b00000100},
{0b00000000, 0b00000010, 0b00000000, 0b00000010, 0b00000010, 0b00000010, 0b00000010, 0b00001100},
{0b00000000, 0b00010000, 0b00010000, 0b00010100, 0b00011000, 0b00011000, 0b00010100, 0b00010000},
{0b00000000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00001100},
{0b00000000, 0b00000000, 0b00000000, 0b00001010, 0b00010101, 0b00010001, 0b00010001, 0b00010001},
{0b00000000, 0b00000000, 0b00000000, 0b00010100, 0b00011010, 0b00010010, 0b00010010, 0b00010010},
{0b00000000, 0b00000000, 0b00000000, 0b00001100, 0b00010010, 0b00010010, 0b00010010, 0b00001100},
{0b00000000, 0b00011100, 0b00010010, 0b00010010, 0b00011100, 0b00010000, 0b00010000, 0b00010000},
{0b00000000, 0b00001110, 0b00010010, 0b00010010, 0b00001110, 0b00000010, 0b00000010, 0b00000001},
{0b00000000, 0b00000000, 0b00000000, 0b00001010, 0b00001100, 0b00001000, 0b00001000, 0b00001000},
{0b00000000, 0b00000000, 0b00001110, 0b00010000, 0b00001000, 0b00000100, 0b00000010, 0b00011110},
{0b00000000, 0b00010000, 0b00010000, 0b00011100, 0b00010000, 0b00010000, 0b00010000, 0b00001100},
{0b00000000, 0b00000000, 0b00000000, 0b00010010, 0b00010010, 0b00010010, 0b00010010, 0b00001100},
{0b00000000, 0b00000000, 0b00000000, 0b00010001, 0b00010001, 0b00010001, 0b00001010, 0b00000100},
{0b00000000, 0b00000000, 0b00000000, 0b00010001, 0b00010001, 0b00010001, 0b00010101, 0b00001010},
{0b00000000, 0b00000000, 0b00000000, 0b00010001, 0b00001010, 0b00000100, 0b00001010, 0b00010001},
{0b00000000, 0b00000000, 0b00010001, 0b00001010, 0b00000100, 0b00001000, 0b00001000, 0b00010000},
{0b00000000, 0b00000000, 0b00000000, 0b00011111, 0b00000010, 0b00000100, 0b00001000, 0b00011111},
{0b00000010, 0b00000100, 0b00000100, 0b00000100, 0b00001000, 0b00000100, 0b00000100, 0b00000010},
{0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100},
{0b00001000, 0b00000100, 0b00000100, 0b00000100, 0b00000010, 0b00000100, 0b00000100, 0b00001000},
{0b00000000, 0b00000000, 0b00000000, 0b00001010, 0b00011110, 0b00010100, 0b00000000, 0b00000000}
};                 


void send_data(unsigned char tmp);
unsigned char DisplayBuffer[]={0,0,0,0,0,0,0,0};
unsigned int speed;
char i, l, k, ShiftAmount, scroll, temp, shift_step=1, StringLength;
char message[]="SCROLLING MESSAGE ON LED DOT-MATRIX DISPLAY ";
char index;

void main()
{
  //unsigned int8 i,j,k;
  unsigned int16 cnt;
  unsigned char num, column, repeat, count;
 
  set_tris_b(0b00000000);           //all output 0b00000000
  set_tris_d(0b00000000);           //all output 0b00000000
  set_tris_e(0b00000001);           //PORTE bit 0 is input
 
  cnt = 0L;
  k = 0;
  output_b(0x00);
  output_d(0x00);
  StringLength = strlen(message) ;
   while(TRUE)
   {   
   
      //loops();
     for (k=0; k<StringLength; k++)
     {
      for (scroll=0; scroll<(8/shift_step); scroll++)
      {
         for (ShiftAmount=0; ShiftAmount<8; ShiftAmount++)
         {
            index = message[k];
            temp = CharData[index-32][ShiftAmount];
            //DisplayBuffer[ShiftAmount] = temp;
            //DisplayBuffer[ShiftAmount] = (temp << shift_step)| (temp >> ((8-shift_step)-scroll*shift_step));
            DisplayBuffer[ShiftAmount] = (DisplayBuffer[ShiftAmount] << shift_step)| (temp >> ((8-shift_step)-scroll*shift_step));
         }

        speed = 5; //55;//+ADC_Read(0)/10;
        for(l=0; l<speed;l++)
        {

           for (i=0; i<8; i++)
           {
               //send_data_serially(DisplayBuffer[i]);
               send_data(DisplayBuffer[i]);
               //send_data(CharData[i]);
               output_high(CD4017_CLK);
               output_low (CD4017_CLK);
               Delay_ms(1);
            }  // i
               output_high(CD4017_RST);//CD4017_RST = 1;
               output_low (CD4017_RST); //CD4017_RST = 0;
               for(i = 0; i < 8; i++)
               DisplayBuffer[i]=0;
         } // l
       } // scroll
      } //
   }
}

void send_data(unsigned char tmp)
{
   unsigned int16 Flag;
   unsigned char t;
   unsigned int16 msk;
   msk = 0x0001;
  for (t=0; t<8; t++)
  {
      Flag = tmp & msk;
      if(Flag==0) output_low(SER_DATA);   //Serial_Data = 0;
      else output_high(SER_DATA);          //Serial_Data = 1;
      output_high(SH_CLK); //SH_CLK = 1;
      output_low(SH_CLK); //SH_CLK = 0;
      msk = msk << 1;
  }
  // Apply clock on ST_Clk
  output_high(ST_CLK);  //ST_CLK = 1;
  output_low (ST_CLK);  //ST_CLK = 0;

}
Shocked
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat Feb 02, 2013 12:34 pm     Reply with quote

got a schematic that shows what you have done?

it also seems self evident that if the big CONST bit table
is junk - so will be the messages ......

lastly delay_ms(1) Sounds good if there is a 100 ft of cable between the pic
and the cmos logic but its a lot of wasted time otherwise.

do you observe ringing on your drive lines? id so consider drawing current and put a 4.7k resistor terminator out there and shorten the delay A LOT.....
Mike Walne



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

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 1:25 pm     Reply with quote

Make it easier for us to decipher your code.

A brief explanation of what's happening would help.
As would some sort of schematic (even crude ASCII art will do).

Have you looked at any waveforms with a 'scope?

Explain clearly what works and what doesn't.

Mike
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 6:33 pm     Reply with quote

Thanks Gents for your response. I'm having trouble posting the schematic as I cannot see any import button and the (ALT+P) isn't working for me. How do I post a schematic onto the forum.?
Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 6:54 pm     Reply with quote

Post the schematic on a free image hosting website, and then post a link
to it in your next post.

Example of a free image host:
http://www.imageshack.us/
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 8:18 pm     Reply with quote

Gents,
Many thanks PCM Programmer for your help. Here is the link of my schematic as requested.

http://imageshack.us/photo/my-images/443/schematic1.png/
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 11:12 pm     Reply with quote

My suggestion is to completely declare the array dimensions, as shown
below in bold:
Quote:

const unsigned char CharData[95][8] ={
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

PostPosted: Sat Feb 02, 2013 11:49 pm     Reply with quote

Hello PCM Programmer,
Thanks for your reply. I did exactly as you said. There is something strange about my 8x8 display matrix. When I send a byte say 0b01111110, the dot matrix displays something like:
Quote:
01111110
01111110
01111110
01111110
01111110
01111110
01111110
01111110

I was expecting only the first row to display 01111110 and everything else to be zeros or OFF.
What is going on here?


http://imageshack.us/photo/my-images/145/schemt.png/
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Feb 03, 2013 12:33 am     Reply with quote

Quote:
When I send a byte say 0b01111110,

I don't see that byte listed in the CharData array. So you must be doing
some experiment, other than using the posted code. If so, post the
full program code for the experiment.

Also post a link to the data sheet for the 8x8 dot matrix display.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun Feb 03, 2013 1:27 am     Reply with quote

Just out of curiosity, why are you showing Q8 and Q9 of the 4017 shorted to ground ? (they are outputs - CMOS inputs should not be left floating, but outputs are OK).

If it were me, I would try a simple program that simply counted up at say a 1 hz rate displaying the count without any scrolling etc attempted just to make sure I had things connected correctly.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

PostPosted: Sun Feb 03, 2013 2:53 am     Reply with quote

Gents,
You are right PCM Programmer, the byte 0b01111110 was not part of the origin value in the table. It is a number I chose to send to the shift to see what would be displayed. The 8x8 Dot matrix I'm using is a "12pcs 8x8 Dot Matrix 3mm Red LED Display Common cathode" as can be seen in the link below. The code below is complete and can be used for experience to understand the problem.

http://www.ebay.com.au/itm/12pcs-8x8-Dot-Matrix-3mm-Red-LED-Display-Common-cathode-/160768142334?_trksid=p3284.m263&_trkparms=algo%3DSI%26its%3DI%26itu%3DUCI%252BRTU%26otn%3D21%26pmod%3D230699071667%26ps%3D54

gpsmikey,
I thought by connecting Q8 and Q9 of the 4017 to the ground would leave them not floating. They are now left unconnected.
As suggested, I have now modified the code to just display characters without scrolling as can be seen the code below. Still, the display is not as expected.

Code:
#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay(clock=20000000)

#use FIXED_IO( D_outputs=PIN_D4,PIN_D3,PIN_D2,PIN_D1,PIN_D0 )
#define Latch        PIN_D0
#define Data_In      PIN_D1
#define Clk           PIN_D2
#define CD4017_Clk   PIN_D3
#define CD4017_MR    PIN_D4
#define Shift 8

const unsigned BYTE Alphabets[130]={
                               0x7e, 0x09, 0x09, 0x09, 0x7E, // A
                               0x7f, 0x49, 0x49, 0x49, 0x36,  // B
                               0x3e, 0x41, 0x41, 0x41, 0x22,
                               0x7f, 0x41, 0x41,0x22, 0x1c,
                               0x7f, 0x49, 0x49, 0x49, 0x63,
                               0x7f, 0x09, 0x09, 0x09, 0x01,
                               0x3e, 0x41, 0x41, 0x49, 0x7a,
                               0x7f, 0x08, 0x08, 0x08, 0x7f,
                               0x00, 0x41, 0x7f, 0x41, 0x00,  // I
                               0x20, 0x40, 0x41, 0x3f, 0x01,
                               0x7f, 0x08, 0x14, 0x22, 0x41,
                               0x7f, 0x40, 0x40, 0x40, 0x60,
                               0x7f, 0x02, 0x04, 0x02, 0x7f,
                               0x7f, 0x04, 0x08, 0x10, 0x7f,
                               0x3e, 0x41, 0x41, 0x41, 0x3e,
                               0x7f, 0x09, 0x09, 0x09, 0x06,
                               0x3e, 0x41, 0x51, 0x21, 0x5e,
                               0x7f, 0x09, 0x19, 0x29, 0x46,
                               0x46, 0x49, 0x49, 0x49, 0x31,  // S
                               0x01, 0x01, 0x7f, 0x01, 0x01,
                               0x3f, 0x40, 0x40, 0x40, 0x3f,
                               0x1f, 0x20, 0x40, 0x20, 0x1f,
                               0x3f, 0x40, 0x30, 0x40, 0x3f,
                               0x63, 0x14, 0x08, 0x14, 0x63,
                               0x07, 0x08, 0x70, 0x08, 0x07,
                               0x61, 0x51, 0x49, 0x45, 0x43 // Z
                               };

void send_data_serially(unsigned char tmp);

void main()
{
   unsigned short count, column, num, repeat;
     
  set_tris_d(0b00000000);           //all output 0b00000000
 
  output_d(0x00);

   
   while(TRUE)
   {
      //TODO: User Code
      // Display 26 alphabets
   for (num=0; num<26; num++)
   {

     for (repeat=0; repeat<100; repeat++)
     {
      column = 1;
      for(count = num*5;count < (num*5+6);count++)
      {
        //PORTB = Alphabets[count];
        //PORTA = column;
        send_data_serially(Alphabets[count]);
        Delay_ms(1);
        output_high(CD4017_Clk );
        output_low (CD4017_Clk );
        Delay_ms(1);
       }  // i
        output_high(CD4017_MR);//CD4017_RST = 1;

        output_low (CD4017_MR); //CD4017_RST = 0;
       
     }
   }
   }

}

void send_data_serially(unsigned char tmp)
{
   unsigned char i;
   unsigned char Data2Send;
   unsigned char Dmsk;
   
   output_low(Latch);
   output_low(clk);                                      //ST_CLK = 0;
   for(i = 0; i < Shift; i++)
   {
      Data2Send = tmp >> i;
      if(Data2Send & 0x001) output_high(Data_In);         //Serial_Data = 1;
      else                  output_low(Data_In);           //Serial_Data = 0;
     
      output_high(Clk);                                 //SH_CLK = 1;
      output_low (Clk);                                  //SH_CLK = 0;
   }
     output_high(Latch);  //ST_CLK = 1;

   
}
temtronic



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

View user's profile Send private message

PostPosted: Sun Feb 03, 2013 6:42 am     Reply with quote

You might want to look at and test with the driver that CCS supplies for the 74595. Called 74595.c ,located in the drivers folder.

A quick look shows your 74595 sequence of 'bit setting' is not the same as theirs.

Probably a good idea to start with a simple 'light an LED,then 2,3...8' program to be sure the hardware and driver are correct.

it's always easier to preceed from known good basic code that try to debug complex code !

hth
jay
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

PostPosted: Sun Feb 03, 2013 9:18 am     Reply with quote

Hi temtronic,
I tried the code but it didn't work either. Can anyone post a simple code that I may test?
The situation is very frustrating and my final year project is now in limbo.
Mike Walne



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

View user's profile Send private message

PostPosted: Sun Feb 03, 2013 9:34 am     Reply with quote

Your not taking notice of what you are being told.

Start from simple beginnings.

Break your task into small sections.

Code each section one at a time,

Test each section 'til you are certain it is error free.

Now that we've got a schematic, it doesn't look like you've analysed what happens as you drive the display.

Get it clear in your own mind how you want the system to operate, before you start coding.

Tell us how you think it needs to go.

There have been loads of posts on this before.

Please answer this simple question:-

What is your design target for the mean (average) current through an illuminated LED?
(100uA?, 300uA?, 1ma?, 3mA?, 10mA? What? )


Mike

EDIT Is your deadline tomorrow?

The guys on this forum WILL help you.

BUT (BIG BUT) this is a help forum, NOT a do it for you forum.

YOU have to do the work, the others and I will willingly assist.

You're the one who wants the paper certificate.
We've all done it before.
Your tutor could easily find the code if it's posted here.
We do this work for a living and charge $$$$$£££££.
kein



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

PostPosted: Sun Feb 03, 2013 11:55 pm     Reply with quote

You're absolutely, Mike. My apologies.
That said, I finally got something happening with the code below. However, there are still issues with characters being displayed as some dots are found to be missing from the displayed character. The screenshots are as attached.
Has anyone come across this problem before?
Regards.
Kein

http://imageshack.us/photo/my-images/39/schem.png/
http://imageshack.us/photo/my-images/194/schem2.png/

Code:
#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay(clock=20000000)

#BYTE PORT_B = 0X06     //define location of register port_b
#BYTE PORT_D = 0X08     //define location of register port_d
#BYTE TRIS_B = 0X86     //define location of register TRIS_B
#BYTE TRIS_D = 0X88     //define location of register TRIS_D
//#use FIXED_IO( D_outputs=PIN_D4,PIN_D3,PIN_D2,PIN_D1,PIN_D0 )
#define CLR          PIN_B0
#define Latch        PIN_B1
#define Data_In      PIN_B2
#define CLK          PIN_B3

const unsigned char letters[16] = {

0xFF, 0x01, 0xEE, 0xEE, 0xEE, 0x01, 0xFF, 0xFF,   //A
0xFF, 0x00, 0x76, 0x76, 0x76, 0x89, 0xFF, 0xFF   //B
};
void Clear_Shift_Register();
void Send_Data_In (unsigned char s);


void main()
{     
      unsigned char count, column,num, repeat;
      TRIS_B = 0b00000000; // Set PORTB direction to be output
      TRIS_D = 0b00000000; // Set PORTB direction to be output
      PORT_B = 0x00; // Turn OFF LEDs on PORTB
      PORT_D = 0x00; // Turn OFF LEDs on PORTB
     
      //count = 0;
      Clear_Shift_Register();
   while(1)
   {
      //DO THE FOLLOWING
    for (num=0;num<2;num++)
    {
     for (repeat=0; repeat<200; repeat++){
        column =0b10000000; 
      for (count = num*8;count < (num*8+8);count++)
      {
         Send_Data_In (letters[count]);
         PORT_D =column;
         delay_us(500);
         column = column>>1;
         Clear_Shift_Register();
      }
      }
      }
    }
}


void Clear_Shift_Register()
{
      output_low(CLR);                       //Clear shift register
      output_high(CLR);                      //Clear shift register
}
void Send_Data_In (unsigned char s)
{
   unsigned char t;

   for(t =0b10000000; t > 0; t>>=1)         //for(t =0; t < 8; t++)
   { 
      //if(s&0x80) output_low(Data_In);     //Test MSB 7
      if(s&0x01)   output_high(Data_In);     //Test MSB 7     
      else         output_low(Data_In);     //Test MSB 7output_high(Data_In);      //skip to here if clear
         output_high(CLK);                   //
         output_low (CLK);
         s >>=1;
   }
      output_high(Latch);                    //Latch in the data
      output_low(Latch);
}
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