Shop OBEX P1 Docs P2 Docs Learn Events
Serin command with Eb500 need help.? — Parallax Forums

Serin command with Eb500 need help.?

TomvnTomvn Posts: 103
edited 2008-09-29 15:42 in BASIC Stamp
·Hi , I have problem with this code write for boebot· , i use· laptop to control boebot to movment via Eb500 bt , the problem is· like i have push two time on F key so that wil make boebot move , so anyway can i just push one time on F key to make boebot move forward , i like to make simlple movement forward = F , backward = B, Right = R, and Left = L,
here my code . any help thanks.
Tom.vn

Comments

  • MSDTechMSDTech Posts: 342
    edited 2008-09-24 21:44
    What are you using on the PC side to send the data to the Bluetooth serial port? When you are looking at a communications problem, the code on both ends needs to be reviewed.
  • TomvnTomvn Posts: 103
    edited 2008-09-24 21:49
    i use bluetooth on my laptop and use debug window in pbasic to make output
  • MSDTechMSDTech Posts: 342
    edited 2008-09-24 22:08
    The problem you are having is that the serin command is expecting 4 values to be transmitted, also, it is probably not synchornizing with the sending unit. I've had much better luck only having one value sent and then testing that one value to determine which way to move. Also, you might want to look at using a prefix character to indicate you are sending.
    Read up about the WAIT parameter on serin.
    You could use any character for the prefix. For example if you use z as the prefix you would have a comand like:
    Motion Var Byte
    SERIN BT_RX,BTBaud,[noparse][[/noparse]WAIT ("z"), Motion]
    If Motion = "f" then forward_fast
    If Motion = "b" THEN backward
    If Motion = "l" THEN left
    If Motion = "r" THEN right

    To move the robot, you would type zf and it will go forward, etc.
    I'm using a vb program to control a robot with this scheme. The major diffence is the program sets the prefix in the backgroud before sending the command to the robot.
  • TomvnTomvn Posts: 103
    edited 2008-09-24 23:32
    Thanks , i will try on that , anyway can i just push f key one time to make boebot move with out push z key, i really to make my voice to control boebot with this code ,i use debug window and select comport to synchornizing with eb500 and use Ms speech recognition , i want tho just say forward to make boebot move that is , then stop make it stop.
  • MSDTechMSDTech Posts: 342
    edited 2008-09-25 02:23
    The way your program is laid out, you will need to resend the command to keep the boebot moving forward. Each time it processes the SERIN command, a new value for the action will be read. So you send one f and it will go forward for about a second then stop. You will need to send the f again to have it continue moving forward.
    One way around this would be to remember the last valid value sent and if there are no valid values, repeat that action. You also need to remember that SERIN is NOT BUFFERED. So you have to be sending the stop command at the instant the unit is running the SERIN command.
    I cheated and added the Servo Controller Board. It has a set it and forget it operation. The BS2 sends it the commands to move forward and it handles sending the pulses to the servos. It will continue sending pulses with the right timing until you tell it to stop. Thus, my BS2 can spend its time waiting for the next command to come in on the SERIN while the servo controller keeps the wheels turning.
  • TomvnTomvn Posts: 103
    edited 2008-09-25 03:08
    ok, so , could i send couple character at one time like this

    SERIN BT_RX,BTBaud,[noparse][[/noparse]WAIT ("!"), Motion]
    If Motion = "forward" then forward_fast
    or i should sent string value to it, i know serin it not buffered.
  • TomvnTomvn Posts: 103
    edited 2008-09-25 15:25
    i try last night with Wait command , so if i use serin to reciever more than one value the first value is be reciever right away when i hit the key and the second value will reciever if i have hit the couple time .so anyway can i sovle that?
  • MSDTechMSDTech Posts: 342
    edited 2008-09-25 15:36
    I'm not sure if you have enough control with the debug terminal to be able to modify the bahavior. Have you tried using hyperterminal to send commands to the robot? Normally, you would be writing some type of application on the PC to send commands to the robot (search these forums for apps using VB Express, which is a free download).
  • TomvnTomvn Posts: 103
    edited 2008-09-25 19:45
    i did try on haperterminal , but it work the same i mean same problem, i read other post same prolem with my code and someone say have seperate value to reciever mean
    make subrountine to reciever each value a time. i will try it tonight.
  • TomvnTomvn Posts: 103
    edited 2008-09-26 14:53
    i try make subrountine ,but it not work , any more idea ???
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-09-29 15:42
    It seems this is a duplicate thread. If not for so many replies on both ends I would remove on of the threads. Instead, I will ask everyone to defer replies only to the following thread and not reply here anymore. Cross-posting is not allowed. Please post messages on a subject only once and in the appropriate forum.

    http://forums.parallax.com/showthread.php?p=754639

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.