Jump to content
43oh

LaunchPad LED Display Booster


Recommended Posts

I wanted to see how X-10 signals and switching heavy loads will affect my light controller's zero-crossing detector, so I programmed my LauchPad to count pulses and display result once every second.

In normal, interference free conditions, I expect to see steady 120, but due to internal clock's tolerance, I the count is alternating between 122 and 123.

In my first test, I am using X-10 transmitter plugged to the same outlet as light controller. Once or twice I can see a hiccup where 123 is longer than expected (this could be clock's tolerance because this hiccup is cyclic,) but nothing major like 124+.

In my second test, I am turning on and off 1200W Miele upright, lights in the room blink, but light controller is not affected.

 

 

Link to post
Share on other sites
  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Here is a little LED Display Booster pack (a.k.a. Shield) I have created for LaunchPad. It has 2 595's, uses 3 wires to communicate with LP, and supports both, common cathode and common anode display

It's finally here!   See my original post for more pictures and the movie.  

For those who got my boards, here's one example which uses USI in SPI mode to communicate with the board (bit banging can also be used, can post an example if needed.) P1.0, P1.5, and P1.6 have shor

Posted Images

  • 1 year later...
  • 4 months later...

Hey RobG, I pulled this boosterpack out of my drawer to use as a readout on my tablesaw project. Sorting through the code, I'm a bit confused. It won't display numbers higher than 4096. Send it 4097, and it just rolls over to show 0001. So basically, it shows (My_Number - 4096) instead of the proper value.  My knowledge of Assembly is limited but growing. Is there something in the ASM that would prevent numbers higher than 4096? Can you point me in the right direction to fix it up?

Link to post
Share on other sites

Well, don't thank yet :smile:

I just realized that all my binTo... functions are 12 bit, they were all created to be used with 10 bit ADC.

I will create 16 bit later on, but for now, you can use something like this:

 

void bin16ToUnpackedBCD(unsigned int n, unsigned char * digits) {

    unsigned char charIndex = 0;
    while (charIndex < 3) {
        digits[charIndex] = 0;
        charIndex++;
    }

    while (n > 0) {
        digits[charIndex] = n % 10;
        n /= 10;
        charIndex--;
    }
}
Link to post
Share on other sites

Ok, well finally got to actually test this and the above bin16ToUnpackedBCD function does not work either. It limits the display to < 1000. Send 999 and it shows 0999 as expected. Send 1000 or greater to it and it displays digit 0 and 3 only. so it looks like 1x0x.

 

I'll run through it a bit more and see what I can come up with; I know you're busy. Using the MSP430 Assembly manual, I'm commenting your ASM code so I can better see what it is doing.

Link to post
Share on other sites
void bin16ToUnpackedBCD(unsigned int n, unsigned char * digits) {

    unsigned char charIndex = 0;
    while (charIndex <= 3) {
        digits[charIndex] = 0;
        charIndex++;
    }

    while (n > 0) {
        charIndex--;
        digits[charIndex] = n % 10;
        n /= 10;
    }
}

You don't initialize digits[3] with 0, I changed it so it does.

 

In this case, I'd prefer to use just plain lines, not loops; it's only 4 lines and probably not more code anyway

void bin16ToUnpackedBCD(unsigned int n, unsigned char * digits) {
    digits[3] = n % 10;
    n /= 10;
    digits[2] = n % 10;
    n /= 10;
    digits[1] = n % 10;
    n /= 10;
    digits[0] = n % 10;
}

Now I'm looking at it, when your uin16 exceeds 9999 you'll try to write to charIndex -1 (that's minus 1), the second loop should be charIndex oriented instead of n oriented.

void bin16ToUnpackedBCD(unsigned int n, unsigned char * digits) {
    int charIndex;
    for(charIndex = 3; charIndex >= 0; --charIndex)
    {
        if (n != 0) // this if-block will save you unneccesary division operations, but adds a litle code to your codespace
        {
            // calculate digit
            digits[charIndex] = n % 10;
            n /= 10;
        }
        else
        {
            // n == 0; just put a zero in this digit
            digits[charIndex] = 0;
        }
    }
}
Link to post
Share on other sites

Ok, it's definitely on my end. I created a new project with your original code. Replacing the binaryToUnpackedBCD with bin16ToUnpackedBCD and it works great!

 

Sorry for any trouble. Fail on my part for sure. I'll sort out my code. In my attempt to add a bit of abstraction, I screwed something up somewhere.

 

Thanks for the help!

 

EDIT: @roadrunner84, I'll test your function out after dropping the kiddo off at camp this morning.

 

EDIT: @RobG, do you have any more of these PCBs? The store has been out for some time.

Edited by gwdeveloper
Link to post
Share on other sites

Good catch rr84, I was setting those individually before I changed to loop, missed that one.

 

Re int >9999, before you use bin16ToUnpackedBCD, you should verify that then number is in the range and if it's out of range, display error or something like that.

You can also change the function to convert to 6 chars, but then you will not be able to display #5 and #6 on a 4 digit display.

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.


×
×
  • Create New...