Jump to content
Sign in to follow this  
sreenugummadi

interfacing msp430g2 launchpad with multiplexed common anode seven segment display using energia

Recommended Posts

i would like to interface a multiplexed 4-digit-7-segment common anode display with msp430 g2 launchpad and display 4 numbers simultaneously.here the 4 digits are controlled by 4 BC547 transistors.

here the segments a,b,c,d,e,f,g,dp of the display are connected to port1 pins respectively and the transistors bases are connected to port2 pins.

i tried with single 7-segment display and it is working .when i extended to 4-digits i could not get the display.

could you please give me the code to display 4 numbers simultaneously.

thank you...

Share this post


Link to post
Share on other sites

Then probably the 4 digit display does not behave similar to the separate digits.

Are you sure both are common anode? Is the LED colour the same (green LEDs generally need higher voltage then red ones, blue even worse)? Is the forward current specification the same (larger displays take more current than tiny screens)?

Share this post


Link to post
Share on other sites

I'll also add, that for a common anode LED display using an NPN transistor such as the BC547 is probably not the best option, as the maximum voltage at the emitter is the base voltage less 0.65V. A high from the MSP430 is typically .3V below Vcc, so with the 3.6v supply of the launchpad, you'll only get 2.65V at the anode. The pins driving the cathode will typically go to Vss+0.3V, so you are only left with 2.35v across the LED, which will probably be enough for most red LEDs, but is barely enough for yellow or green, and definitely not enough for blue or white.

 

A better solution is to use a PNP transistor such as the BC557. The emitter is connected to your positive supply, the base (through a resistor) to the MSP430 pin, and the collector to the LED anode.  Doing it this way becomes negative logic - i.e., the transistor & LED are turned on when the output pin is set to low.

 

As for code, the basic code would look something like the following... 

const uint8_t anode_pins[4]={P2_0, P2_1, P2_2, P2_3}; //the pins that our anodes are connected to.
                                                      //note that the rest of this code assumes that you are
                                                      //using a PNP transistor to drive the anodes as 
                                                      //recommended above.

uint8_t display_segments[4];   //this array holds the values for each of the digit's segments. 
                               //display_segments[0] is the first digit, [1] is the 2nd etc.
                               //each bit is active low, so a value of B11111111 would have all
                               //segments off, while B000000000 would have all segments on.
                               //the actual mapping of the bits depends on the mapping of your pins
                               //to the segment displays, but if you have P1_0 -> a (top segment), 
                               //P1_1 -> b (right-top segment), P1_2 - > c (right-bottom segment) etc,
                               //then a value of B11111000 would be a 7 (a, b & c lit) 
                               //

//
// put your setup code - you will want to set your pins to outputs, and initially set all
// the pins to high
//

//code snippet to update display. Each time you call this function, it will light up the
//next digit of the LCD display. This routine should be called frequently - preferably at 
//least 100 times per second, so that the display won't have noticeable flicker.
//You could call this in your loop() routine if it doesn't do things like have big delays,
//or for more advanced usage, set up a timer with an interrupt routine.
//
void DisplayNextDigit()
{
  static uint8_t current_digit = 0;
  digitalWrite(anode_pin[current_digit],1); //turn off the last digit that was displayed
  current_digit++;                       //step up to the next digit
  if (current_digit==4) current_digit=0; //if we were on the last digit, go back to the 1st
  P1OUT=display_segments[current_digit]; //load the cathode values for the segments.
                                         //we use direct register access rather than
                                         //digitalWrite so we can set all segments
                                         //simultaneously for better speed & less code.
  digitalWrite(anode_pin[i],0);          //turn the digit on
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...