Shop OBEX P1 Docs P2 Docs Learn Events
8 Digits with Maxim 7219 and Basic Stamp — Parallax Forums

8 Digits with Maxim 7219 and Basic Stamp

ryfitzger227ryfitzger227 Posts: 99
edited 2013-12-03 10:05 in BASIC Stamp
Okay. So I've searched the forums, google, etc for the past 2 hours I'd say and can't find really anything about this. Everything I've found has been for 4 digits or lower and everything that talks about an 8 digit was never solved or is to complex for me to read it and understand it.

I've been using the AppKit for the Maxim 7219 and BS2 and got 4 digits working just fine, but when I tried to add in the next 4 digits it stopped working. Here's the code I've been using.
' {$STAMP BS2}
' {$PBASIC 2.5}


DATA_n  CON 7
CLK CON 5
Load  CON 6


decode  CON 9
brite CON 10
scan  CON 11
switch  CON 12
test  CON 15
DecPoint CON 000000


max_dat VAR Word
index VAR Nib
temp  VAR Byte
nonZ  VAR Bit
dispVal VAR Word
odd VAR index.BIT0


OUTS = 0
DIRS = $FFFF


FOR index = 0 TO 7
  LOOKUP index,[scan,4,brite,3,decode,$1F,switch,1], max_dat
  SHIFTOUT DATA_n, CLK, MSBFIRST,[max_dat]
  IF odd = 0 THEN noLoad
  PULSOUT Load,1
NoLoad:
NEXT


dispVal = 1234


MaxDisplay:
nonZ = 0
FOR index = 4 TO 1
  SHIFTOUT DATA_n, CLK, MSBFIRST,[index]
  temp = dispVal DIG (index - 1)
  IF temp = 0 THEN skip1
  nonZ = 1
skip1:
  IF nonZ = 1 OR temp <> 0 OR index = 1 THEN skip2
  temp = 15
skip2:
  SHIFTOUT DATA_n, CLK, MSBFIRST,[temp]
  PULSOUT Load, 5
NEXT


RETURN


Instead of using a counter like it is in the AppKit, I just set the variable myself. When I set dispVal to something more than 1234 (like 12345678) I get an error message saying "Constant exceeds 16 bits." After doing some research I found out that 12345678 is actually 24 bits. How do I send something like this to the 7219?

Comments

  • PublisonPublison Posts: 12,366
    edited 2013-12-02 17:00

    paperclip.png Attached Files
  • ryfitzger227ryfitzger227 Posts: 99
    edited 2013-12-02 17:55
    This is just confusing me. He's using a dot matrix and already created his patterns. I would like to stick with using decimal numbers and a 7 segment display. What part of the code is actually letting us use 8 digits?

    BTW: The Attached file is invalid.
  • PublisonPublison Posts: 12,366
    edited 2013-12-02 18:11
    Try this one.
  • ryfitzger227ryfitzger227 Posts: 99
    edited 2013-12-02 18:30
    I'm sure this could be simplified, but right now this works.
    digit_1 = 4
    digit_2 = 3
    digit_3 = 2
    digit_4 = 1
    digit_5 = 5
    digit_6 = 6
    digit_7 = 7
    digit_8 = 8
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[1]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_1]
    PULSOUT Load, 5
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[2]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_2]
    PULSOUT Load, 5
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[3]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_3]
    PULSOUT Load, 5
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[4]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_4]
    PULSOUT Load, 5
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[5]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_5]
    PULSOUT Load, 5
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[6]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_6]
    PULSOUT Load, 5
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[7]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_7]
    PULSOUT Load, 5
    
    
    SHIFTOUT DATA_n, CLK, MSBFIRST,[8]
    SHIFTOUT data_n, CLK, MSBFIRST,[digit_8]
    PULSOUT Load, 5
    
  • SavageCircuitsSavageCircuits Posts: 264
    edited 2013-12-03 10:05
    Here's an example that uses all 8 digits, although only 6 are being shown as numbers. The other two are used for the AM/PM and COLON indicators.

    http://www.savagecircuits.com/binarydigitalclock
Sign In or Register to comment.