Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LED(Dot matrix) Calender using DS1307.

Status
Not open for further replies.

Dumken

Member
Hi guys. Good day.. Pls does anyone have an idea on how to go about a code that will display a calender in the form shown below. My main concern is on how to display not reading from the the DS1307
 

Attachments

  • Calender.jpg
    Calender.jpg
    33.2 KB · Views: 641
Do you understand the I2C protocol and how to choose the rest of the hardware and software, if not search for a DIY project.
 
Tony Stewart i do. I know how to read and write using i2c protocol. Am done with the 7 segment clock My main Challenge is the display. Ian Rogers, i checked the tutorial what was there was more of scrolable but i want a static effect on the calendar. I am done with the clock. My problem is the static calender. And too i noticed the code was on MPLAB. Pls Can u help me with a related mikroc code to make the adjustment. if possible linking it with the code on this website https://embedded-lab.com/blog/?p=4717 The picture below shows my progress so far
 

Attachments

  • progress.pdf
    102.2 KB · Views: 239
I also did a 32x16 led display that runs pretty smoothly... It is driven in the same way as a LCD screen..

But I used 74LS323 shift registers....

The screen gets dimmer the more LED's you have... As the end result will theoretically have two screens it should work okay..

Moving to MikroC isn't a big deal.... I have XC8 compiler and MikroC for pic32's so I should be able to help!!

I use interrupts to drive the screen, that's why I have a flicker free display... There is a "off screen" display that I can flip...
 
As you display in 7 segment same is to be done in matrix , in this you will be using shift register to display it on leds
data transfer. and scanning rows from port, use loop
 
DIY = Do It Yourself
 
The usual is to create either a lookup table in assembler or an array in c or high level code, this defines the bit patterns for the displayed character, then you scan through the display, if you doing it verticaly you'd be showing 1/5 of a character at a time if they were 5 x 8's.
There are probably examples of scrolling displays on the net, its not complex, but it is processor intensive.
 
Okay!!

The code You need a font and both animation files.... I have included them at the end..
C:
#include<pic.h>
#define _XTAL_FREQ 20000000L       // 20 meg crsytal
__CONFIG(0x3F72);             // HS on,  WDT off, BOR on, PWRTon..

char displayPointer=0;           // for interrupt use...
extern const char  fnt[];         // Font in external C file
extern const char  anim[];
extern const char  anim1[];
unsigned char buffer[64];          // buffer for screen
unsigned char backbuffer[64];       // Spare screen for drawing on
char pow[8]={128,64,32,16,8,4,2,1};

void interrupt ISR()           // This just swaps the buffer to the display
   {
   if(TMR2IF)               // Make sure its the timer interrupt.
     {
     PORTB = 0;             // Clear old data first
     if(displayPointer == 0 )      // 1st frame..
       RC4 = 1;           // Data = 1 on the first clock only
     RC3 = 1;
     __delay_us(20);           // Clock the shift registers
     RC3 = 0;
     RC4 = 0;             // Make sure data stays low for the rest of the cycles
     PORTB = buffer[displayPointer];   // Move buffer row by row( 4 row sections per row )     
     if(++displayPointer==64)      // 32 LED row sections in total
       displayPointer = 0;       // Back to first row..
     }
   TMR2IF = 0;               // Clear timer 2 interrupt flag
   }

void pixel(signed char x,signed char y,int cond)
   {
   int tmp;
   char pix,msk;
   if(x<0 || y<0) return;       // outside drawing limits negative
   if(x>31 || y>15) return;       // outside drawing limits positive
   tmp = (y << 2) + (x>>3);     // Linear position
   pix = x%8;             // pixel required
   pix = pow[ pix];
   msk = backbuffer[tmp];       // get exsisting data
   if(cond == 2)
     pix ^= msk;           // XOR data to screen
   if (cond == 1)
     {
     pix = ~pix;
     pix &= msk;           // AND data to screen
     }
   if(cond == 0)
     pix |= msk;           // OR data to screen
   backbuffer[tmp] = pix;       // apply changes
   }

void charput(char ch, signed char x,signed char y)
   {
   signed char x1, y1;         
   const char* addr2;         // pointer to character
   char disp;
   ch -= 0x20;             // characters starts a 0 not 0x20
   addr2 = &fnt[0];         // start of font array
   addr2 = addr2 + ((int)ch * 8);   // start place in font array
   for( y1=0;y1<8;y1++)       // eight rows
     {
     disp = *addr2;
     for (x1 = 0; x1<8; x1++)   // eight pixels
       {       
       if(disp & pow[x1])
         pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
       }
     addr2++;
     }   
   }

