Shop OBEX P1 Docs P2 Docs Learn Events
Show 4 different values on LED display using one display driver — Parallax Forums

Show 4 different values on LED display using one display driver

MoskogMoskog Posts: 554
edited 2010-03-02 20:19 in BASIC Stamp
I need some advice her. I am testing temperature readings on LED display using MAX7219 LED driver and a BS2.
The scenario is measuring temperature on four different places using four sensors that provide integer temperature readings, like 10C, 15C, 9C and 25C. And then display them all using one LED driver
I found this example code in Parallax App-docs and with this I can display one of the numbers right now on the right side of a four-digit display:

dispVal = temperature1· 'Let us say temperature1 is our first reading (decimal value 10)
······················· 'temperature2 is 15 and so on.

Display:
nonZ = 0········································· ' Clear flag for 1st non-zero digit.
FOR index = 2 TO 1······························· ' Work from digit 2 down to digit 1.
· SHIFTOUT MaxDATA_n,MaxCLK,MSBFIRST,[noparse][[/noparse]index]····· ' Send digit position.
· temp = dispVal DIG (index-1)··················· ' Get decimal digit (0-4) of dispVal.
· IF temp = 0 THEN skip1························· ' If digit = 0, don't set nonZ flag.
· nonZ = 1
skip1:
· IF nonZ = 1 OR temp <> 0 OR index = 1 THEN skip2· ' If leading 0..
· temp = 15········································ '..write a blank to the display.
skip2:
· SHIFTOUT MaxDATA_n,MaxCLK,MSBFIRST,[noparse][[/noparse]temp]········ ' Send the digit.
· PULSOUT MaxLoad,5································ ' And load the display.
NEXT··············································· ' Repeat for all 4 digits.
RETURN············································· ' Done? Return.

Now, as an example, if I have an 8-digit LED display and I want to display all four readings on that display
so the display shows 10150925. (One single MAX7219 can handle eight digits), this is what I need help to do! In case of one digit reading the leading zero can be displayed.
In the end I am not going to use one 8-digit display but four 4-digits displays instead
where I use only the two left digits on each display to show the (dynamic) temperature readings. Then use the two remaining digits to the right to show the (static) degree-sign and the letter C, but those can be made by using resistors and not waste BS2 memory.
The main thing here is to use one single MAX7219 to display 4 different readings instead of have to use 4 different expensive display drivers.

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-03-02 17:08
    Most of the complexity of that display routine is involved with skipping the leading zeros--no doing so should be much simpler! I added one variable, "position" that would set the starting point for each dispVal.
    Display:
      FOR index = 1 TO 0                                ' Work from digit 2 down to digit 1.
        SHIFTOUT MaxDATA_n,MaxCLK,MSBFIRST,[noparse][[/noparse]index+position]      ' Send digit position.
        temp = dispVal DIG (index)                    ' Get decimal digit (1-0) of dispVal.
         SHIFTOUT MaxDATA_n,MaxCLK,MSBFIRST,[noparse][[/noparse]temp]         ' Send the digit.
        PULSOUT MaxLoad,5                                 ' And load the display.
      NEXT                                                ' Repeat for all 2 digits.
    RETURN                                              ' Done? Return.
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MoskogMoskog Posts: 554
    edited 2010-03-02 20:19
    Thank you, Tracy, that is exactly what I was looking for.
    It is so amazing how simple a solution can be sometimes, I spent hours to figure out how and was never able to see it.
    Just remove a lot of stuff and add a single Nib!
    Works perfect, now I can continue with the project. Thanks again!
Sign In or Register to comment.