Shop OBEX P1 Docs P2 Docs Learn Events
help bluetooth terminal control boebot — Parallax Forums

help bluetooth terminal control boebot

walkin79walkin79 Posts: 29
edited 2012-08-07 06:44 in BASIC Stamp
this program is pretty much out of the book, everything works except when i wat to turn right the instruction to the servos fail, what ever pulse out command is first is sent to both servos, they work fine if you delet one or the other but will not work together bran new servos








' TerminalBoeBotControl_Keypad.bs2
' Moves the Boe-Bot based on the numbers 2, 4, 6, 8 or the
' letters A, W, D, X.
'control + d opens the debug window ( you must connect bluetooth and get the
' correct com port example com 5 look in stamps in class mini projects boe bot
' bluetooth
' {$STAMP BS2}
' {$PBASIC 2.5}
Piezo PIN 4
RX PIN 2 ' RX of the Easy Bluetooth
TX PIN 0 ' TX of the Easy Bluetooth
ltServo PIN 13 ' Left Servo Pin
rtServo PIN 12 ' Right Servo Pin
FwdLtFast CON 850 ' Left servo forward full speed
BwdLtFast CON 50 ' Left servo backward full speed
FwdRtFast CON 50 ' Right servo forward full speed
BwdRtFast CON 850 ' Right servo backward full speed

Baud CON 84 ' Baud set at 9600
myByte VAR Byte ' Byte to establish connection
index VAR Word ' READ index/character storage
character VAR Word
note1 VAR Word ' for peizo noise
x VAR Word ' for peizo noise
dirChar VAR Word ' Stores directional character
counter VAR Word ' Counter for FOR...NEXT loop




DO
' Recieve character from the PC
SERIN RX, Baud, [dirChar]
IF (dirChar = "8") OR (dirChar = "w") THEN
GOSUB Forward
ELSEIF (dirChar = "2") OR (dirChar = "x") THEN
GOSUB Backward
ELSEIF (dirChar = "4") OR (dirChar = "a") THEN
GOSUB Left
ELSEIF (dirChar = "6") OR (dirChar = "d") THEN
GOSUB Right
ELSEIF (dirChar = "5") OR (dirChar = "p") THEN
GOSUB noise
ENDIF
LOOP
Forward:
SEROUT TX, BAUD, [CRSRXY, 7, 0, "*", CRSRXY, 6, 1, "*", CRSRXY, 8, 1, "*"]
PULSOUT ltServo, FwdLtFast
PULSOUT rtServo, FwdRtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 7, 0, " ", CRSRXY, 6, 1, " ", CRSRXY, 8, 1, " "]
RETURN
Backward:
SEROUT TX, BAUD, [CRSRXY, 7, 6, "*", CRSRXY, 6, 5, "*", CRSRXY, 8, 5, "*"]
PULSOUT ltServo, BwdLtFast
PULSOUT rtServo, BwdRtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 7, 6, " ", CRSRXY, 6, 5, " ", CRSRXY, 8, 5, " "]
RETURN
Left:
SEROUT TX, BAUD, [CRSRXY, 3, 3, "*", CRSRXY, 4, 2, "*", CRSRXY, 4, 4, "*"]
PULSOUT ltServo, BwdLtFast
PULSOUT rtServo, FwdRtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 3, 3, " ", CRSRXY, 4, 2, " ", CRSRXY, 4, 4, " "]
RETURN
Right:
SEROUT TX, BAUD, [CRSRXY, 11, 3, "*", CRSRXY, 10, 2, "*", CRSRXY, 10, 4, "*"]
PULSOUT rtServo, BwdRtFast
PULSOUT ltServo, FwdLtFast
PAUSE 20
SEROUT TX, BAUD, [CRSRXY, 11, 3, "*", CRSRXY, 10, 2, "*", CRSRXY, 10, 4, "*"]
RETURN

