How can I fix the unstable communication what Boe-Bot Kit for MSRS add a new mo
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.
but it very strange when I receive data form "_serialPort.Read(packet, 0, 6);"
I always take wrong·array data, such as
but in the Basic Stamp chip, the data is·normal.
How can I fix this problem? Thank you!
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The·structure looks like this:
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!