Shop OBEX P1 Docs P2 Docs Learn Events
Bs1usb — Parallax Forums

Bs1usb

LadderWalkerLadderWalker Posts: 4
edited 2008-05-15 22:19 in BASIC Stamp
Does anybody know if it is possible to have a program communicate with the BS1USB? For instance when u hit a certain key it turns on an LED or something like that.

james

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-04 04:34
    There are no provisions for PC to BS1USB communications over the USB port. It's strictly one-way to the PC using the DEBUG statement.
  • LadderWalkerLadderWalker Posts: 4
    edited 2007-03-04 13:44
    Ok so how about if i went from serial to one of the I/O pins
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-04 15:03
    That would work as long as you use the circuit in the PBasic manual (see SERIN and SEROUT statements). The Stamps accept TTL logic levels (0V/5V) while a serial line has RS232 voltage levels (maybe +12V/-12V). Generally, the Stamps can transmit to a serial line and need a protective resistor (22K) when receiving from a serial line to one of the I/O pins.
  • LadderWalkerLadderWalker Posts: 4
    edited 2007-03-04 16:33
    with SERIN i can make it wait for a certain string, does that mean that u can send characters tthrough serial?(and the basic stamp will recieve it or will it only accept on or off)
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-04 16:39
    SERIN will cause the Stamp to receive one or more serial characters. SEROUT will cause the Stamp to transmit serial characters. There are lots of other things you can do with an I/O pin. For example, you can "read" the value of a resistor using the POT statement for the BS1. You can debounce a pushbutton with the BUTTON statement.
  • LadderWalkerLadderWalker Posts: 4
    edited 2007-03-05 04:22
    sweet thanx for the info

    james
  • Fabian OliverFabian Oliver Posts: 5
    edited 2007-03-09 00:05
    just a quick question, if i powered the BS1USB with a 5v supply to the usb connector externally from the computer, will the microcontroller work on it's own? say if i wanted to load a program to it to have it operate externally from the pc?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-03-09 15:11
    Fabian,

    If you’re asking if the BS1-USB will operate without the PC that programmed it, the answer is yes. Once you download the program to the BS1-USB it remains on it and runs whenever the unit is powered from 5V. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Fabian OliverFabian Oliver Posts: 5
    edited 2007-03-12 01:49
    i was wondering if there was a way to set the pins as low or high with a command like WRITE PINS, %10101010.

    in the syntax guide it says the pins are bit addressable.

    so instead of having to do

    high 0
    high 1
    high 2
    low 3
    low 4
    low 5
    high 6
    high 7

    i could just use WRITE PINS, %11000111

    not sure if this can be done, just wondering. thanks.

    this is the code i tried.

    ' {$STAMP BS1}
    ' {$PBASIC 1.0}

    MAIN:
    SYMBOL e = PINS
    SYMBOL d = DIRS
    WRITE d, %11111111

    WRITE e, %10101011

    END

    but didn't work.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-12 02:11
    If you look in the PBasic manual under "Basic Stamp Architecture - Memory Organization", you'll see a table showing the memory layout for the BS1 (Table 4.1). The names for the various words and bytes there are essentially pre-defined variables. You can use them directly in any statement as variables. In the example you posted, you'd put "DIRS = %11111111" and "PINS = %10101011".
  • Fabian OliverFabian Oliver Posts: 5
    edited 2007-03-12 13:09
    thanks.
  • Fabian OliverFabian Oliver Posts: 5
    edited 2008-05-15 21:01
    is there a way with the bs1usb to program interrupts? say when a pin receives data it executes a subroutine?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-15 22:19
    There are no interrupts on the Stamps although there's a special polling mechanism on the BS2p/pe/px Stamps. Your program needs to have some kind of loop where a pin is checked every cycle through the loop and your program calls the subroutine when the check is positive.

    On the BS1, there's no way to interrupt statements like SERIN or COUNT that execute for a prolonged period of time (other than by resetting the chip).
Sign In or Register to comment.