Shop OBEX P1 Docs P2 Docs Learn Events
How can I fix the unstable communication what Boe-Bot Kit for MSRS add a new mo — Parallax Forums

How can I fix the unstable communication what Boe-Bot Kit for MSRS add a new mo

ttxno1ttxno1 Posts: 5
edited 2008-03-22 19:35 in Robotics
Hi:

Today, I setup a new motor in the Boe-Bot.

But it is unstable when I want to connect it to MSRS.

I modify array length·at·the "BoeBotControl.cs"·in·MSRS BASICStamp2 simple code.

private void SendSpeed(int left, int right)
{
      byte[noparse][[/noparse]] buf = new byte[noparse][[/noparse]6];
      buf[noparse][[/noparse]2] = 32;
      buf[noparse][[/noparse]3] = (byte)left;
      buf[noparse][[/noparse]4] = (byte)right;
      buf[noparse][[/noparse]5] = (byte)middle;  //<---new Motor
      SendPackets(ref buf);
}

        private bool SendPackets(ref byte[noparse][[/noparse]] packet)
        {
            if (packet.Length != 6) throw new SystemException("Invalid packet length!");
            packet[noparse][[/noparse]0] = 255;                                            // Start byte.
            packet[noparse][[/noparse]1] = msgCnt;                                         // Message index, incremened by Boe-Bot.
                                                                        // Must be used in next message that is
                                                                        // sent.
            while (_serialPort.BytesToRead < 6)                        
            {                                                              
                _serialPort.Write(packet, 0, 6);                        
                while (_serialPort.BytesToWrite > 0) Thread.Sleep(1);
            }
            _serialPort.Read(packet, 0, 6);                             // Get Boe-Bot's reply.
            msgCnt = packet[noparse][[/noparse]1];                                         // Get next message count.
            if (packet[noparse][[/noparse]2] == 1) handshake = false;                      // Boe-Bot requests reconnect.
            return true;
        }


but it very strange when I receive data form "_serialPort.Read(packet, 0, 6);"

I always take wrong·array data, such as
packet[noparse][[/noparse]0] = 0
packet[noparse][[/noparse]1] = 255
packet[noparse][[/noparse]2] = 0
packet[noparse][[/noparse]3] = 255
packet[noparse][[/noparse]4] = 0
packet[noparse][[/noparse]5] = 3

but in the Basic Stamp chip, the data is·normal.
packet[noparse][[/noparse]0] = 255
packet[noparse][[/noparse]1] = 0
packet[noparse][[/noparse]2] = 3
packet[noparse][[/noparse]3] = 0
packet[noparse][[/noparse]4] = 0
packet[noparse][[/noparse]5] = 0


How can I fix this problem? Thank you!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-03-22 01:42
    What kind of motor are we talking about?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ttxno1ttxno1 Posts: 5
    edited 2008-03-22 19:35
    Actually, I use a BS2p24 and BS2 to control three DC motor.

    The·structure looks like this:

    bs.bmp

    The BS2p24 connect with a computer, and the BS2 make PWM signs for three DC motor.

    I did't know why·the·BS2p24 lost signs from the computer·when I just used·one BS2p24 to control DC motor and make PWM signs.

    So I use two chip to repair it.

    I'm not sure it's a·good solution? but now I've a problem about MSRS connect to BS2p24.

    Would you have any suggest?

    However, very·thank you for your question!
Sign In or Register to comment.