Shop OBEX P1 Docs P2 Docs Learn Events
Regarding the BS2p40... — Parallax Forums

Regarding the BS2p40...

kingspudkingspud Posts: 128
edited 2008-04-21 18:47 in BASIC Stamp
Hello all,

This question is for the admins or those who are familiar with the BS2p40 chip.

My question is:

You know how you can run the command that will use %00010111 and it will directly output to ports P8 to P15...

Well...

Can you run a similar command that will work on the other side of the chip with ports X8 thru X15?

I need to use this command on both sides of the chip to access 16ports or if not, then it looks as if I may have to use [noparse][[/noparse] 2 ] BS2 chips for my project!

Thanks for the help.

Joe

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein

Comments

  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-04-19 21:32
    x VAR BYTE
    x = %00010111
    MAINIO ' select the p pins
    DIRH=$ff ' make p8-p15 outputs
    OUTH=x ' with pattern x
    AUXIO ' select x pins
    DIRH=$ff ' make x8-x15 outputs
    OUTH=x ' with pattern x
    END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • kingspudkingspud Posts: 128
    edited 2008-04-19 22:02
    Thanks Allen,
    ·
    You are a Parallax GOD!
    ·
    It worked like a charm!
    ·
    Also, thanks for leaving code and not just saying "yes it can do it!"· I was able to test what you gave me, which makes life so much easier!
    ·
    I am working on a horseshoe score board that uses the BS2p40; a 16Volt·4digit LED seven-segment display and has 6 buttons.· It will also have an arrow that points to the·player whose turn it is!
    ·
    With your piece of code I think I can get the whole thing working the way I want.·
    ·
    If I get stuck I will give you a buzz!!!!
    ·
    When it is finished I will post it in the finished project section so everyone can see the ENTIRE results.· I say entire because I have been trying to get information on using the Basic Stamp with a high voltage led display and found no projects finished with full schematics and photos.· I plan on showing everything so anyone else who needs help will have more than enough...· at least more than I was able to get.
    ·
    Thanks again,

    Joe


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “Intellectual growth should commence at birth and cease only at death”
    Albert Einstein
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-04-20 00:31
    kingspud,

    What is a "high voltage led display"?· Do you have a part number or a datasheet?

    Post Edit --

    The information you get is proportional to the information that you provide.

    I remember trying to give you some assistance in this matter and coming up a dead-end, here: http://forums.parallax.com/showthread.php?p=705997

    To what degree (detail) do you require "information"?· http://forums.parallax.com/showthread.php?p=721129

    (Cripes.)

    Post Edited (PJ Allen) : 4/20/2008 1:04:46 AM GMT
  • kingspudkingspud Posts: 128
    edited 2008-04-21 06:58
    Hi Tracy,

    This is the code I have so far..

    The following happens when I run it...

    The UP/DOWN buttons that control the MAINIO displays work great.· They count the numbers up and down when you hit the buttons BUT...

    right when you hit one of the buttons for the AUXIO side this is what happens...

    When you hit the UP button the count goes up 1 then stops.

    When you hit the DOWN button it does nothing and if you try to use the other buttons on the MAINIO side OR the UP button they now do nothing.

    Did I do something wrong in my code?

    Did I miss something?

    Thanks for your help in this.

    Joe





    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    index1·········· VAR···· Word
    index2·········· VAR···· Word

    index1 = 0
    index2 = 0



    DO

    · 'If you press button [noparse][[/noparse]0] the index count will increase from 1 to 9 and stop
    · ·IF IN0 = 1 THEN
    · MAINIO
    ·· DIRH=$ff
    ··· ·· index1 = index1 + 1
    ····· ·· IF index1 >= 25 THEN
    ····· ···· index1 = 25
    ······ ···· IN0 = 0
    ····· ·· ENDIF
    · LOOKUP index1,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    ·DEBUG BIN8 OUTH
    ······· PAUSE 500




    · 'If you press button [noparse][[/noparse]1] the index count will decrease from 9 to 1 and stop
    · ·ELSEIF IN1 = 1 THEN
    · · MAINIO·
    ·· DIRH=$ff
    ·· index1 = index1 - 1
    ·· ··IF index1 <= 0 THEN
    ···· ··· index1 = 1
    ····· ··· IN1 = 0
    ·· ··ENDIF
    ·· LOOKUP index1,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    · DEBUG BIN8 OUTH
    ······· PAUSE 500





    · 'If you press button [noparse][[/noparse]2] the index count will decrease from 9 to 1 and stop
    · ·ELSEIF IN2 = 1 THEN
    ·· AUXIO
    ·· DIRH=$ff
    ··· ·· index2 = index2 + 1
    ····· ·· IF index2 >= 25 THEN
    ····· ···· index2 = 25
    ······ ···· IN2 = 0
    ····· ·· ENDIF
    · LOOKUP index2,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    ·DEBUG BIN8 OUTH
    ······· PAUSE 500




    · 'If you press button [noparse][[/noparse]3] the index count will decrease from 9 to 1 and stop
    · ·ELSEIF IN3 = 1 THEN
    · AUXIO
    ·· DIRH=$ff
    · ·· index2 = index2 - 1
    ·· ··IF index2 <= 1 THEN
    ···· ··· index2 = 1
    ····· ··· IN3 = 0
    ·· ··ENDIF
    ·· LOOKUP index2,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    · DEBUG BIN8 OUTH
    ······· PAUSE 500
    ·ENDIF

    LOOP

    END

    ============================================================

    NOTE for PJ Allen,

    The display is a MAX tronics 4 digit 12Volt seven-segment display.

    http://www.bakatronics.com/shop/item.aspx?itemid=445

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “Intellectual growth should commence at birth and cease only at death”
    Albert Einstein
  • kingspudkingspud Posts: 128
    edited 2008-04-21 07:08
    **********· UPDATE ·************

    I found that if I comment out the two line that have the AUXIO command in them this is what happens...

    I hit the UP button on the MAINIO side and it starts to cound up...
    I hit the DOWN button ont the MAINIO side and counts down...

    BUT if I hit the UP button onthe AUXIO side the display for the MAINIO starts to count up as if it was the AUXIO side.

    So... what is happening is it works but only on the MAINIO side.· Both Player 1 and Player 2 buttons work but only on the MAINIO display side.

    What do you think this means? Why doesn't the AUXIO command work like it is suppose to work?


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “Intellectual growth should commence at birth and cease only at death”
    Albert Einstein
  • kingspudkingspud Posts: 128
    edited 2008-04-21 07:38
    UPDATE ******

    Figured it out!!!!

    I needed to attached a line to BOTH sides of the BS2p40 chip.

    Meaning... button UP had to be attached to IN0 on the MAINIO side AND and AUXIO side!

    This goes with all four button connections!

    What was happening was when the IF/THEN checker would switch from MAINIO to AUXIO it would not see the button being pressed anymore because it was now only looking at the AUXIO side!· I needed the IF/THEN checker to see the button being presses on both sides at all times!

    I'm really close now to getting the whole things to work!

    Thanks

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “Intellectual growth should commence at birth and cease only at death”
    Albert Einstein
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-04-21 07:41
    I'm not sure what is supposed to happen, but there are a couple of syntax errors in the program.

    ELSEIF should only be used as part of an overall IF statement. I think you might get what you want if you leave out *all* of the ENDIF statements except the one just before the LOOP:END. That goes with the very first IF, and all the ELSEIFs are part of the same construct. No ENDIFs until it is all done.

    Statements like in0=0 don't make sense. The pin input states are read only. What are you trying to accomplish with that instruction?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • kingspudkingspud Posts: 128
    edited 2008-04-21 08:30
    I got the IN0 =0 out of some old code. Your right, I took it out and it still worked fine. I guess I thought it would force the INPUT's high or low depending on the 0 or 1.

    Regarding the ENDIF's. I tried to take them out and the code bombs! They have to be in there because there are small IF/THEN checkers residing inside the intial IF/THEN statements.

    Joe

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “Intellectual growth should commence at birth and cease only at death”
    Albert Einstein
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-04-21 15:38
    You're perfectly right about the ENDIFs for the inside IF/THEN statements. I didn't see those. It sounds like you found the real bug though, congratulations! That was the difference between MAINIO and AUXIO for the ELSEIF in3=0 ...

    The MAINIO and AUXIO commands are very fast. So instead of the hard wired connections between pins 0,1,2 and 3 on both p and x, you could do

    MAINIO : IF inN=0 ... ' for N=0,1,2,3
    AUXIO ' for only N=2,3

    That leaves the buttons on mainio only.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • kingspudkingspud Posts: 128
    edited 2008-04-21 18:47
    I finally figured the entire code out!

    I know it isn't clean and maybe someone can write it in a cleaner more condenced form.

    I use Proteus 7 simulation software to run the code.

    This program is the coolest thing is the world!!!!!· It will allow you to place a BS2 microprocessor on a page and place components with it and write your code and then test it!

    Here is the website: http://www.labcenter.co.uk/index.cfm

    If you buy it tell them that Joe Propati sent you.

    Here is the code and·an attachment of the Proteus 7 simulation diagram

    Let me know if anyone has any questions or can please clean up my source code to make it neat!

    When I'm finished with the entire project I will post everything I have so it will make life easier for others, a lot easier than I had it!

    Thanks for everyones help!

    Joe P.



    ' BUTTON.BS240
    ' Connect an active-low circuit to pin P0 of the BS2. When you press the
    ' button, the DEBUG screen will display an asterisk (*). The program, as
    ' shown below, will print an asterisk at the first button press, then
    ' delay approximately one second (200 x 5 ms PAUSE) before auto-repeating
    ' at a rate of approximately 100 ms (5 x 20 ms).· Feel free to modify the
    ' program to see the effects of your changes on the way BUTTON responds.
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}

    index1·········· VAR···· Word
    index2·········· VAR···· Word
    arrow·· VAR···· Word
    index1 = 0
    index2 = 0
    arrow· = 1
    main:
    MAINIO
    HIGH 6
    HIGH 7
    AUXIO
    LOW 6
    HIGH 7
    MAINIO
    DO
    · 'If you press button [noparse][[/noparse]0] the index count will increase from 1 to 9 and stop

    ·IF IN0 = 1 THEN
    · MAINIO
    ·· DIRH=$ff
    ··· ·· index1 = index1 + 1
    ····· ·· IF index1 >= 25 THEN
    ····· ···· index1 = 25
    ······ ···
    ····· ·· ENDIF
    · LOOKUP index1,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    ·DEBUG BIN8 OUTH
    ······· PAUSE 500
    · 'If you press button [noparse][[/noparse]1] the index count will decrease from 9 to 1 and stop
    ···
    ·ELSEIF IN1 = 1· THEN
    · · MAINIO·
    ·· DIRH=$ff
    ·· index1 = index1 - 1
    ·· ··IF index1 <= 0 THEN
    ···· ··· index1 = 1
    ····· ···
    ·· ··ENDIF
    ·· LOOKUP index1,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    · DEBUG BIN8 OUTH
    ······· PAUSE 500

    · 'If you press button [noparse][[/noparse]2] the index count will decrease from 9 to 1 and stop
    ·ELSEIF IN2 = 1· THEN
    ·· AUXIO
    ·· DIRH=$ff
    ··· ·· index2 = index2 + 1
    ····· ·· IF index2 >= 25 THEN
    ····· ···· index2 = 25
    ······ ····
    ··
    ····· ·· ENDIF
    · LOOKUP index2,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    ·DEBUG BIN8 OUTH
    ······· PAUSE 500

    · 'If you press button [noparse][[/noparse]3] the index count will decrease from 9 to 1 and stop

    ·ELSEIF IN3 = 1· THEN
    · AUXIO
    ·· DIRH=$ff
    · ·· index2 = index2 - 1
    ·· ··IF index2 <= 1 THEN
    ···· ··· index2 = 1
    ·····
    ·· ··ENDIF
    ·· LOOKUP index2,· [noparse][[/noparse] %00000000, %00011110, %00101110,%00111110,%01001110,%01011110,%01101110,%01111110,%10001110,%10011110,%00000001,%00010001,%00100001,%00110001,%01000001,%01010001,%01010001,%01110001,%10000001,%10010001,%00000010,%00010010], OUTH
    · DEBUG BIN8 OUTH
    ······· PAUSE 500
    'If you press button [noparse][[/noparse]4] RESTART SCOREBOARD
    ···
    ·ELSEIF IN4 = 1· THEN
    · ··index1 = 0
    ··index2 = 0
    ······· MAINIO
    ··· LOW 7
    ··· LOW 6
    ··AUXIO
    ··· LOW 6
    ·········· LOW 7
    ······ pause 1000
    ··MAINIO
    ··· HIGH 6
    ··· HIGH 7
    ··MAINIO
    ··OUTH=%00000000
    ··AUXIO
    ··OUTH=%00000000
    ··AUXIO
    ····· LOW 6
    ····· HIGH 7
    ··arrow = 1
    'If you press button [noparse][[/noparse]5] CHANGE DIRECTION OF ARROW
    ···
    · ELSEIF IN5 = 1 THEN
    ·· arrow = arrow + 1
    ··IF arrow = 2 THEN
    ·· AUXIO
    ··· LOW 7
    ··· HIGH 6
    ·· arrow = 0
    ··pause 500
    ··ELSE
    ··· AUXIO
    ····· LOW 6
    ····· HIGH 7
    ··pause 500·
    ··ENDIF·
    ·ENDIF
    LOOP
    END


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “Intellectual growth should commence at birth and cease only at death”
    Albert Einstein
Sign In or Register to comment.