EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Plz again helpe to understand programe for digital clock using seven segment

Plz again helpe to understand programe for digital clock using seven segment

|

Microcontroller › 8051 › Plz again helpe to understand programe for digital clock using seven segment

  • This topic has 6 replies, 3 voices, and was last updated 14 years, 6 months ago by Amit Kumar.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • May 16, 2011 at 10:32 am #940
    Amit Kumar
    Participant
    void display() interrupt 1        //Function to display the number using seven segmnet multiplexing. For more details refer seven segment multiplexing.
    {
    TL0=0x36; //Reloading Timer0
    TH0=0xf6;
    P2=0xFF;
    dig_ctrl_1 = dig_ctrl_3 = dig_ctrl_2 = dig_ctrl_4 = 0;
    dig_disp++;
    dig_disp=dig_disp%4;
    switch(dig_disp)

    May anyone tell me what is dig_disp & why it is incremented. What is the meaning of line

    dig_disp=dig_disp%4;

     

    May 16, 2011 at 11:08 am #6232
    dagakshay
    Participant

    send the link where you reffering this code…

    May 16, 2011 at 1:26 pm #6240
    romel emperado
    Participant

    that is only a variable…

     

    it needs to increment so that it will match to the switch case..

    May 17, 2011 at 8:34 am #6256
    Amit Kumar
    Participant

     

     

    Dear sir,

     

    I have pasted  the  programe.

     

    And tell me what is the variable for dig_disp. Please make me understand it.

     

    #include<reg51.h>
    sbit dig_ctrl_4=P1^0; //Declaring control pins of the seven segments
    sbit dig_ctrl_3=P1^1;
    sbit dig_ctrl_2=P1^2;
    sbit dig_ctrl_1=P1^3;
    unsigned char dig_disp=0;
    int min2;
    int min1;
    int sec2;
    int sec1;
    char digi_val[10]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10};

    void delay() //Function to provide a time delay of approx. 1 second. using Timer 1.
    {
    int i;
    for(i=0;i<20;i++)
    {
    TL1=0xFD;
    TH1=0x4B;
    TR1=1;
    while(TF1==0);
    TR1=0;
    TF1=0;
    }
    }

    void display() interrupt 1 //Function to display the number using seven segmnet multiplexing. For more details refer seven segment multiplexing.
    {
    TL0=0x36; //Reloading Timer0
    TH0=0xf6;
    P2=0xFF;
    dig_ctrl_1 = dig_ctrl_3 = dig_ctrl_2 = dig_ctrl_4 = 0;
    dig_disp++;
    dig_disp=dig_disp%4;
    switch(dig_disp)
    {
    case 0:
    P2=digi_val[sec1];
    dig_ctrl_1 = 1;
    break;

    case 1:
    P2= digi_val[sec2];
    dig_ctrl_2 = 1;
    break;

    case 2:
    P2= digi_val[min1];
    dig_ctrl_3 = 1;
    break;

    case 3:
    P2= digi_val[min2];
    dig_ctrl_4 = 1;
    break;
    }
    }

    void main()
    {
    TMOD=0x11; //Intialize Timer 0
    TL0=0x36;
    TH0=0xF6;
    IE=0x82; // Enable Timer 0 interrupt
    TR0=1; //Start Timer 0
    while(1) //Start clock
    {
    min2=min1=sec2=sec1=0;
    for(min2=0;min2<6;min2++)
    {
    for(min1=0;min1<10;min1++)
    {
    for(sec2=0;sec2<6;sec2++)
    {
    for(sec1=0;sec1<10;sec1++)
    {
    delay();
    }
    }
    }
    }
    }
    }

     

    May 17, 2011 at 1:51 pm #6258
    Amit Kumar
    Participant
    void display() interrupt 1        //Function to display the number using seven segmnet multiplexing. For more details refer seven segment multiplexing.
    {
    TL0=0x36; //Reloading Timer0
    TH0=0xf6;
    P2=0xFF;
    dig_ctrl_1 = dig_ctrl_3 = dig_ctrl_2 = dig_ctrl_4 = 0;
    dig_disp++;
    dig_disp=dig_disp%4;

    dig_disp is meant for what. It is variable, i understand it. But this variable is for what? & why it is written dig_disp=dig_disp%4;

    May 17, 2011 at 9:39 pm #6260
    romel emperado
    Participant
    dig_disp++;  // variable is increamented

    dig_disp=dig_disp%4; // as u can see this line using modulo any value
    switch(dig_disp)

    dig_disp=dig_disp%4;  // as u can see this line is using modulo any value of  this variable will be check by the switch case..

    this is simply getting the timing if you want faster timing you can change that in 2 instead of 4..

    try to experiment so that will know what happens if you change that line..

     

    May 25, 2011 at 12:27 pm #6299
    Amit Kumar
    Participant

    Now, i understand the programe.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Quick question on capacitors value in UF December 9, 2025
  • EEPROM not being written or read on dsPIC30F2010 December 9, 2025
  • Want Thermal Camera with Fixed Thermal Span option December 9, 2025
  • Printer loop December 9, 2025
  • mechanism to shutdown feeding when sensor temperature rises December 9, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise