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

PIC16F877A 4 Digit 7 Segment Display Scrolling Text

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



Joined: 16 Jun 2020
Posts: 3

View user's profile Send private message

PIC16F877A 4 Digit 7 Segment Display Scrolling Text
PostPosted: Tue Jun 16, 2020 4:08 am     Reply with quote

Hi,
I have the project given below:
"Print your name and surname in the form of scrolling text with 4 7-segment displays connected to Port B of 16F877A. When the circuit first runs, the first four letters of your name and surname will be written, and every 500ms, the text will be shifted to the left and printed as an infinite loop on the screen. (For example, for MICHAEL JACKSON, "MICH" first, "ICHA" after 500ms, "CHAE" after 500ms, "HAEL" after 500ms, "AEL (space)" after 500ms, "EL (space) J" after 500ms, 500ms later "L (space) JA" will continue as "(space) JAC" after 500ms, "JACK" after 500ms, "ACKS" after 500ms, "CKSO" after 500ms, "KSON" ...). The time for each letter to appear on the screen will be 10ms. It is forbidden to use the Delay command. It is forbidden to write commands to the infinite loop in the main loop. "

I prepared the circuit using PIC16F877A. It's in the link below but i have no idea how to do the code. Could you help me please? Thanks in advance.

[url] https://imgur.com/a/bBzqsot [/url]
temtronic



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

View user's profile Send private message

PostPosted: Tue Jun 16, 2020 6:29 am     Reply with quote

1st get the PIC to flash an LED at 1Hz.....
this simple basic program will show you you've wired up the PIC and parts and that you CAN download and execute a working program.....

Now break the project up into several, small sections.
get ONE display to display known data. you'll need to create a table of characters( the alphabet ..). then 'loop' through the table (or array) to show a character, delay a bit, increment the element counter and repeat 25 more times.

report back when this works.....

overall the program is complicated BUT broken down into smaller sections it can be accomplished.

I don't have any 4094 here so I can't test though.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Jun 16, 2020 6:38 am     Reply with quote

You also have a big issue, that a 7 segment display cannot show quite
a lot of alphabetic characters. G, K, M, Q, T, V, W, X for example....
I'd suspect this might be a school project. The 10mSec number suggests
that they expect you to generate a 100Hz interrupt and multiplex the display
at this frequency. There have been lots of code parts posted here in the
past for a display like this.
Then the actual output just becomes a matter of taking four characters from
the input string and displaying these. After 0.5 seconds (so 50 'counts' with
the interrupt, advance the pointer one character).
norstadd



Joined: 16 Jun 2020
Posts: 3

View user's profile Send private message

PostPosted: Tue Jun 16, 2020 8:01 am     Reply with quote

First of all thanks for the answering. I'm adding the code i made below. I'm a beginner so i am sorry if i make a basic mistake on the code.

Ttelmah, that's right it's a school project. About the characters that 7 segment display cannot show i can use any other character. For example for M i can use 2. Thanks for answering again.

temtronic, i tried as you suggest and create a code but it doesn't seem to work like i want. It's only showing the same character on all the 4 displays. I couldn't understand the problem with it. Thanks for answering again.


Code:

#include <7segscrollingtext.h>
#define data pin_b0
#define clk pin_b1
#define stb pin_b2
#define oe pin_b3

int table[8]={
0b10110111,0b10110111,   // M Letter
0b00000110,0b10111001,   // I and C letter
0b11110110,0b11110111,   // H and A letter
0b11111001,0b00111000};  // E and L letter
 
unsigned int16 count=0;
int i,j,digit_0,digit_1,digit_2,digit_3;

#int_timer0
void timer0_kesme ()
{
set_timer0(60);
j++;
if (j==50)
{
j=0;
}


}


void main()
{
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1|RTCC_8_bit);      //51,2 us overflow

set_timer0(60);
enable_interrupts(INT_timer0);
enable_interrupts(GLOBAL);


{
  output_high(oe);

   for(;;)
   {
      digit_0=table[i];
      digit_1=table[i];
      digit_2=table[i];
      digit_3=table[i];
     
     
      for(i=0;i<8;i++)
      {
      output_bit(data,bit_test(table[i],(8-i)));
      output_high(clk);
      output_low(clk);
      }
      for(i=0;i<8;i++)
      {
      output_bit(data,bit_test(table[i],(8-i)));
      output_high(clk);
      output_low(clk);
      }
      for(i=0;i<8;i++)
      {
      output_bit(data,bit_test(table[i],(8-i)));
      output_high(clk);
      output_low(clk);
      }
      for(i=0;i<8;i++)
      {
      output_bit(data,bit_test(table[i],(8-i)));
      output_high(clk);
      output_low(clk);
      }
     output_high(stb);
     output_low(stb);
     
     count++;
     if(count>999)  count=0;
   }

   while(TRUE)
   {
      //TODO: User Code
   }

}
}
temtronic



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

View user's profile Send private message

PostPosted: Tue Jun 16, 2020 8:08 am     Reply with quote

possibly this is why.....

digit_0=table[i];
digit_1=table[i];
digit_2=table[i];
digit_3=table[i];
norstadd



Joined: 16 Jun 2020
Posts: 3

View user's profile Send private message

PostPosted: Tue Jun 16, 2020 8:25 am     Reply with quote

Any suggestion on how to fix it?
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Jun 16, 2020 9:54 am     Reply with quote

First, I don't think output_bit takes three parameters:

output_bit(data,bit_test(table[i],(8-i)));

Then you want to use the digit values you have loaded in these
outputs in turn.

But.
You really should be looking at doing this one digit at a time in the
interrupt, which want to be at a much lower frequency. It's currently
being called only about every 200 instructions.....
You don't say the processor clock rate, but this is silly....
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