Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multiple 3X1 sevensegment display connection with PIC microcontroller

Status
Not open for further replies.
I uploaded proteus DNS file, proteus 7.8 sp2.

Anyway: update: Capture2.PNG

Code:
/*******************************************************************************
* Program for, Shift Register Display test for multiple digits                 *
* Program Written by_ Engr. Mithun_K_Das, mithun060@gmail.com                  *
* MCU:PIC16F877A; X-Tal: 20MHz                                                 *
* Date: 07-09-2017                                                             *
*******************************************************************************/


Digit_conversion(char digit)
{
   switch(digit)
   {
      case 0: digit = 0x3F; return digit;
      case 1: digit = 0x06; return digit;
      case 2: digit = 0x5B; return digit;
      case 3: digit = 0x4F; return digit;
      case 4: digit = 0x66; return digit;
      case 5: digit = 0x6D; return digit;
      case 6: digit = 0x7D; return digit;
      case 7: digit = 0x07; return digit;
      case 8: digit = 0x7F; return digit;
      case 9: digit = 0x6F; return digit;
   }
}

unsigned int number1=0, number2=0;
int digit=0;
void Disp_number1(unsigned int value)
{
   digit = (value/1u)%10;
   Spi_Write(Digit_conversion(digit));
   digit = (value/10u)%10;
   Spi_Write(Digit_conversion(digit));
   digit = (value/100u)%10;
   Spi_Write(Digit_conversion(digit));
}
void Disp_number2(unsigned int value)
{
   digit = (value/1u)%10;
   Spi_Write(Digit_conversion(digit));
   digit = (value/10u)%10;
   Spi_Write(Digit_conversion(digit));
   digit = (value/100u)%10;
   Spi_Write(Digit_conversion(digit));
}
void Update_display()
{
  PORTC.F6=1; //one latch clock
  PORTC.F6=0;
}
void main()
{
  TRISC = 0x00;
  PORTC = 0x00;
  CMCON = 0x07;
  ADCON1 = 0x07;
  SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
  while(1)
  {

      number1 = 123;
      number2 = 789;
      Disp_number1(number1);
      Disp_number2(number2);
      Update_display();
    
  }

}

Tell me if I'm in right way... I've just tested with 2 3X1 digits. And will extend step by step.

- - - Updated - - -

update:

Capture3.PNG

HTML:
/*******************************************************************************
* Program for, Shift Register Display test for multiple digits                 *
* Program Written by_ Engr. Mithun_K_Das, mithun060@gmail.com                  *
* MCU:PIC16F877A; X-Tal: 20MHz                                                 *
* Date: 07-09-2017                                                             *
*******************************************************************************/


Digit_conversion(char digit)
{
   switch(digit)
   {
      case 0: digit = 0x3F; return digit;
      case 1: digit = 0x06; return digit;
      case 2: digit = 0x5B; return digit;
      case 3: digit = 0x4F; return digit;
      case 4: digit = 0x66; return digit;
      case 5: digit = 0x6D; return digit;
      case 6: digit = 0x7D; return digit;
      case 7: digit = 0x07; return digit;
      case 8: digit = 0x7F; return digit;
      case 9: digit = 0x6F; return digit;
   }
}

unsigned int number1=0, number2=0,number3=0,number4=0;
int digit=0;
void Disp_number(unsigned int value)
{
   digit = (value/1u)%10;
   Spi_Write(Digit_conversion(digit));
   digit = (value/10u)%10;
   Spi_Write(Digit_conversion(digit));
   digit = (value/100u)%10;
   Spi_Write(Digit_conversion(digit));
}
void Update_display()
{
  PORTC.F6=1; //one latch clock
  PORTC.F6=0;
}
void main()
{
  TRISC = 0x00;
  PORTC = 0x00;
  CMCON = 0x07;
  ADCON1 = 0x07;
  SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
  while(1)
  {

      number1 = 123;
      number2 = 789;
      number3 = 256;
      number4 = 512;
      Disp_number(number1);
      Disp_number(number2);
      Disp_number(number3);
      Disp_number(number4);
      
      Update_display();
    
  }

}


So I'm in right way, right?

- - - Updated - - -

Now its 10 display so far.... & I'll try up to the end...
Capture10.PNG

Hope you like it.
 

Your SPI Clock is still at 5 MHz. Increase it.

Use Interrupts to send SPI data.

Your MCU will be able to do other tasks without display blinking then.
 

Yes! Everything will be updated step by step. I was just in the beginning level of this design. Hope to complete it soon.

- - - Updated - - -

SPI clock is Fosc/4 and it is maximum for this microcontroller. Is there any way to increase SPI clock?
 

Your SPI Clock is still at 5 MHz. Increase it.

From the last picture it is not clear if OP is actually cascading the data serially, but increasing the amount of shift-registers which is now 30, it imposes a limit on the maximum allowed speed due to the delay of each device in regard to the clock.

- - - Updated - - -

Nope, all of them are synced to the same clock.
 

Hi,

Your SPI Clock is still at 5 MHz. Increase it.

Use Interrupts to send SPI data.

Your MCU will be able to do other tasks without display blinking then.
Nonsense.
(I wonder why the OP changed the display now. But maybe it´s just another schematic the does not fit to the reality)

If the schematic it true:
The display is not multiplexed anymore. Even a SPI clock of 1000Hz could do the job.
There is no traffic on the bus as long as the display doesn´t change.

In reality I doubt it is working with 5MHz and 32 displays. Solution: --> slow down clock.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top