void strput(const char* ch, signed char x,signed char y)
   {
   int addr;
   
   while (*ch )
     {
     charput(*ch++,x,y);       // write a string to the display buffer
     x+=7;
     }     
   }

void clr()
   {
   int addr;
   for(addr=0;addr<64;addr++)         // Empty display buffer
     backbuffer[addr]= 0;
   }

void Blit()
   {
   int addr=0;
   GIE = 0;
   for(addr=0;addr < 64;addr ++)
     {
     buffer[addr] = backbuffer[addr];   // put all data from display buffer
     }                   // to screen buffer
   GIE = 1;
   }
void animation1(void)
   {
   char x,y;
   const char* frame;             // pointer to frames
   for(x=0;x<14;x++)             // 14 frames in animation
     {
     clr();                 // clears the display buffer
     frame = &anim1[0];           // start of frames
     frame += x*64;              // each frame is 64 bytes long
     for(y=0;y<64;y++)
       backbuffer[y] = *frame++;     // Cycle through the animation
     Blit();                 // pass to screen buffer
     __delay_ms(350);           // time to view
     }
   }

void animation(void)
   {
   char x,y;
   const char* frame;             // pointer to frames
   for(x=0;x<14;x++)             // 14 frames in animation
     {
     clr();                 // clears the display buffer
     frame = &anim[0];           // start of frames
     frame += x*32;              // each frame is 32 bytes long
     for(y=16;y<48;y++)
       backbuffer[y] = *frame++;     // Cycle through the animation
     Blit();                 // pass to screen buffer
     __delay_ms(150);           // time to view
     }
   }

void displaystring(void)         // this routine prints through the screen buffer
   {                   // moving one pixel at a time
   signed char x=32,y=0;         // I made these signed so I could print
   for(y = 0;y  < 96 ;y++)         // to nowhere so I could produce the scrolling effect
     {
     clr();               // Clear the display buffer
     strput("HELLO WORLD!!",x--,4);   // adjust the scrolling string
   
     Blit();               // pass to screen buffer
     __delay_ms(100);           // time to view
     }
   }

void main(void)
   {
   int sx,sy;
   int xdir=1, ydir=1;
   ADCON1 = 0x6;             // ALL digital
   T2CON = 0x1e;             // T2 on, 16:1 pre scale
   PR2 = 60;               // timer preload value ( equates to 1.4mS with 20mhz crystal)
   TMR2IE = 1;               // enable timer 2 interrupt
   PEIE = 1;               // enable peripheral interrupt
   GIE = 1;               // enableglobal interrupt
   TRISB = 0;               // Port B as output...
   TRISC = 0;               // Port C as ouput...
   animation();
   animation1();
   displaystring();
   while(1)
     {
     clr();
     sx += xdir; sy += ydir;     
  strput("]",sx,sy);

     if(sx>27) xdir = -1;
     if(sy>12) ydir = -1;
     if(sx<0) xdir = 1;
     if(sy<0) ydir = 1;
     __delay_ms(60);
     Blit();
     }
   }   // End main

The schematics:--: Remember I don't have the resistors on the circuit as the simulation is too slow..
Each column needs a resistor to prevent LED or micro failure!!!
upload_2015-8-4_20-41-4.png
 

Attachments

  • anim.c
    5.4 KB · Views: 198
  • font.c
    10.1 KB · Views: 192
  • anim1.c
    3.9 KB · Views: 198
The code You need a font and both animation files.... I have included them at the end..
Before ISR i was suggesting to use direct data transfer to learn more basic
The 74hc164 i used serial in from uC parallel out to LEDs.
example :
RC.4=1; //CLOCK
RC.5=1; // DATA TO AB OF 74HC164
RC.4=0;
RC.4=1;

LIKE THIS

C:
for(int r=0;r<8;r++){
DAD=pow[r];
//__delay_ms(2);
RST=0;
RST=1;
u++;
for(int a=0;a<12;a++){
DAD=0;
RST=1;
char t,n;
n=leds[a];
n>>=u;
t=(n & b);
DATA=t;

CLK=1;
__delay_us(10);
CLK=0;
 
What is 323 registrr is this?
And i have google bidirectional shift register
Any shift register will do... I just don't want a latching feature as it is a constant update.. hence the screen / back buffers..
 
This is a really poor vid I made a while back, but I used a load of 4094 cmos shift registers to drive a vacuum display.
I got the display much clearer than in the vid, lookout for the mess of wires.

 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top