Shop OBEX P1 Docs P2 Docs Learn Events
BS2 on BOE does not run after power off — Parallax Forums

BS2 on BOE does not run after power off

dartecdartec Posts: 6
edited 2010-10-27 10:40 in BASIC Stamp
I use a BS2 on a BOE board. I also have an eb600 bluetooth and a RFID both Parallax boards. When I power the board OFF and power back ON, I have to do either of two things to get the original program to run properly:
a) to push the reset button on the board
b) to reload the BS2 program.

My application requires that the program run flawlessly after power OFF and power back ON (no reload of the program).
Can anybody help?
Angel

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-10-21 20:11
    You can start by showing us your code and your connections to all the parts.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-21 20:15
    Are any of the devices the BASIC Stamp is connected to powered independently from the BOE? If so, the Stamp may be scavenging power from them through its I/O pins and not really getting power cycled when the BOE is switched off and back on.

    -Phil
  • dartecdartec Posts: 6
    edited 2010-10-27 08:54
    Both the RFID Parallax board and the eb600 Parallax Bluetooth board are connected to the BS2 within the BOE and powered from the same BOE power supply.
  • dartecdartec Posts: 6
    edited 2010-10-27 09:03
    Here is the code:
    '****************RKA4 V3 SHORT. Rev2
    '*****Author:Angel Diez, March 2008
    '**********************************
    '{$STAMP BS2}
    '{$PBASIC 2.5}
    '{$PORT COM1}

    ' constant declarations
    nbrCount CON 1

    ' variable declarations
    packet VAR Byte(15)
    targetNbr VAR Byte
    i VAR Byte
    j VAR Byte


    Enable PIN 9 ' low = reader on
    RFINPUT PIN 10 ' serial from reader
    Latch PIN 12 ' lock/latch control
    'Spkr PIN 11 ' speaker output
    'TmAdj CON $100 ' x 1.0 (time adjust)
    'FrAdj CON $100 ' x 1.0 (freq adjust)
    '
    [ Constants ]

    idx VAR Byte ' tag byte index
    '
    [ EEPROM Data ]
    ' data
    DATA $00, $0C, $84, $00, $75, $D4 ' node A (TSA1)

    '
    [ Initialization ]
    Reset:
    LOW Latch ' lock the door!
    'RFID Reader Module
    '
    [ Program Code ]
    Main:
    LOW Enable ' activate the reader
    SERIN RFINPUT, 396, [WAIT($0A), STR packet\10] ' wait for hdr + ID
    HIGH Enable ' deactivate reader

    'HIGH Latch ' remove latch
    'FREQOUT Spkr, 2000 */ TmAdj, 880 */ FrAdj ' beep
    'LOW Latch ' restore latch
    'GOSUB Bmain
    'END
    '
    [ Subroutines ]
    ' initialise the eb500
    GOSUB eb500Init

    ' generate a packet
    GOSUB generatePacket
    GOTO Main
    END

    ' eb500 initialisation subroutine
    eb500Init:
    ' wait for the eb500 radio to be ready
    ' switch to command mode
    LOW 6
    PAUSE 200
    ' disconnect (if necessary)
    'SEROUT 1, 84, ["dis", CR]
    'SERIN 0, 84, [WAIT(CR, ">")]
    'DEBUG "done.", CR
    RETURN

    ' connection polling subroutine
    connectionWait:
    IF (IN5 = 1) THEN connectionWait
    RETURN

    ' disconnection polling subroutine
    disconnectionWait:
    IF (IN5 = 0) THEN disconnectionWait
    RETURN

    ' disconnection from data mode subroutine
    'disconnectFromDataMode:
    ' switch to command mode
    'LOW 6
    'SERIN 0, 84, [WAIT(CR, ">")]

    ' disconnect
    'SEROUT 1, 84, ["dis", CR]
    'SERIN 0, 84, [WAIT(CR, ">")]
    'RETURN

    ' packet routing subroutine
    routePacket:
    ' compute target neighbour
    targetNbr = packet(0) // nbrCount

    ' modify the packet
    packet(0) = packet(0) / nbrCount
    packet(1) = packet(1) - 1

    ' connect to targetNbr
    GOSUB targetNbrConnect
    PAUSE 200
    ' route the packet
    SEROUT 1, 84, [STR packet\15]
    'DEBUG "ROUTE=", HEX2 packet(0)
    ' wait for disconnection
    GOSUB disconnectionWait
    RETURN

    ' target neighbour connection subroutine
    targetNbrConnect:
    ' send the connection command
    SEROUT 1, 84, ["con "]
    'DEBUG "target", HEX2 targetNbr
    ' send the hardware address
    FOR i = 0 TO 5
    READ (targetNbr * 6 + i), j
    SEROUT 1, 84, [HEX2 j]
    'DEBUG HEX2 j,":"
    IF (i <> 5) THEN SEROUT 1, 84, [":"]
    NEXT

    ' connect
    SEROUT 1, 84, [CR]
    'SERIN 0, 84, [WAIT(CR, ">")]
    GOSUB connectionWait

    ' wait for the neighbour to be ready
    'PAUSE 400
    RETURN


    ' packet generator subroutine (DEBUG PURPOSES ONLY)
    generatePacket:
    ' copy the packet data
    FOR idx = 12 TO 3
    packet(idx)=packet(idx-3)
    'DEBUG "P", HEX2 packet(idx)
    NEXT
    packet(0) = 0 '**** RTE = 0 (server)
    packet(1) = 0 '**** TTL = 0
    packet(2) = 255 '*** sync
    packet(13) = CR
    packet(14) = LF

    GOSUB routePacket
    RETURN


    The connections are as per eb600 and RFID board specs (both serial input and output)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-27 10:40
    Try putting a one-second PAUSE as your program's first executable statement. Some peripherals come out of a power-up reset more slowly than the BS2 does, and it may be getting ahead itself trying to access them right away. At least this would explain why a program reload or manual reset works, since the peripherals are already under power and have been for some duration.

    -Phil
Sign In or Register to comment.