Shop OBEX P1 Docs P2 Docs Learn Events
grouping i/o pins — Parallax Forums

grouping i/o pins

mikeamikea Posts: 283
edited 2012-07-28 11:21 in BASIC Stamp
I'm using " pulsout 4, 1250" i've found "outa, outb, outc, outd" to group 4 pins together. is there a way to group 2 pins or do i have to use binary? if binary is the least typing would this work...pulsout 0000000000000011,1250 to turn high i/o 0 and 1.thanks-mike

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-07-28 10:40
    That would result a PULSOUT on P3.
    PULSOUT is for one pin at a time only.
  • mikeamikea Posts: 283
    edited 2012-07-28 10:50
    Thanks PJ, how does that end up p3? -mike.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-07-28 10:55
    Actually, % would be required for it to be recognised as a binary number.
    PULSOUT 3 and PULSOUT %11 and PULSOUT%0011 express the same argument.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-07-28 11:01
    You can set multiple pins high/low in parallel fashion, just not with PULSOUT

    Here, P0 and P3 blink together --
    DIRA = %1001
    
    Recycle:
     OUTA = %1001
     PAUSE 500
     OUTA = %0000
     PAUSE 1000
     GOTO Recycle
    
  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-28 11:07
    The only grouping of I/O pins is as groups of 4 (OUTA, OUTB, OUTC, OUTD), groups of 8 (OUTH, OUTL), and all pins (OUTS). You can use any of these groupings to change multiple I/O pins, but the built-in statements all use only single pin numbers.

    You could use "OUTA = OUTA | %1100" to set both I/O pins 2 and 3 to high and "OUTA = OUTA & %0011" to set both I/O pins 2 and 3 to low. "OUTA = OUTA ^ %1100" will toggle the current state of both I/O pins.
  • mikeamikea Posts: 283
    edited 2012-07-28 11:08
    Are there two ways to express binary? i was thinking that 8 bit for example there would be 8 digits either 1 or 0 for low or high and they read right to left. seems like i've set pins on the propeller that way before.-mike
  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-28 11:12
    %10110011, $B3, and 179 are all the same number and are used identically in any Stamp program. Similarly, %01000001, $41, 65, and "A" are all the same number and can be used interchangably in a Stamp program.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-07-28 11:16
    With the Stamp, the rightmost bit is the LSB.

    With Spin you can arrange OUTA as
    outa [3..0]
    or
    outa [0..3]
    and that makes a difference.
  • mikeamikea Posts: 283
    edited 2012-07-28 11:19
    Thank you Mike, and PJ. Gonna read up on binary etc. we were playing with 2 c.r. servos and figuring out options on how to drive them.-mike
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-07-28 11:21
    The best way to do servos with a Stamp is with ServoPALs.
Sign In or Register to comment.