dual 7-segment dice

Discussion in 'Homework Help' started by mojocyber, Jan 8, 2014.

  1. mojocyber

    Thread Starter New Member

    Dec 4, 2013
    3
    0
    I am having problems with my code it is not displaying as I want it to, I have to have it finished in 2 days.

    Code ( (Unknown Language)):
    1.  
    2. /* Created:   Mon Nov 25 2013
    3. * Processor: PIC16F877
    4. * Compiler:  HI-TECH C for PIC10/12/16
    5. */
    6. /* double 7 Segment interfacing programme*/
    7.  
    8. #include <pic.h>
    9. #include <stdlib.h>
    10. #include <time.h>
    11.  
    12.  
    13. const static unsigned char segment_code[] = {   0x3F, //0
    14.                     0x06, //1
    15.                     0x5B, //2
    16.                     0x4F, //3
    17.                     0x66, //4
    18.                     0x6D, //5
    19.                     0x7C, //6
    20.                     0x07, //7
    21.                                                     0x7F, //8
    22.                                                     0x67}; //9
    23.  
    24. char counter1 = 0;
    25. char counter2 = 0;
    26. bit button_up = 0;
    27.  
    28. void main(void)
    29. {
    30.     TRISC=0x00; // all outputs
    31.     TRISD=0x00; // all outputs
    32.     TRISB=0xFF; // all inputs
    33.  
    34.     srand(rand()); // seeds random with time
    35.  
    36.     for(;;) // start of superloop
    37.     {
    38.         if(RB0==1)
    39.             button_up=1;
    40.         else
    41.         {
    42.             if (button_up==1)
    43.             {
    44.                 button_up=0;
    45.                 counter1=rand()%6+1;
    46.                 counter2=rand()%6+1;
    47.             }
    48.         }
    49.         PORTC=segment_code[counter1];
    50.         PORTD=segment_code[counter2];
    51.     }
    52. };
    53.  
    :confused:
     
    Last edited by a moderator: Jan 8, 2014
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    So, what is it displaying? Does anything show up? Where is your schematic? Have you checked the wiring? What is the target functionality? Have you isolated the programmer after programming tree target so as to not interfere with the display functionality (port C)?

    For wanting help, you haven't provided much information, aside from a code dump...
     
    Last edited: Jan 8, 2014
  3. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    So... are we supposed to use our highly advanced mind-reading skills to know how you want it to display?

    You need to CLEARLY describe what you WANT it to do and what it IS doing.
     
  4. mojocyber

    Thread Starter New Member

    Dec 4, 2013
    3
    0
    You are required to design an electronic dice simulator. The design will incorporate two seven segment displays, a pushbutton and the PIC16F877. A suitable circuit design developed in Proteus will be required to simulate the circuit and the software developed.
    When the push button is pressed both displays will show rapidly changing numbers between 1 and 6. When the button is released the two random numbers generated will be displayed.
    Requirements
    You will need to develop the circuit in the ISIS part of Proteus 8 and the C code for the PIC16F877, using the HiTech 'C' compiler. The report should document the design procedure with sufficient detail so that it could be redeveloped by others.

    I have 1 7-segment connected to RCO to RC6
    and 1 7-segment connected to RDO to RD6
    push button connected to RBO

    it is not outputting full digits
     
  5. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,393
    497
    I am going to start with a couple of things that I find odd.

    1.
    The dice have values between 1 and 6. Your segment_code array contains 0, 7, 8, 9. You are asked to display 1, 2, 3, 4, 5, 6. Why do you have 0, 7, 8, 9?

    2.
    Ok. I got this part wrong.
     
  6. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Is that on both, or just one display? If just one, which?
    Does it display incomplete characters, or characters that don't make sense?

    Have you tried just making both segments count up to 7 to verify the connections?

    Since you have a schematic, how about you post it?
     
  7. mojocyber

    Thread Starter New Member

    Dec 4, 2013
    3
    0
    schematic has been added as an attachment
     
  8. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    Are you sure you're getting any display on the CC 7-SEG LED?

    I see that you're using 220K resistors for current limiters for your display. The rest of the circuit are OK. I'd put a 10K resistor for the MCLR to Vcc.

    Allen
     
  9. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,810
    834
    Can someone else count the connections to the 7 segment display on the left? I don't see enough resistors. My eyes are not so good.
     
  10. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,393
    497
    RC2 line missing a resistor.
     
  11. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Pin 36 should be grounded, as this is configured to be PGM for low voltage programming.

    As others have noted, add a resistor to RC2 and reduce the resistor values... try 330Ω.
     
Loading...