free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Rickey's World :: Discussion Forums :: Discuss and Learn :: 8051 Discussion Forum
 
<< Previous thread | Next thread >>
receive serial data on 4 7 segements .
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage
Author Post
guitar
Thu Jul 16 2009, 09:44AM
 User Offline
Registered Member #10154
Joined: Wed Aug 27 2008, 04:15AM

Posts: 45
Thanked 2 times in 2 posts
Hello Sir,

I am trying to connect '4' 7segements to Microcontroller.The microcontroller will inturn receive data from serial port.
I am able to receive data and display on '4' 7 segements.for.eg if i am getting 1234 as serial data then only 1digit is displaying out of four above mentioned digits('1234') on all '4' 7 segments.I am attaching the .hex file,proteus design and my 'c' code.Kindly,suggest me for the same.
serial_trans.zip

Back to top

tweety bird
Thu Jul 16 2009, 07:31PM
 User Offline
Registered Member #7329
Joined: Sat Apr 19 2008, 08:49PM

Posts: 70
Thanked 8 times in 7 posts
though i havent seen ur proj , but still i ll try to giv u some suggestions...
receive data thru serial port, show them on 7 seg one by one..
when u rec 1st char, enable 1 st 7seg n disable all others n send data to it..
then u rec 2nd char, enable 2nd 7seg n disable all others, n send data to it...
n so on..
it should be simple ...
Back to top

guitar
Thu Jul 16 2009, 08:26PM
 User Offline
Registered Member #10154
Joined: Wed Aug 27 2008, 04:15AM

Posts: 45
Thanked 2 times in 2 posts
but i want all the 4 digits(1234) to display on each seven segment display simultaneously.
like ' 1' on 1st seven segment, '2' on 2nd seven segment , '3' on 3rd seven segment , '4' on 4th seven segment and so on. but each seven segment should display retain their value .

so that value appears to be '1234' on whole 4 7 segment display.
Back to top

afilash
Fri Jul 17 2009, 12:58PM

 User Offline
Registered Member #20315
Joined: Tue Jul 14 2009, 07:52AM

Posts: 21
Thanked 2 times in 2 posts
I can't able to open the circuit diagram you have send, could you please send it as a JPG?
i assume you are using multiplexing to display numbers in 7 seg using port P1?
if your program is like that given in the zip file it wont work !!!!
declare an array of length 4.
what you have to do just receive numbers one by one
convert each ASCII character to display_code
push those codes in to that array like a circular buffer
then
while the program is not receiving any ASCII character
pull the character_code from the array and send it through port P1 one by one simultaneously enable the correct seven segment
you have to do the last part in a loop!!!!!!


i will tell you what your current will do >>>
it will recive the ASCII > convert it to seg_code > push it out through P1
since all the enable lines are high during this process all the 7 seg will display the current character you have sent to the microcontroller
:mad

got it?

then reprogram your code !
or else we will help you :-)
Back to top


This post has been thanked 1 time
 guitar 
guitar
Fri Jul 17 2009, 01:49PM
 User Offline
Registered Member #10154
Joined: Wed Aug 27 2008, 04:15AM

Posts: 45
Thanked 2 times in 2 posts
hello sir,
thanks for your valuable support.
I have understood the way you have described and would implement this way.
i want to know that..previously i was using a array[4].But ,it would only store the last value that came from serial port.Thus, i was not able to save and retrieve value for rest the data in array(array[1],array[2] and array[3].
Back to top

afilash
Fri Jul 17 2009, 02:31PM

 User Offline
Registered Member #20315
Joined: Tue Jul 14 2009, 07:52AM

Posts: 21
Thanked 2 times in 2 posts
No need to call me "Sir"
you can call me "abhi" or "afilash"
in your previous code , I assume that the array variable get initialized inside you serial_reception_code_section
any way rewrite it & show us :-)
Back to top


This post has been thanked 1 time
 guitar 
rahuljin
Sat Jul 18 2009, 12:39AM

 User Offline
Registered Member #3897
Joined: Fri Sep 07 2007, 01:19PM

Posts: 180
Thanked 14 times in 14 posts
here is some code ----

CODE:

#include <REGX52.h>
#include <stdio.h>
#include <math.h>

unsigned int DIGI[4];

void Delay()
{
    unsigned int i;
    for(i=535;i>0;i--);
}

void display()
{
        P2_3 = 1;
        P1 = DIGI[0];
        Delay();
        P2_3 = 0;
        P2_2 = 1;
        P1 = DIGI[1];
        Delay();
        P2_2 = 0;
        P2_1 = 1;
        P1 = DIGI[2];          
        Delay();
        P2_1 = 0;
        P2_0 = 1;
        P1 = DIGI[3];          
        Delay();
        P2_0 = 0;
}

void main()
{

        unsigned int c;
    unsigned int i = 0;
            //I want to use the array to store '1234' values from serial ports.How can i do it?
       
        TMOD = 0x20;
    SCON = 0x50;
    TH1  = 0xFD;
    TL1  = 0xFD;
    TR1  = 1;



        for(i = 0; i < 4; i++)
        DIGI[i] = 0xC0;
 
    while(1)
        {          

               
                for(i = 0; i < 4; i++)
                {
                        while(!RI)
                        {
                        display();
                        }
                        c = SBUF;
                        RI = 0;
                        switch(c)
                        {
                                case 0x30: DIGI[i] = (0xC0);
                                        break;
                                case 0x31: DIGI[i] = 0xF9;
                                break;
                                case 0x32: DIGI[i] = 0xA4;
                                break;
                                case 0x33: DIGI[i] = 0xB0;
                                break;
                                case 0x34: DIGI[i] = 0x99;
                                break;
                                case 0x35: DIGI[i] = 0x92;
                                break;
                                case 0x36: DIGI[i] = 0x82;
                                break;
                                case 0x37: DIGI[i] = 0xF8;
                                break;
                                case 0x38: DIGI[i] = 0x80;
                                break;
                                case 0x39: DIGI[i] = 0x98;
                                break;
                                default: DIGI[i] = 0xBF;
                                break;
                        }
                          display();
       
                }

        }
}


 


the name is rahul
Back to top


This post has been thanked 1 time
 guitar 
Bohemian Strings
Sat Jul 18 2009, 07:04PM
 User Offline
Registered Member #20464
Joined: Sat Jul 18 2009, 11:33AM

Posts: 15
Thanked 0 times in 0 posts
Hello Rahuljin,

I have a request. Can you rewrite the same C program using the function bioscom(), if you please? I have to do a similar sort of a job, but using bioscom() only... Please help if you can.
:-)
Back to top

rahuljin
Sat Jul 18 2009, 07:49PM

 User Offline
Registered Member #3897
Joined: Fri Sep 07 2007, 01:19PM

Posts: 180
Thanked 14 times in 14 posts
what is bioscom() ? explain a bit so that i can help

[ Edited Sat Jul 18 2009, 07:50PM ]

the name is rahul
Back to top

Bohemian Strings
Sat Jul 18 2009, 10:22PM
 User Offline
Registered Member #20464
Joined: Sat Jul 18 2009, 11:33AM

Posts: 15
Thanked 0 times in 0 posts
Rahuljin,

bioscom() is a function that is used to support serial communication through RS 232. It can only be compiled in DOS based C editor and requires the header file <bios.h>. Please refer to my post Project: Serial communication between Microcontroller and PC in the 8051 discussion forum... I did explain everything there... Any kind of help will be really appreciated. I need this job to be done by tomorrow...

[ Edited Sat Jul 18 2009, 10:23PM ]
Back to top

 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems