[SOLVED] 7 Segment 5 Digit Driver

Status
Not open for further replies.
Bro, can you write the code which i explained to you in the any MSP430 in the proteus ? Because, this project works with MSP430 not Renesas. Timer initialization and other peripherals are easy. I am wondering the algorithm behind the all 5 buttons. For example, do you use "sprintf" to convert values into ASCII then print these onto screen. In the detailed code, it is need for displaying letters maybe words onto it.
 

Sorry, I have never used MSP430. What are the functions of the 5 buttons ? I don't use sprintf(). I have given all versions of code to you. You can see the .c files. I have not used sprintf(). In my code mask[0] = 0xC0 and it is the value which will make the 7 segment display 0 if it is sent to TPIC. Similarly for all the 10 digits (0 to 9) there is a 7 Segment mask value.

Provide your MSP430 circuit. I want to know how TPIC and CD4017 connects to MSP430. I have IAR MSP430 Compiler but have never used it. 7 Segments can only display alphabets a, b, c, d, e, f. It can't display other letters.
 

@pic.programmer,

Your code is likely to suffer problems due to the fashion as you're handling the interruption. The first issue that I see is the use of Delays routine inside the interrupt vector; although the amount of 0,2ms could be negligible at this specific case, putting it there turns the program prone to lock anytime, particularly because you are also sending send data to serial from within this same interrupt vector. I presume that for baud rates much higher than 4800 this would not work properly.

It is not advisable to place too much processing inside interrupt vector, once this turn the debugging process a few more complicated. Unless you are totally aware of the timing requirement of each part of your program by a proper constraint analysis, a priori, the interrupt event should only deal with flags.