noise:
FOR x = 1 TO 50 ' run about 5 seconds
RANDOM note1 ' create random note
note1 = note1 // 2000 ' don't let note go to high
FREQOUT 4,50,note1 ' play it
PAUSE 100 ' short pause between notes
NEXT
RETURN

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-08-06 05:56
    What is your battery situation?
    If it's OK running one servo or the other, but not with both, then the battery is marginal (weak.)

    Are those SEROUTs from out of the book?
    SEROUTs take a lot of time and blow your servo routine refresh time (20ms limit.)
  • walkin79walkin79 Posts: 29
    edited 2012-08-06 12:21
    everything is out of the book, im running a 9v battery, all the other commands work, forward reverse anf left, its just the right turn command, both servos have a forward pulse
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-08-06 12:30
    What if you swap the servos at the connectors?

    I put mine up on something like a stand (a cottage cheese container), so it doesn't move about, when I try figuring something out.
  • walkin79walkin79 Posts: 29
    edited 2012-08-06 12:34
    no change, it is definately a program or power problem, although i dont think its power because all the other commands work. is there anyother instruction to drive a servo other than pulsout?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-08-06 12:42
    I wouldn't expect a servo to run well (at all) with a 9V battery, let alone two, even though, technically they don't go simultaneously.

    Write a little test program and just run/test one servo and test both, separately, that way.

    I have experience with this stuff [ http://incredulist.blogspot.com/p/cypherbot_23.html ]

    I'm not keen on the "9V battery" or the SEROUTs, but if they're "in the book"...
  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-08-06 14:38
    walkin79 wrote: »
    this program is pretty much out of the book,

    I have 2 questions. First, Which "Book" is this out of and second, which PC program are you using to connect to the BoeBot? I have been trying to get this same thing to work with an EBT with no luck.

    Edit: I found it. Testing the problem to se if I can recreate.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-08-06 15:18
    Walkin79,Are you pressing number 5/p or 6/d?.
  • walkin79walkin79 Posts: 29
    edited 2012-08-06 15:49
    im pressing 6/d, i got the code from whats a micro controller, all you have to do is load the program to the stamp and go into your bluetooth settings search for and connect the east bluetooth serial connection, then you go back to the basic stamp editor and press ctrl+d to open a debug screen and wait for the connection. then you press your buttons forward rev left right except right isnt working on my program for some reason, no luck switching power supplies, 4 aa and a 6 volt ac plug, no difference
  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-08-06 15:54
    I have it working with no problems. 6V may not be enough. I am using an 8.0V wall wart and all works fine. I will charge up my bateries to see if I can recreate the problem or not. I just copied the code you posted so it is not a code issue. At first I thought it was but i was misreading the comments.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-08-06 18:20
    So -
    it's not sending "6" or "d"
    or
    it's not branching to Right with a "6" or "d"
    ???

    In three of the direction examples, Backward, Forward, and Left, the order is:
    PULSOUT ltServo, constant
    PULSOUT rtServo, constant

    but with Right, you have:
    PULSOUT rtServo, BwdRtFast
    PULSOUT ltServo, FwdLtFast

    Is that how it is shown in the W-a-M book? The order shouldn't make a difference, and I guess they're getting plugged with the right values. The inconsistency strikes me as odd, perhaps telling - and Right is where the problem lies. Is what you have pasted here exactly what you have cut&pasted into the IDE and Saved to the BS2?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-08-06 18:44
    The code is correct. I copy and pasted the code from Walkin79's original post and it worked fine for me.

    Walkin79, Did you swap the Servos from 12 to 13 and vice versa to see what happens?

    I am thinking you may have a bad pin on your Servo inputs. I just plugged in 4 Ea. rechargeable batteries, each of which had 1.46 volts and this still worked fine for me.

    I would wire the right servo to the breadboard and change the pin to see if that works.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-08-06 18:54
    See Replies #4 and #5
  • NWCCTVNWCCTV Posts: 3,629
    edited 2012-08-06 18:58
    OOPS!!! Overlooked. This is definately an odd one. Do you have a volt meter to test your wall wart and make sure it is putting out at least 6 volts?

    The only thing I see in the code is that the laset SEROUT line contains "*" whereas the preceding 3 last lines do not. However, it works this way for me whether the * is there or not.
  • walkin79walkin79 Posts: 29
    edited 2012-08-07 02:48
    solved it, it was a bad cell in my battery pack. weird.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-08-07 06:44
    Replies #2 and #6
    but anyway
    walkin79 wrote:
    ...im running a 9v battery,... it was a bad cell in my battery pack.
    There's a lot of difference between a "9V battery" and a 9V "battery pack".
Sign In or Register to comment.