Serial command to set undocumented S3, S4, S5 modes

General discussion of using Roboclaw motor controllers
Post Reply
ryanrs
Posts: 2
Joined: Tue Aug 01, 2017 4:03 pm
Serial command to set undocumented S3, S4, S5 modes

Post by ryanrs »

Is there more documentation for packet serial commands 74/75? The manual only covers basics, but in the Ion app I can do things like invert the signal, set user/auto home mode, set timeouts, etc. When I choose these advanced modes in the app, I can see different values returned for command 75.

I am using a Roboclaw 2x15a with firmware v4.1.23, using packet serial commands over USB.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Serial command to set undocumented S3, S4, S5 modes

Post by Basicmicro Support »

We recently updated those functions to add that functionality. The manual has not been update yet. Is there a reason you need to change those settings on the fly? We recommend you use Ion Studio to setup and save your settings once which elliminates any need to set them in your packet serial programs.

The new values available are:

SIGTYPE_ESTOP 0x01
SIGTYPE_LIMIT 0x02
SIGTYPE_EX 0x04

SIGFLAG_INV 0x08

//LIMIT
SIGFLAG_FOREWARD 0x10
SIGFLAG_BACKWARD 0x20
SIGFLAG_HOME 0x40
SIGFLAG_AUTO 0x80

//ESTOP
SIGFLAG_LATCH 0x80

//EX Mode
SIGFLAG_BRAKE 0x00
SIGFLAG_CLAMP 0x10
SIGFLAG_RS485 0x20
SIGFLAG_USER 0x70
SIGFLAG_ENCMODE 0x80

You OR together combinations to create the settings. Starting by selecting the SIGTYPE(ESTOP, LIMIT or EX). Then OR that with SIGFLAG_INV if you want to invert the pin. Then Depending which sigtype you used you have different sigflags that can be OR'd together.

To set a pin as a latching e-stop you would set SIGTYPE_ESTOP | SIGFLAG_LATCH
For an inverted latching e-stop you would set SIGTYPE_ESTOP | SIGFLAG_LATCH | SIGFLAG_INV
To set the pin as a home signal with automatic homing on startup you would set SIGTYPE_LIMIT | SIGFLAG_HOME | SIGFLAG_AUTO

Note all combinations are allowed. Only those you have available in Ion Studio. So you can setup a limit with both a forward and backward limit. Only a forward limit(active only when moving forward) in combination with a home signal(active only when in reverse) etc...

The automatic duty and timeout values for s4 and s5(used when set to auto home) can be set using commands 105(s4) and 106(s5). Arguments are duty(2 bytes) and timeout(4 bytes). These functions have not been added to the libraries we provide yet but if you really need them you should be able to add them easily enough.
ryanrs
Posts: 2
Joined: Tue Aug 01, 2017 4:03 pm
Re: Serial command to set undocumented S3, S4, S5 modes

Post by ryanrs »

Thanks! I'm not changing them on the fly. I just wanted to understand what's going on under the hood, plus minimize the amount I need to run Ion Studio (avoiding using Windows).
carlos_en14
Posts: 12
Joined: Tue May 09, 2017 9:42 am
Re: Serial command to set undocumented S3, S4, S5 modes

Post by carlos_en14 »

Those variables SIGFLAG_XXXXXX are not in the RoboClaw Arduino library and when compiling throws an error, variables are not declared in the scope.

You know if is there a new Arduino library version up to date? Or you are saying that for the moment we should declare by ourselves to use them?

This could be an Arduino example?..

Code: Select all


#define SIGTYPE_ESTOP	0x01

//ESTOP
#define SIGFLAG_LATCH	0x80

#define address 0x80

#include <RoboClaw.h>
#include <SoftwareSerial.h>

SoftwareSerial serial(roboclawRx, roboclawTx);  // S1 > 11  .  S2 > 10
RoboClaw roboclaw(&serial, 10000);

void setup() {
  Serial.begin(57600);
  roboclaw.begin(38400);
  
  //DO HOME MANUAL OR AUTO, DOESN'T MATTER, AT THIS MOMENT S3 IS E-STOP
  
  //AFTER HOMED CONVERT S4 AND S5 SWITCHES TO E-STOP LATCHING
  
  roboclaw.SetPinFunctions(address,SIGFLAG_LATCH,SIGFLAG_LATCH,SIGFLAG_LATCH );
}
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Serial command to set undocumented S3, S4, S5 modes

Post by Basicmicro Support »

Yes. You can either
1. Just use the numbers directly

2. Add them as defines in your arduino program as you did, here is the whole list so just cut and paste)

#define SIGTYPE_ESTOP 0x01
#define SIGTYPE_LIMIT 0x02
#define SIGTYPE_EX 0x04

#define SIGFLAG_INV 0x08

//LIMIT
#define SIGFLAG_FOREWARD 0x10
#define SIGFLAG_BACKWARD 0x20
#define SIGFLAG_HOME 0x40
#define SIGFLAG_AUTO 0x80

//ESTOP
#define SIGFLAG_LATCH 0x80

//EX Mode
#define SIGFLAG_BRAKE 0x00
#define SIGFLAG_CLAMP 0x10
#define SIGFLAG_RS485 0x20
#define SIGFLAG_USER 0x70
#define SIGFLAG_ENCMODE 0x80

3. Wait for us to update the arduino library. We will be doing that but its going to be several weeks at a minimum. We have a fairly long todo list right now.

Since the only change for these commands is the new values for the arguments(still the same arguments) I'd go with 1(my preference) or 2(for readability).
carlos_en14
Posts: 12
Joined: Tue May 09, 2017 9:42 am
Re: Serial command to set undocumented S3, S4, S5 modes

Post by carlos_en14 »

IMC Support wrote: 3. Wait for us to update the arduino library. We will be doing that but its going to be several weeks at a minimum. We have a fairly long todo list right now.

Since the only change for these commands is the new values for the arguments(still the same arguments) I'd go with 1(my preference) or 2(for readability).
Looks like you haven't update the library by now.. I am using it this way..
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Serial command to set undocumented S3, S4, S5 modes

Post by Basicmicro Support »

We've added the above as an enum in the Robcolaw library but we havent released the update yet. We are in the middle of a firmware up and wont release the new arduino library until the new firmware update is finalized.

Until then using these #defines is the recommended option. Actually the main recommended option is to use Ion Studio to setup the control but if you have to change the pin modes dynamically this is the correct method.
rwschumann
Posts: 8
Joined: Wed Jun 20, 2018 7:39 am
Re: Serial command to set undocumented S3, S4, S5 modes

Post by rwschumann »

The current manual also needs to be updated as it shows a mode of 3 for going into voltage clamp mode. Sending this actually causes it to go into an estop latch and it halts with an estop error if an actual voltage clamp circuit is attached.

I am running firmware 4.1.24
Manual has no visible ID or marking other than a copyright 2014, 2015 notice.

Post Reply