Shop OBEX P1 Docs P2 Docs Learn Events
Controlling a 4 digit 7-segment Display - Page 3 — Parallax Forums

Controlling a 4 digit 7-segment Display

13»

Comments

  • Rtrotter15,

    As I said there isn't much code for the MAX7219 itself.
    A 16-bit number is sent to the 7219 which starts with the address number of the register you are writing and then the data value that you are writing to it.
    The data is then loaded into the register when the LOAD pin is pulsed.

    Several of the registers control the intensity of the display, how many digits to use, and whether to use BCD coding or not.
    If you turn off the BCD coding then you can control the each segment directly.

    The 7219 can also control LEDs and several 7219s can be linked together to create a larger display.
    Neat little chip but you need to read the datasheet to know how to use it.
    The tables for each of the registers shows what different values do but beware that these values are in Hex, 0x??

    Once you configure the 7219 then you write to one of the digit registers to update its value.
    After you pulse the LOAD pin then the new value will be displayed.

    The decimal point though is controlled manually but setting the MSB of the data bit, or adding 128 to the value that will be written to the Digit register.
  • RTrotter15 wrote: »
    So...... I've begun the process of modifying the Experiment #29 program to be used on a new version of the HomeWork Board.

    Here's what I think needs to be done (I'm not looking for the "exact answer", but the method of the madness of writing Stamp code).

    1. Modify the variable lines (penny VAR deposit.BIT0) to read something like "penny VAR Bit"? (the deposit.BIT0 is code for version 1.2 right?

    2. Modify the "Get_Coins" selection to read (5) I/O pins (P4 for penny, P3 for nickle etc)

    3. Add a "1" to each coin variable, so that it can be used in the statement "money = money + (penny *1)


    With all that said, I have a few questions.

    Q1. The "penny VAR deposit.BIT0" is code for version 1.2 right?

    Q2. What version is the statement "Main:" or "Get_Coins:"

    Thanks guys,

    Randy

    Addressing your questions, not necessarily in order:

    2, 1: Get_Coins *does* read the 5 I/O pins, in a non-obvious manner. The results are returned in deposit, bits 4-0. What happens is, deposit is initialized to indicate that all 5 coins are present. Then this is ANDed, 10 times, with the inverse of the value on the bus. If any button is pressed, all 10 times, the respective bit in deposit stays a "1". All five buttons are read 10 times. Coins is defined as the five bits of the bus. I think your idea of replacing the routine with a series of reading I/O pins would make it more clear.
    pennyButton PIN 0
    penny = ~pennyButton //or should I say PennyBlossum ?

    3. Note that it can accept only one of any specific coin per pass.

    Q1 : Clearly, the definitions of the button have to match the way you think about the buttons
    Q2: Don't understand the question.

    tc




  • I think your idea of replacing the routine with a series of reading I/O pins would make it more clear.
    pennyButton PIN 0
    penny = ~pennyButton //or should I say PennyBlossum ?

    LOL, making it any clearer would be great (I know I've already jumped into the middle of a fairly complex learning process)

    3. Note that it can accept only one of any specific coin per pass.

    I don't think this should be a problem. I mean the program will rotate around and scan the I/O pins faster than a human can press a different button.

    Q2: Don't understand the question.
    I think I've already answered my own question, but I was trying to ask if these lines of code "Main:" or "Get_Coins:" were specific to a certain version of the HomeWork Board? Meaning, can I use them on my board? (I believe the answer is yes)

    RT
  • RTrotter15,

    The pushbuttons are wired in what's called an Active-Low configuration because the value will be Low or 0 when the button is pressed. This is because the pushbutton is connected to VSS or Ground which is at 0 Volts and the pin is held High or 1 through the 10K Pull-Up resistor to VDD or 5 Volts.

    If you connected the pushbutton to VDD or 5V and the 10K to VSS or Ground then you would have an Active-High configuration.
    In that case the 10K resistor would be called a Pull-Down because it would "Pull" the I/O Pin voltage "Down" to Ground or 0 Volts.
    The pin would then be pulled High everytime the button is pressed.


    Just beware that the PIN directive is only in PBASIC 2.5
    The PIN directive is nice because the program can read the I/O pin value directly.
    PBASIC 2.5 also has DO...LOOP which can be used instead of Loop:...GOTO Loop, and IF...THEN...ELSE...ENDIF is much easier to follow than the IF...THEN Label that PBASIC 2.0 uses.


    All HomeWork Boards use the BS2.
Sign In or Register to comment.