Code:
void Interrupt() {
sendByte(*ptr2char++);
                     break;
                case 1:
                case 3:
                case 5:
                case 7:
                case 9:
                      sendByte(0xFF);
                      break;
        };

        ++select;

        if((select == 0) || (select == 1) || (select == 3) || (select == 5) || (select == 7) || (select == 9)) {
                   CD4017_CLK = 1;
                   Delay_us(200);
                   CD4017_CLK = 0;
 

@andre_teprom

Hi

The interrupt occurs once every 2 ms and the delays used inside ISR and sendByte function take 200 us and 450 us and it is within the 2 ms time period. I know it is not a good practice to use delays inside ISR but as delays were small I used them. I will try to provide a better code which avoids delays inside ISR and also use a flag in ISR which is set in ISR and tested in while(1) loop and the required task is done.
 

The interrupt occurs once every 2 ms and the delays used inside ISR and sendByte function take 200 us and 450 us and it is within the 2 ms time period.

It is nice to know that you made the timing analysis so that minimizes the chance to occur some interlocking, anyway, once the kernel of the program lies at the interrupt vector, it is expected that the OP will add further features right there, therefore although the program works well at the current stage, should be not assured anytime.
 

@andre_teprom

I am trying to find out whether there is a method so that I can jump from ISR to a piece of code in while(1) loop without using goto statement.
 



As you can see in the figure above, the emmitter of the npn type bjts are connected the anode of the leds. Bases of each bjt are driven by 125Hz %20 duty pwm. Initially everything is off, what is the voltage of the emmitter ? According to a simulation it is 0V initially, but as i know is it +5V because bjt is off(Vb=0) In fact, it is open if i don't apply invert pwm initially !

I don't know if im wrong, please reply

Thank you.

Edit___




As you can see above, this is basic simulation of one led.
In the simulation,

Black Signal - Base signal
Blue Signal - Emitter Current
Green Signal - Emitter Voltage

Everything include current seems normal, but in previous simulation of the same circuit emitter current was reversed so, it was negative while pwm on time.
 
Last edited:

The outputs of TPIC6b595 are open drain outputs and hence you will need 8 pull up resistors at the outputs of it.

I think there is no need for this. Cause after ST_CP, output transistors are opened. If CD4017 output is high then pull anode up +5V then open drains pull current from this source. So there is no need for extra pull-up resistors, only current limiter resistors should be enough.
 



Why it cannot be assigned to the first address of this array ?
 

Code:
ptr2char = display;
or if you find difficult to understand the above code, you can use:

Code:
ptr2char = &display[0];
display is a "char *". The &display is a "char **"
 



I've wired up the led driver circuit. The problem is that TC4017BP's outputs are not up to +5V, they are always 0,05V ? As you can see in the schematic drawing paper, the two IC which are placed left downward position are TL274 opamps, they are responsible for boost 3,3V coming from uC to 5V to apply the input voltages of TPIC595b and TC4017BP. They works correctly as a code. But, the problem is that either 4017 outputs or TPIC595 open drains,confused.

Any help would be appreciated

Thanks in advance.
 

It is not the cause of your problem, but why you use resistors to the common anode of the 7seg?
This will change the brightness depending on how much of the 7 segments are on.
Resistors should be used on the segment cathodes.

Have you measured the 4017 input lines and have the approximate 5V/0Vfor low/high values?
The Q0 (not connected) output of the 4017 does not get high when reset input get high?
The cd4017 is capable of providing only 1,5mA on 5V supply, may not be enough depending on the NPN transistors selected.
 
Last edited:

It is not the cause of your problem, but why you use resistors to the common anode of the 7seg?
This will change the brightness depending on how much of the 7 segments are on.
Resistors should be used on the segment cathodes.

I think it does not matter whether resistors are placed behind anode or in front of the cathode while led is on. Bjt's can supply 200mA continous current so that it should be limited.


Have you measured the 4017 input lines and have the approximate 5V/0Vfor low/high values?

I measured the CLK input of 4017 4.95V as high and 0.05V as low,but it does not affect the outputs of the IC. They are always 0.05V

The cd4017 is capable of providing only 1,5mA on 5V supply, may not be enough depending on the NPN transistors selected.

If TC4017 can open the any NPN transistor, 1.5mA would be enough to work bjt in saturation region.
 

You don't say the value of resistor connected to anode. You say 200 mA can flow. So, I assume R = V / I = 5 / 200 mA = 25E. So if 200 mA current is flowing in each transistor and only one segment of a digit is ON then 200 mA current will flow through that LED. Is this good for the LED ?
 

Bro even outputs of tc4017 does not go high. How would it suggest that any current can flow.

100 ohm resistors are used.
 

even outputs of tc4017 does not go high
Apparently you are not controlling it correctly. Is Q0 permanently high? Then you're either holding 4017 in reset or not clocking it.

TL274 will only work as low speed level converter, you better use 74HCT logic gates.

One you have managed to operate the digit and segment driver, you'll see with your own eyes why the current limiting resistors should be placed in the segment and not the digit lines.
 
Reactions: xenos

    xenos

    Points: 2
    Helpful Answer Positive Rating
Before Starting Timer call this code.

Code:
CD4017_RST = 0;

I have checked the datasheet. If CD4017_RST is high then clock will not advance.
 

I restart the TC4017 by giving rst pin 1 then waiting 50us, give it 0 above while(1) in the code. But, Q0 is not going high i dont understand why it does not work properly :-?

Code:
#include "msp.h"
#include "main.h"

char capture[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
char select = 0;
unsigned int number = 12345;
char  display[5] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

char *ptr2char = 0;
void sendByte(unsigned char byte);

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT

    // Configure GPIO
        P5DIR |= BIT4 | BIT5;   // CLK ve RST çıkışları
        P4DIR |= BIT7 | BIT5 | BIT4; //SER_IN, RCK,SRCK
        P5OUT &= ~BIT5;
        P5OUT &= ~BIT4;
        P4OUT &= ~BIT7;
        P4OUT &= ~BIT5;
        P4OUT &= ~BIT4;

        RST_h;
        _delay_cycles(50-1);
        RST_l;

    TA0CCTL0 = CCIE;                          // TACCR0 interrupt enabled
    TA0CCR0 = 5000; 							// 5ms de bir interrupt
    TA0CTL = TASSEL__SMCLK | MC__CONTINUOUS;   // SMCLK, continuous mode
    ptr2char = &display[0];
    SCB_SCR |= SCB_SCR_SLEEPONEXIT;           // Enable sleep on exit from ISR

    __enable_interrupt();
    NVIC_ISER0 = 1 << ((INT_TA0_0 - 16) & 31);

    while (1)
    {
        display[0] = 0xF9;
        display[1] = 0xA4;
        display[2] = 0xB0;
        display[3] = 0x99;
        display[4] = 0x92;
    }
}

// Timer A0 interrupt service routine

void TimerA0_0IsrHandler(void) {

 switch(select) {
                case 0:
                case 2:
                case 4:
                case 6:
                case 8:
                     sendByte(*ptr2char++);
                     break;
                case 1:
                case 3:
                case 5:
                case 7:
                case 9:
                      sendByte(0xFF);
                      break;
        };

        ++select;

        if((select == 0) || (select == 1) || (select == 3) || (select == 5) || (select == 7) || (select == 9)) {
                   CLK_h;
                   _delay_cycles(200-1);
                   CLK_l;
        }

       if(select == 10) {
              RST_h;
              _delay_cycles(200-1);
              RST_l;
              select = 0;
              ptr2char = &display[0];
        }

        TA0CCTL0 &= ~CCIFG;

}
void sendByte(unsigned char byte) {
    char i = 0, mask = 0x80;

    for(i = 0; i < 8; i++) {
            if((byte & mask)==1){
               SER_IN_h;
            }
            else if ((byte & mask)==0){
               SER_IN_l;
            }
            SRCK_h;
            _delay_cycles(50-1);
            SRCK_l;

            mask >>= 1;
    }

    RCK_h;
    _delay_cycles(50-1);
    RCK_l;
}

Update___________

I've just tested my opamps outputs they are not normal. When i built up this circuit,opamp outputs are 5V when msp gives 3.3V to non-inverting input of the opamps and 0.05V when msp outputs are 0V. But now, even msp gives 3.3V to opamps non-inverting input, output of opamp is 1.11V :S and the other measurement shows 3.68 V . Im very confused. Did i damage the TC4017 or TPIC5b595 ' inputs ?
 
Last edited:

TO whom it may concern.

Nobody makes 7 segment LED displays that you can multiplex at the rated current x 10, and x5 is a practical limit.
Therefore you must lower your average current by 50% or stop using 10 stages of counter and use only 5.

Using 5 interleaved stages of a 10 stage Johnson Counter means each digit will only be 10% of it's expected brightness.

The absolute max current only applies when none of the other segments are on, because it specifies 25'C and when all other the segments are on, this must be Ipeak must be derated 50% due to internal temp rise from each segment.

Otherwise , the junctions will fry >125'C. Users be advised.

 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…