SBL1360 RS232 to Arduino TTL Issue

3 years 6 months ago - 3 years 6 months ago #29532813 by alkaza
SBL1360 RS232 to Arduino TTL Issue was created by alkaza
Hello, everyone.

I know there are several people out there who have succeeded with serial communication between Arduino and Roboteq.
I have been struggling for a long time now and cannot get it to work.
Please help me figure out what am I doing wrong.

Roboteq Brushless DC Motor Controller: SBL1360

Arduinos used: Uno, Nano, Due

RS232 to TTL Converter Modules used:
ElecFreaks
Seeed

Cable configuration:
DB9 Female To PC		DB15 Male To Controller
Pin 2 (RX Data)		-	Pin 2 (Data Out)
Pin 3 (TX Data)		-	Pin 3 (Data In)
Pin 5 (GND)		-	Pin 5 (GND)

Setting up Roboteq via Roborun+ PC Utility Console:
Disable watchdog
^RWD 0
Save Configuration
%EESAV

Commands:
Read Motor Amps
?A
Go to Speed or to Relative Position
!G 1 500

Sample Arduino Code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("!G 1 500_");
  delay(1000);
}

Troubleshooting:
Reading and writing commands using Putty Serial
  1. PC -> USB to RS232 -> RS232 to BOB15 -> SBL1360 - Works
  2. PC -> Arduino -> TTL to RS232 -> RS232 to USB -> PC - Works
  3. Arduino -> TTL to RS232 -> RS232 to BOB15 -> SBL1360 - Does not work

I have experimented with different Arduinos, different RS232 to TTL converters and different serial communication libraries, flipped RX/TX wires, still no luck.

Thank you in advance,

Alena

Please Log in or Create an account to join the conversation.

3 years 6 months ago #29532820 by giantpt
Hello Alena,

From what I see in your Arduino code, it will send a short command to the RoboteQ and than wait 1 second and send another short command.
This will make the motor spin for a fraction of a second every 1 second.
In your code you CANNOT use "delay" to command your roboteq, it must be something like this:
Serial.println("!G 1 500 ");

and it has to be constantly sent for the motor to keep spinning.
The TTL converter seems to be ok, I use a similar one from SparkFun which is a switching TTL to Serial converter

To get the values from the roboteq to the arduino you can either request them from the arduino or write a script on the roboteq to send them to the arduino.
for either situations I recommend you to disable the serial echo on the roboteq, like this the string comes cleaner to the arduino.
Than you'll have to parse the string on the arduino side in order to "dismantle" all the elements of the string you are getting from the roboteq.

