Shop OBEX P1 Docs P2 Docs Learn Events
talk to boe bot using c# with eb500 — Parallax Forums

talk to boe bot using c# with eb500

zzacreekzzacreek Posts: 3
edited 2008-09-29 20:43 in Robotics
i want to create a program with c# to talk to my boe bot using eb500. I have set it up as a com port and i created a program that sends the data over to the boe bot using c# but the boe bot cannot read what i am sending over?
i was wondering if anyone knew how to open up the com port with c# and what settings you need? i have been able to open it up and send data, but so far boe bot reads it as Smile and not a string?
i should also note that i am trying to send it chars.
i want to use my computer as the brains of the system and have the boe bot be controled with it. I am going to hook up a real time cam system to it so it can track objects and tell what kind of object it is and so on.
thanks for all the help..

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-05-30 03:00
    You need to make sure the baud rate is the same on both ends. Also the bot has no way to tell when the string will be comming so you need to have it waiting for the string all the time, at least at the start until you get out what you put in then you can progress to doing other things and checking for input. If you attach your code it will help in diagnosing your troubles.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • zzacreekzzacreek Posts: 3
    edited 2008-06-02 04:03
    I really just took the defaults of everything that the System.IO.Ports is using in C# i changed the Baudrate and portname to use 9600 and com6 which is the port i am using:
    code below:
    SerialPort sp = new SerialPort();

    sp.BaudRate = Convert.ToInt32(b_p_sec.Text);



    //sp.DataBits=Convert.ToInt32(data_b.Text);
    //sp.pa
    //sp.Parity
    sp.PortName =comport.Text;

    Then i send the command to the robot:
    // send command to robot..
    Encoding my;
    //byte[noparse]/noparse testa = new byte[noparse][[/noparse]50];// set the array..
    try
    {
    //write line to serial port
    //byte array[noparse]/noparse;
    //array='H';
    // works but only with one char???
    //my = sp.Encoding;
    sp.Write(sendbox.Text);
    // sp.Write(
    //StopBits test;
    //test.
    //sp.StopBits
    //sp.


    //sp.WriteLine(sendbox.Text);
    //clear the text box

    sendbox.Text = "";
    }
    catch (System.Exception ex)
    {
    MessageBox.Show( ex.Message);
    }

    It works and it looks like it just sends the first letter? when i do this in Hyper Terminal it works fine and sends everything? But C# must use the serial ports different or something? i have not tried to rev from the robot yet?
    anyone know what might be the problem? or should i use C++ or something to do this?
    I can talk to my robot and it gets the first letter like i said but it just does not seem to get the rest. I had the rev on the bot set to an array of bytes so i should have the room.
  • JeffgJeffg Posts: 17
    edited 2008-06-02 06:25
    Check out the MSRS - Bluetooth Boe Bot v1.4, the Bluetooth Boe-Bot Example Code v1.2 for MSRS and the Microsoft Robotics Studio; The standard configuration includes the EB500.

    The code is there for both sides (the BoeBot and the PC. Below is the Serial Port section from the MSRS - BoeBotControl.cs file.


    public bool Connect(int serialPort, out string errorMessage)
    {
    if (serialPort <= 0)
    {
    errorMessage = "The Boe-Bot serial port is not configured!";
    return false;
    }

    if (connected)
    {
    Close();
    }

    try
    {
    string ComPort = "COM" + serialPort.ToString();
    _serialPort = new SerialPort(ComPort, 9600, Parity.None, 8, StopBits.One);
    _serialPort.Open();
    _serialPort.DiscardInBuffer();
    errorMessage = string.Empty;
    connected = true;
    return true;
    }
    catch (Exception ex)
    {
    errorMessage = string.Format("Error connecting Boe-Bot to COM{0}: {1}", serialPort, ex.Message);
    return false;
    }
    }

    public void Close()
    {
    if (!connected)
    return;
    connected = false;

    if (running)
    {
    running = false;
    Thread.Sleep(100);
    }

    if (_serialPort != null && _serialPort.IsOpen)
    {
    _serialPort.Close();
    _serialPort = null;
    }

    }
  • zzacreekzzacreek Posts: 3
    edited 2008-07-02 03:24
    well i did figure out most of my issues. i found that in C# using the com port with blue tooth you have a 2 byte limit on how much data you can send and get. i have found that is the most information i can send and get at one time.
    so that kind of sucks for sending data to the computer.
    because i really need this all to be done in real time. so the computer can do more work.

    But talking back and forth between C# and boe bot works. All you have to do is use the System.IO.Ports.. i had to send the data and get the data using bytes. giving that i only have 2 byte to send of data does not really give me all the options i was hoping for.

    well i wanted to close this out should some ever search on this..
  • vinionvinion Posts: 2
    edited 2008-09-29 20:43
    There is a code to "talk" to SumoBot with C#..
    I dont know if you are still looking for an answer or if this can help..
    www.codemammoth.com/ShowCode.php?Code=16
Sign In or Register to comment.