Shop OBEX P1 Docs P2 Docs Learn Events
BS2 OEM & DIRL command reverse circuit polarity, does anybody now why? — Parallax Forums

BS2 OEM & DIRL command reverse circuit polarity, does anybody now why?

SashaSasha Posts: 35
edited 2007-11-30 16:30 in BASIC Stamp
For BS2 OEM module power supply I use 9v battery (+ on Vin, - to Vss), hookup 7 LED diodes with 470 ohms resistor from pin0 to pin6, LED positive side (and resistors) attach to pins and negative side to Vss.
In Stamp Editor in main routine I put simply command like this:
DIRL = %1111111
PAUSE 500
DIRL = %0000000
PAUSE 500
DIRL = %1111111
Etc…
But nothing happens, this doesn’t work. With command like this:
PIN1 = 1PIN2 = 1PIN3 = 1PIN4 = 1….
Or
DIR1 = 1DIR2 = 1DIR3 = 1DIR4 = 1….·
shakehead.gif·ts works fine, but this is not a way to control 7 LEDs.

Then I switches LEDs positive to Vdd and negative sides to Stamp pins enter again simply command:
DIRL = %1111111
PAUSE 500
DIRL = %0000000
PAUSE 500
DIRL = %1111111
LEDs start blinking. What happens here?freaked.gif
I read from manual that Vdd is +5v input for Stamp supply. In this case pins are negative part of the circuit and where to put resistors if this situation is normal?
Please help me to resolve this!!

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-11-23 01:53
    Hi Sasha, DIRL sets I/O pins 0 to 7 as either inputs or outputs, 0 for input 1 for output. To make·the outputs high or low you should use the OUTL instruction. Modify your code to read as follows and read the description of the DIR,OUT and IN registers in the Memory and Variables section of the IDE Pbasic help file

    DIRL=%11111111

    OUTL = %00111111
    PAUSE 500
    OUTL = %00000000
    PAUSE 500
    OUTL = %00111111

    Jeff T.

    Post Edited (Unsoundcode) : 11/23/2007 1:58:09 AM GMT
  • SashaSasha Posts: 35
    edited 2007-11-23 01:59
    Thanks Jeff I'll try this immediately
  • SashaSasha Posts: 35
    edited 2007-11-23 02:36
    Everything works perfect, Thanks !!!
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-11-23 02:43
    Sasha, replacing PINS with OUTL should yield the same results. Whether the program needs slowing down for the persistance of vision I do not know.

    OUTL controls the state of·all 8 outputs with one instruction, the previous state of the outputs has no bearing on what their new states will be, that is determined by the next OUT instruction.

    hope this helps

    Jeff T.



    EDIT for future reference if it makes it easier you could use decimal notation,· eg: OUTL·6 is the same as typing·OUTL %00000110

    Post Edited (Unsoundcode) : 11/23/2007 2:49:00 AM GMT
  • KatyBriKatyBri Posts: 171
    edited 2007-11-23 03:04
    Does the OUTL command implicitly set the pins to output, thereby eliminating the need to configure them initially with DIRL?
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-11-23 04:06
    Hi KatyBri, when using the OUT register you have to use the DIR instruction to latch the register to the output pins. It is not neccessary to declare the DIR before using the OUT·register, in other words a value can be assigned to the OUT register and then latched to the output using DIR later in the program.

    Jeff T.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-11-30 16:30
    Be mindful of the amount of current you are drawing from that port. 8 LEDs could easily over-current that port and damage your BASIC Stamp Module and/or I/O pins.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.