but first try to use something like this to check what are you receiving on the arduino from the roboteq, I'll post a part of a code I have, you'll have to check it and declare some missing variables on the top of the arduino code for it to work:
// I use arduino Mega, Serial1 to connect to the RoboteQ and Serial to see the results on the Serial Monitor of the Arduino IDE
Serial1.println("?V_?A_?C 1_?T_?FF_?FS\r" );       // Here I am requesting some telemetry elements to the roboteq and I am using Serial1 on arduino Mega
    unsigned long recTime = millis();                         // Here I am starting to compose the incoming string
    while (Serial1.available() > 0  || millis()-recTime<50) {
      char inChar = (char)Serial1.read();     // get the new byte:
      inputString += inChar;
      if(inputString.indexOf("FS=")<inputString.lastIndexOf('\r'))
        stringComplete = true;
    }
    
    
    if(stringComplete) {
      Serial.println(inputString);  // Print entire string from controller on the Serial Monitor of your IDE

                                    // OR print just the piece of information you want, in this case is voltage      
      
      if(dispVoltage1 == 0.0 || abs(parseReceivedValue(inputString,"V=",":",":",10.0) - dispVoltage1) <= 10.0)
        dispVoltage1 = parseReceivedValue(inputString,"V=",":",":",10.0);
      Serial.println(dispVoltage1);

Please, don't forget to declare some variables or this will not work, this code is just a small part of a really complex one.

Declare:
String inputString; // a string to hold incoming data
boolean stringComplete = false;
float dispVoltage1 = 0.0;

On Void Setup you also need:

Serial1.begin(115200); // to communicate with the roboteq

inputString.reserve(128);
stringComplete = false;
loopCnt = 0;

I think this is all you need

Have fun
The following user(s) said Thank You: blake, alkaza

Please Log in or Create an account to join the conversation.

3 years 6 months ago - 3 years 6 months ago #29532821 by alkaza
Replied by alkaza on topic SBL1360 RS232 to Arduino TTL Issue
Thank you for your detailed answer!
Unfortunately, even with local echo disabled and without the delay in the Arduino code, the Roboteq does not react to the command (the motor is not spinning).
Using Arduino Due:
void setup() {
  // put your setup code here, to run once:
  Serial1.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial1.println("!G 1 500_");
}
Any ideas what could be the issue?

Please Log in or Create an account to join the conversation.

3 years 6 months ago #29532822 by blake
@giantpt - Thank you for your detailed response it is quite comprehensive. I do have one minor amendment: It should not be necessary to send a command every one second. If you are having to do this in your system it is because of the motor controller's serial watchdog timer which is set to 1000ms by default. You can disable the watchdog or increase the time using the ^RWD command. This is further described on page 279 of our User Manual.

@alkaza - It is not necessary to use the underscore after the command value in your !G command. See the .ino code below, this is a working test script that will simply turn on and off the motor in a loop. If this does not work, then you'll want to double check your wiring between the Arduino and the motor controller. You need the Tx from the Arduino to connect to the Rx of the motor controller, and the Rx of the Arduino to connect to the Tx of the motor controller. I have not used the specific RS232 - TTL adapter that you are using before but there is no reason it should not work.
String command;

void setup() {
  // put your setup code here, to run once:

  Serial.begin(115200);  //set serial baud to 115200 bps

  Serial.println("^rwd 1 0"); //disable motor controller watchdog
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(5000); //hold 5 sec
  Serial.println("!G 1 500"); //forward
  delay(5000); //run for 5 sec
  Serial.println("!G 1 0"); //stop
}
The following user(s) said Thank You: alkaza

Please Log in or Create an account to join the conversation.

3 years 6 months ago - 3 years 6 months ago #29532825 by alkaza
Replied by alkaza on topic SBL1360 RS232 to Arduino TTL Issue
Thank you for your response!
I have tried the code you posted before (I looked at several topics related to my issue before creating one) and it still does not work. I have disabled the watchdog in the Roboteq's settings and with or without local echo the situation does not change.
I believe that wiring between the Arduino and the RS232 converter is correct because when I connect it to the PC, the serial console receives the commands from the Arduino with no problem but even if I flip RX/TX wires, it does not work with the Roboteq.
I am wondering if the RS232 to BOB15 cable I made might be the issue though when I connect it to the PC, the Roboteq properly responds to the commands from the serial console and the serial console receives the feedback if local echo in enabled.
To make the cable, I bought appropriate connectors and clips and used some jumper wires. Maybe I should have bought different wires, like optical fiber cable? When I check with a multimeter the continuity between the Roboteq and the RS232 converter pins, everything is fine.
My other guess was that the RS232 voltage levels from the converter are not enough for the Roboteq or the Arduino operates on the wrong frequency but normally it should not be an issue. I tried to troubleshoot it with the oscilloscope but could not figure it out. I will try again and keep you posted.

Please Log in or Create an account to join the conversation.

3 years 6 months ago - 3 years 6 months ago #29532826 by alkaza
Replied by alkaza on topic SBL1360 RS232 to Arduino TTL Issue
Troubleshooting with Oscilloscope:

PC Serial Console:
Pressing "a" key

TTL from PC:

(PC -> RS232 to TTL)

RS232 from PC:


Arduino:
void setup() {
  // put your setup code here, to run once:
  Serial1.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial1.print("a");
  delay(1);
}

TTL from Arduino:


RS232 from Arduino:

(Arduino -> TTL to RS232)
Attachments:

Please Log in or Create an account to join the conversation.

3 years 6 months ago #29532830 by alkaza
Replied by alkaza on topic SBL1360 RS232 to Arduino TTL Issue
I feel like maybe SBL1360 is very sensitive to small changes in frequencies. I will purchase Sparkfun RS232 Shifter and see if it helps, seems like it worked for you guys. Maybe the problem is in RS232 converters that use MAX232 chip.

Please Log in or Create an account to join the conversation.

3 years 6 months ago #29532847 by giantpt
Hello Alzaka,

I use both converters without problems... the SparkFun shifter and another one bought on eBay with the MAX232... in the past I have even made my own converters with the MAX232 chip with success.
I start to believe that you might have a problem on the RoboteQ controller or on your MAX232 converter

Please Log in or Create an account to join the conversation.

3 years 5 months ago #29532863 by blake
Sorry for the delayed response. I have finally had some time to test the RS232-TTL Adapter with a few different Arduino models. I tested the Mega, Uno, and 101 as well as several different controllers especially the SBL1360 and as before I had no problems communicating between the Arduino and controller

Please Log in or Create an account to join the conversation.

2 years 7 months ago #29533477 by BENOIT
Hello,
I have the same problem with a HBL2360... did you find a solution ?
Thanks
Tib'

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.301 seconds