PacketSerial problem with FW.ver.4.1.10

General discussion of using Roboclaw motor controllers
RaymondLiu
Posts: 4
Joined: Wed Sep 09, 2015 7:37 pm
PacketSerial problem with FW.ver.4.1.10

Post by RaymondLiu »

I have an Arduino Mega2560 connected to RoboClaw 2x15A V5 FW.ver.4.1.10 with Packet Serial mode.
I tried to read back data using RoboClaw library with example PacketSerialReadVersion but got nothing .
Also, switched to RoboClaw2 in this form, the problem was still existed.
http://forums.basicmicro.co.uk/topic997 ... 048518b33f

I'm sure the setting (baud, connection, mode) is correct, and the STAT1 LED on RoboClaw is blinking when command was be send.

The USB mode worked very well with IonMotion configuration program. I also tried to use the python library, it was fine.

I need a communication to RoboClaw with MCU serial. Please give me a help.
yongjaewon
Posts: 5
Joined: Sun Sep 06, 2015 6:25 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by yongjaewon »

Software serial does not seem to work reliably, if at all, for some reason. Not sure why. To try hardware serial, open PacketSerialReadVersion example code, change "RoboClaw rc(10,11,10000);" to "RoboClaw rc(15,14,10000);". Pin 14 on the mega goes to S1 data on the RoboClaw, and pin 15 goes to S2 data.

If it still does not work, double check these configurations..
RoboClaw should be in mode 7(packet serial with address 0x80), option 4(38400 baud rate).
Arduino serial monitor or similar should be opened on the correct COM port with 57600 baud rate.
RaymondLiu
Posts: 4
Joined: Wed Sep 09, 2015 7:37 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by RaymondLiu »

Still not work. Do you try the newest FW 4.1.10 ?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by Basicmicro Support »

First you should make sure data is coming back to the Arduino at all if you can. If you havea scope check the S2 pin from the roboclaw and make sure it is sending data when you send the Read Version command. If it is then you need to focus your attention on the Arduino code(eg possibly wrong pin used on the Arduino for receiving data). If it is not sending anything back double check what you are sending the Roboclaw. Is the address set correctly?

Note: If the Roboclaw see a valid packet but the address for the packet is not the address of that roboclaw it will blink the LED just like normal but still ignore the packet and no data will be sent back.
RaymondLiu
Posts: 4
Joined: Wed Sep 09, 2015 7:37 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by RaymondLiu »

Hi acidtech, thank you for your reply.
I found a big issue that should be reported to you.
When a MCU communicated to Roboclaw using packet serial, the Roboclaw must connect a USB cable to PC.
Or MCU only received byte of value 255. I test using Read Encoder M1 (command:16)

Connection with encoder, MCU and USB
Image

Get M1 encoder with USB connection via MCU
Image

Get M1 encoder without USB connection via MCU
Image
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by Basicmicro Support »

Could you please provide a little more information. Are you sending commands to the roboclaw directly using RealTerm? If so what exactly are you sending? What baud rate are you using as well?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by Basicmicro Support »

Here is a test arduino program I used. Roboclaw was only connected to the arduino via S1 and S2 and there was no USB connection to the Roboclaw. Encoder values read out correctly. I also ran it at 38400 but 19200 seems to work best with software serial on an arduino.

Code: Select all

//Includes required to use Roboclaw library
#include "BMSerial.h"
#include "RoboClaw.h"

//Roboclaw Address
#define address 0x80

//Setup communcaitions with roboclaw. Use pins 10 and 11 with 10ms timeout
RoboClaw roboclaw(10,11,10000);

void setup() {
  //Open terminal and roboclaw at 38400bps
  Serial.begin(9600);
  roboclaw.begin(19200);
}

void loop() {
  uint8_t status1,status2,status3,status4;
  bool valid1,valid2,valid3,valid4;
  
  //Read all the data from Roboclaw before displaying on terminal window
  //This prevents the hardware serial interrupt from interfering with
  //reading data using software serial.
  int32_t enc1= roboclaw.ReadEncM1(address, &status1, &valid1);
  int32_t enc2 = roboclaw.ReadEncM2(address, &status2, &valid2);
  int32_t speed1 = roboclaw.ReadSpeedM1(address, &status3, &valid3);
  int32_t speed2 = roboclaw.ReadSpeedM2(address, &status4, &valid4);

  if(valid1 && valid2 && valid3 && valid4){
    Serial.print("Encoder1:");
    Serial.print(enc1,HEX);
    Serial.print(" ");
    Serial.print(status1,HEX);
    Serial.print(" ");
    Serial.print("Encoder2:");
    Serial.print(enc2,HEX);
    Serial.print(" ");
    Serial.print(status2,HEX);
    Serial.print(" ");
    Serial.print("Speed1:");
    Serial.print(speed1,HEX);
    Serial.print(" ");
    Serial.print("Speed2:");
    Serial.print(speed2,HEX);
    Serial.print(" ");
    Serial.println();
  }
  
  delay(10);
}
RaymondLiu
Posts: 4
Joined: Wed Sep 09, 2015 7:37 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by RaymondLiu »

RealTerm is just showing bytes MCU get from RoboClaw.
The baud is 57600 in MCU and RoboClaw. Also test with 38400, 19200.
I send a address byte 128 and a command byte 16 ,then received 4(encoder number) + 1(status) + 1(checksum) = 6 byte.

What's the arduino board you use ? I have the same problem using Mega2560.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: PacketSerial problem with FW.ver.4.1.10

Post by Basicmicro Support »

Just posting an update. Roboclaw has error handling systems in packetserial. One of them is a timeout if a full packet isnt received quickly enough(eg no more than 10ms delays between bytes received for a single packet). This is so if a bad packet is received or bad bytes get in to the buffer(eg a false start bit for example) the buffer will automatically clear if you wait 10ms.

I believe this is the cause of your problems with RealTerm. I have another customer who had a similar problem with RealTerm. Instead of using Realterm(he was using it for testing) he is now using his final processor and has enabled acknowledgements on Roboclaw commands and is properly handling failed packets which fixed his problem.

To enable acks in the current arduino library change the constructor from this:

RoboClaw roboclaw(10,11,10000);

to this:

RoboClaw roboclaw(10,11,10000,true);

Note the next firmware release makes two changes. One, acks are always enabled(so the argument in the arduino constructor is being removed) for packet serial and we have changed from a simple checksum to a CRC16. That will apply to firmware 4.1.11 and newer. This will prevent errors that would have gotten through the simple checksum.
Penguine
Posts: 4
Joined: Thu Oct 29, 2015 12:13 am
Re: PacketSerial problem with FW.ver.4.1.10

Post by Penguine »

I found Roboclaw works at baud rate 19200 other than 38400 with my starDuino ( similar to leonarde). At 38400, the drive shall be " activated" by connection of USB. Latest firmware certainly. With diffent PWM PINs output, drive could be improved.
Wish to be helpful somewhat.

Post Reply