View Full Version : Serin command with Eb500 need help.?
09-25-2008, 04:17 AM
ˇ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.
09-25-2008, 04:44 AM
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.
09-25-2008, 04:49 AM
i use bluetooth on my laptop and use debug window in pbasic to make output
09-25-2008, 05:08 AM
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,[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.
09-25-2008, 06:32 AM
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.
09-25-2008, 09:23 AM
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.
09-25-2008, 10:08 AM
ok, so , could i send couple character at one time like this
SERIN BT_RX,BTBaud,[WAIT ("!"), Motion]
If Motion = "forward" then forward_fast
or i should sent string value to it, i know serin it not buffered.
09-25-2008, 10:25 PM
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?
09-25-2008, 10:36 PM
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).
09-26-2008, 02:45 AM
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.
09-26-2008, 09:53 PM
i try make subrountine ,but it not work , any more idea ???
09-29-2008, 10:42 PM
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.