Shop OBEX P1 Docs P2 Docs Learn Events
Advanced 7-Segment Multiplexing — Parallax Forums

Advanced 7-Segment Multiplexing

bsparkybsparky Posts: 52
edited 2005-03-10 19:34 in Learn with BlocklyProp
I am tring to understand the code for Experiment #29 from the Parallax web site.

index var nib
idxodd var index.bit0

for index=0to7
lookup index,[noparse][[/noparse]scan,3,brite,5,decode,$of,shutdn,1],d7219
shiftout datapin,clock,msbfirst,[noparse][[/noparse]d7219]
if(idxodd=no) then no_load
pulsout load,5

They show the NEXT command after the no_load label I believe it should be before it,but thats not my real question.
What exactly is happening with the statment IF(IDXODD=NO) THEN NO_LOAD isn't the idxodd looking at bit0 of the nib index and would this bit0 not change alternetly 0 & 1 as the index went through the count 0 to 7.

0000 for 0 count
0001 for 1 count
0010 for 2 count
0011 for 3 count
0100 for 4 count
0101 for 5 count and so on ?

Or am I looking at this all wrong must be any light on this.......... Thanks Bill

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-10 05:04
    In that routine, eight bytes are sent to the '7219 but you need to send two bytes before blipping the Load line. By monitoring the state of Bit0 in the loop control variable (index), we can skip the PULSOUT every other time to accomplish this. Bit0 of index does in fact change; when the value of index is even, Bit0 is clear (0), when index odd, Bit0 is set (1).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • bsparkybsparky Posts: 52
    edited 2005-03-10 15:08
    OK I see so the NEXT command after that should be after the NO_LOAD label that way it has someware to jump to. Thanks
    Another part in that same program has me a bit confused the variables DEPOSIT.bit0, DEPOSIT.bit1 a bit can only hold a 0 or 1 but you could have up to 9 pennys ? Thanks for clearing these question up for me. I a trying to make a scoreing display board.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-10 15:12
    Remembe that deposit is a bigger variable and the individual bits identify the user input (pennies, nickels, dimes, quarters, or dollars). The great thing about PBASIC is that we can use modifiers to examine specific portions of a variable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • bsparkybsparky Posts: 52
    edited 2005-03-10 16:11
    Quess I still don't see it. The way I look at it is like this....

    0000 0000 0000 0000 word hold value 65535
    0000 0000 byte hold value 255
    0000 nib hold value 15
    0 bit hold value 1


    So if you are looking bit0 of the var deposit you would be looking 0000 0000 which to my way of looking at it would be 0 or 1.

    Thanks for the help.
  • bsparkybsparky Posts: 52
    edited 2005-03-10 16:15
    sorry the last 0 in the byte should have been in bold but it didn't come out that way.

    0 0 0 0 0 0 0 0
    7 6 5 4 3 2 1 0
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-10 17:01
    You're not quite following the program -- let me see if I can shed some light.

    The Main loop calls a subroutine called Get_Coins. Get_Coins will scan the coin inputs and return 1s in the variable called deposit for the coin button(s) pressed. For example, on a scan of Get_Coins the Penny and Nickel inputs could be pressed. The value returned in depost would be %00011.

    Back up in the Main loop there is code like this:

    money = money + (penny * 1)       ' add coins 
    money = money + (nickel * 5) 
    money = money + (dime * 10) 
    money = money + (quarter * 25) 
    money = money + (dollar * 100)
    


    The idea is that if a coin bit is set (1), then the value for that coin would be added. This program is a little subtle -- spend some time with it and it will make sense.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • bsparkybsparky Posts: 52
    edited 2005-03-10 19:00
    I think I see it, each time through the key scan only one depression of each coin is registered then its add to the money var then we go back and check again. The DIG operator will make displaying the score much easier then the way I was thinking. I was thinking of taking the score digits apart and storing them as three var then sending them out to the display. The DIG operator does it for me.
    jumpin.gifjumpin.gif

    In my program I want to scan a 16 keypad then storing the keys as a single var number and check each key for the enter key which will tell me my number is done, then send this out to the display. Each number entered will be subtracted from a total value entered first. Will see how I make out. Should be fun. Love these STAMPS.


    I appreciate all your help.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-10 19:34
    You might want to have a look at this article for help on 4x4 keyboard scanning -- you can do it without an extra chip, but it takes more (precious) IO lines and requies a chunk of code.

    We're pleased that our products are a pleasure and that our demos are helpful.· Have fun!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.