Shop OBEX P1 Docs P2 Docs Learn Events
Problem with LEDs on PDB — Parallax Forums

Problem with LEDs on PDB

StampNut2StampNut2 Posts: 224
edited 2006-04-22 05:12 in BASIC Stamp
Hello all.

·I am new to this forum and wish to learn programming. I have aquired a PDB with a BSP2-40 Stamp Ihave connected everything up sucessfully to my pc and the PDB is running as it should.
My question is:
I have connected up leds on the PDB to 0-15 on the stamp and run this program. But only 0-7 light up what have I miissed in the program? I know this will be very basic to you guys but I have to start somewhere. Many thanks.

·· ' {$STAMP BS2p}
' {$PBASIC 2.5}
thePin········· VAR···· Nib············ ' pin 0 - 15

Setup:
· DIRA = %111111111111111························· ' make LEDs output, low
Main:
· DO
··· FOR thePIN = 0 TO 15················ ' loop through pins
···· TOGGLE thePin···················· ' toggle current pin
····· DEBUG HOME, BIN15 OUTA············ ' show on Debug
····· PAUSE· 50························ ' short delay
··· NEXT
· LOOP································· ' repeat forever
· END


Post Edited By Moderator (Dave Andreae (Parallax)) : 4/21/2006 10:57:58 PM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-21 22:51
    You're letting Spin (Propeller) code pop into your PBASIC program.· Replace "DIRA" with "DIRS" and "OUTA" with "OUTS" and your program will work.

    PS: Welcome to our forums, and don't forget to add an appropriate subject line to your new treads -- that will get you more responses.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 4/21/2006 10:54:28 PM GMT
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-21 23:13
    Thanks Jon, I will check it out shortly. Thanks for the welcome too. Yeah I forgot at the last minute to put a topic in the subject line [noparse][[/noparse]old age creeping in!] In your opinion Jon what is the best book for learning your code and for robotics applications.
    Many thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nerver give up when things go wrong.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-21 23:48
    We have a whole series of books -- start with "What's A Microcontroller?" and go from there. I wrote a book called StampWorks that uses the PDB; you should probably have WAM under your belt before you approach StampWorks -- I don't do a lot of hand-holding, I just show you how to get things done and to code well (in my opinion).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-22 00:24
    I have just realtered the code, The debug terminal tells me everything is ok 1's and 0's all 16 but only 7 leds are lighting on the PDB, is there any jumper pins or code to activate 8-15 on the PDB?

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

    thePin VAR Nib ' pin 0 - 15


    Setup:
    DIRS = %111111111111111 ' make LEDs output, low

    Main:
    DO
    FOR thePIN = 0 TO 15 ' loop through pins

    TOGGLE thePin ' toggle current pin

    DEBUG HOME, BIN15 OUTS ' show on Debug
    PAUSE 50 ' short delay
    NEXT
    LOOP ' repeat forever
    END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never give up when things go wrong.
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-22 00:34
    I have just realtered the code, The debug terminal tells me everything is ok 1's and 0's all 16 but only 7 leds are lighting on the PDB, is there any jumper pins or code to activate 8-15 on the PDB?

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

    thePin VAR Nib ' pin 0 - 15


    Setup:
    DIRS = %111111111111111 ' make LEDs output, low

    Main:
    DO
    FOR thePIN = 0 TO 15 ' loop through pins

    TOGGLE thePin ' toggle current pin

    DEBUG HOME, BIN15 OUTS ' show on Debug
    PAUSE 50 ' short delay
    NEXT
    LOOP ' repeat forever
    END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never give up when things go wrong.
  • SSteveSSteve Posts: 808
    edited 2006-04-22 01:01
    I just tried your code (with a BS2, not a BS2p) on my PDB and all 16 LEDs light. Try swapping the wires between LEDs 0-7 and 8-15 to see what happens.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-22 02:03
    SSteve: Thanks, I will try it shortly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never give up when things go wrong.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-22 02:07
    Test the LEDs first. Disconnect the P8-P15 LEDs from the Stamp and connect them, one at a time, to Vdd; if they light then you might have a duff Stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-22 02:15
    I will try this shortly and see if they light. If it is a duff stamp would Parallax replace it as this is the first time that it has been used.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never give up when things go wrong.
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-22 02:23
    Jon, I have tested the leds and they work fine, so do you think it is the stamp?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never give up when things go wrong.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-22 02:27
    Hello,

    ·· Remember, with a BS2P40 the P8 through P15 are not on the main I/O header where P0-P15 normally are.· This is in the manual.· Instead they share with the SX I/O pins, so P8 through P15 on that header are actually AUXIO pins.· Please see the PDB Manual· for more information.· I would bet that is where your problem lies.· Your upper 8 LEDs should be connected to the I/O headers on the left side of the board over by the SX chip.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 4/22/2006 2:31:33 AM GMT
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-22 02:30
    Interesting!!!! when swapped around as SSteve suggested leds 8-15 work ok, However 0-6 do not. When I test each led 8-15 and uas a jumper directly on the stamp pin it works ok, I almost appears to be a break from the stamp to the wire holder block, any more suggestions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never give up when things go wrong.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-22 02:32
    Yes, see my post above...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • StampNut2StampNut2 Posts: 224
    edited 2006-04-22 02:40
    Hi Chris, Yes you were right, until I get used to this board I guess I will have a couple of problems now and then. but yes connecting the other wires 8-15 to the sx header works great.

    MANY THANKS TO THOSE THAT REPLIED TO MY POST. [noparse][[/noparse]GREAT FORUM]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never give up when things go wrong.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-22 02:50
    Glad I could help.· And remember, DIRA and OUTA above only affect the first 4 bits of the 16 I/O pins.· DIRA is the direction register for P0-P3 and OUTA is the output latch for P0-P3.· This follows suit for DIRB/OUTB, DIRC/OUTC and DIRD/OUTD.· Then there's DIRL/OUTL and DIRH/OUTH which affect 8 bits at a time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-22 05:12
    Thanks for the catch, Chris -- I missed that it was a BS2p40.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.