Hi All,
I'm working on a project to control some servos with Automation Direct's SureServo2 line of products and I am running into an issue I can't seem to resolve.
I'm currently using Paul's Modbus RTU Library as found here: https://github.com/PaulStoffregen/Modbus-Master-Slave-for-Arduino
I modified one of the examples for testing as shown:
As you can see I've only modified the parameters to match the default parameters that the Servo Drive requires. Then at the bottom I've added a little loop to spit out all the data via my serial monitor to see if everything is working.
Short answer: it's not
To clarify, the serial monitor is spitting out nothing but the following each loop:
0000000000000000..
However I've attached a screenshot from my logic analyzer to show that I should be receiving "7554" in there somewhere (this is just the encoder count for the servo's current rotational position, this will change a lot as it is rotating). Note that I am reading these data from my analyzer with the listed signals connected to the appropriate teeny pins (0,1 & 2 in this example)
I've gone through A LOT of troubleshooting. Here's what I've tried:
With my current hardware setup and this new model of servo drive, the result is always the same: query goes out, expected response comes back, but I don't get any usable data out of the library functions.
Please tell me I'm not overlooking something simple! I've been going nuts trying to get something I can work with, but I've had no luck so far. Actually, I will take a simple fix! Anything to help me move on and start being able to use my servos
Thanks in advance for any insight ya'll might be able to provide.
I'm working on a project to control some servos with Automation Direct's SureServo2 line of products and I am running into an issue I can't seem to resolve.
I'm currently using Paul's Modbus RTU Library as found here: https://github.com/PaulStoffregen/Modbus-Master-Slave-for-Arduino
I modified one of the examples for testing as shown:
Code:
#include <ModbusRtu.h>
uint16_t au16data[16];
uint8_t u8state;
Modbus master(0,Serial1,2); //
modbus_t telegram;
unsigned long u32wait;
void setup() {
Serial.begin(9600); // for viewing result during testing
Serial1.begin(38400, SERIAL_8N2); // servo drive default com parameters
master.begin(38400);
master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over
u32wait = millis() + 1000;
u8state = 0;
}
void loop() {
switch( u8state ) {
case 0:
if (millis() > u32wait) u8state++; // wait state
break;
case 1:
telegram.u8id = 127; // slave address
telegram.u8fct = 3; // function code (this one is registers read)
telegram.u16RegAdd = 18; // start address in slave
telegram.u16CoilsNo = 2; // number of elements (coils or registers) to read
telegram.au16reg = au16data; // pointer to a memory array in the Arduino
master.query( telegram ); // send query (only once)
u8state++;
break;
case 2:
master.poll(); // check incoming messages
if (master.getState() == COM_IDLE) {
u8state = 0;
u32wait = millis() + 1000;
for (int i=0; i<16; i++) {
Serial.print(au16data[i]);
}
Serial.println("..");
}
break;
}
}
As you can see I've only modified the parameters to match the default parameters that the Servo Drive requires. Then at the bottom I've added a little loop to spit out all the data via my serial monitor to see if everything is working.
Short answer: it's not
To clarify, the serial monitor is spitting out nothing but the following each loop:
0000000000000000..
However I've attached a screenshot from my logic analyzer to show that I should be receiving "7554" in there somewhere (this is just the encoder count for the servo's current rotational position, this will change a lot as it is rotating). Note that I am reading these data from my analyzer with the listed signals connected to the appropriate teeny pins (0,1 & 2 in this example)
I've gone through A LOT of troubleshooting. Here's what I've tried:
- Different Teensy 4.1s
- Different Serial Ports on the Teensys (Serial1 and Serial2)
- Different MAX3485 ICs (with 120ohm resistor installed).
- Changing parameters in the servo drive to use different speed, data format (and of course updating the code to reflect those changes)
- Different libraries: both the Smarmengol library which Paul's was forked from, and 4-20ma's (Doc Walker) ModbusMaster library which I had successfully used previously with the previous generation of SureServo (not SureServo2) drives via RS232 with a MAX3232 chip.
With my current hardware setup and this new model of servo drive, the result is always the same: query goes out, expected response comes back, but I don't get any usable data out of the library functions.
Please tell me I'm not overlooking something simple! I've been going nuts trying to get something I can work with, but I've had no luck so far. Actually, I will take a simple fix! Anything to help me move on and start being able to use my servos
Thanks in advance for any insight ya'll might be able to provide.