Shop OBEX P1 Docs P2 Docs Learn Events
BS2pe Question — Parallax Forums

BS2pe Question

jamesksujamesksu Posts: 22
edited 2011-08-02 14:23 in BASIC Stamp
Sorry for the complete noob question, and someone may be able to point me to another thread that answers this:

I have a bs2pe that I want to connect (2) daughterboards to. I have a TCS230 color sensor and a PWR-I/O board with a PIR sensor and servo motor attached with 3 pin. Basically I just need help getting started on how I address different devices on the bs2pe using a single program. Everytime I try to run the motor or PIR sensor, any code automatically goes to the color sensor in the "B" socket. Is there a sample code I could grab that shows how to address different devices in socket "a" and "b" in the same program? Is this even possible? Thanks.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-02 08:52
    With two exceptions that won't affect you, the BS2pe ports that access socket "A" are different from those that access socket "B". The illustration at the top of page 5 in the MoBo manual shows which BS2pe ports access which pins in both sockets. So, yes, you can detect colors with a TCS230/3200 plugged into "B", while controlling a servo in "A", for example. You just have to make sure to use the port corresponding to the pin in "A" to which the servo is connected.

    Here's a thread that shows a TSL1401-DB and PWR-I/O-DB working together to acquire color images. The BS2pe code is attached below. ('Probably not the best example, since it lacks comments, but you'll get the gist from the pin assignments.)

    If you attach your code, it will be easier to provide further assistance if you need it.

    -Phil
  • jamesksujamesksu Posts: 22
    edited 2011-08-02 11:12
    Phil- thanks for the quick response. My only confusion now is the OWOUT command, which appears to be the way to address each device connected to the daughterboard. In the sample code you sent, it says:

    OWOUT io, 1, [$EC, 128, 8, $00, $EE, exp, $A4]

    What do each of the numbers and characters represent in the "outputdata" argument, and what does the comma signify? Again, if there is a place to direct me that will work too.

    Thanks.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-02 13:28
    The OWOUT command is used only when it's necessary to invoke the AVR coprocessor associated with a particular socket to handle a more complex interaction, such as analog to digital conversion. If all you're doing is controlling a servo, you can bypass the AVR functionality and control the daughterboard pins directly from your PBASIC program.

    OTOH, if you wish to use the coprocessor functionality, you can refer to the documents for each different AVR program. The OWOUT parameters you refer to are detailed in the TSL1401-DB's AVR documentation. For the AVR functions that come pre-programmed with the MoBo, refer to the GPIO3 documentation on the MoBo's product page.

    -Phil
  • jamesksujamesksu Posts: 22
    edited 2011-08-02 14:10
    That makes sense. So what I/O pin should be referenced here if the servo is plugged in through the PWR-I/O in socket A: (I've tried P8, A5, 5, etc)

    ' =========================================================================
    '
    ' File...... Basic_servo_standard.bs2
    ' Purpose... Standard rotation servo test code
    ' Author.... Parallax, Inc.
    ' E-mail.... support@parallax.com
    ' Started... 1/3/00
    ' Updated... 4/29/04
    '
    ' {$STAMP BS2PE}
    ' {$PBASIC 2.5}
    '
    ' =========================================================================

    '
    [ Program Description ]
    ' This code will rotate a standard rotation servo in one direction
    ' and then the other direction.
    ' Note: The code will work also with the Bs2e and Bs2pe when the directive
    ' is changed.
    '
    [ Revision History ]
    ' 4/29/04 updated to reflect new format changes
    '
    [ I/O Definitions ]
    Servo_pin CON ?? 'I/O pin that is connected to servo
    '
    [ Variables ]
    Temp VAR Word 'Work space for FOR NEXT

    '
    [ Program Code ]
    start:
    For temp = 200 To 1200
    PULSOUT Servo_pin, temp
    PAUSE 50
    Next
    For temp = 1200 To 200
    PULSOUT Servo_pin, temp
    PAUSE 50
    Next
    GoTo start
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-02 14:23
    P8, P9, P11, and P12 are all legitimate candidates when using socket "A" for the PWR-I/O-DB. Again, please refer to the diagram at the top of page 5 of the MoBo documentation.

    Oh, and when you post code on the forum...

    attachment.php?attachmentid=78421&d=1297987572

    -Phil
Sign In or Register to comment.