Hi,
I’m doing a hand prosthesis project where I need to be able do control 8 DC motors with quadrature encoders (Faulhaber 1512 SR 324:1 with encoder I2E-8). The conections between them is as follow:
I managed to control the motors by setting the Duty cycle, as test, but now I need to be able to control them by providing a desired position. I tried using one of the example codes from the library, but nothing happens:
[roboclaw_arduino_library/examples/PacketSerialEncoderPosition/PacketSerialEncoderPosition.ino at master · basicmicro/roboclaw_arduino_library · GitHub]
This is how the Roboclaw is configured and calibrated on Motion studio
Am I missing something?
Best Regards, Celina
Hello, Celina.
It looks like you have your RoboClaw’s packet serial address set to 129 (0x81) while the example code you linked to uses the address 128 (0x80). Can you try making those match and seeing if that fixes the problem?
Brandon
I made modifications to the code I ran in my IDE:
//See BareMinimum example for a list of library functions
//Includes required to use Roboclaw library
#include "RoboClaw.h"
#define address 0x81
//Arduino Mega2560 Pins 18-TX(S1-RX) and 19-RX(S2-TX)
RoboClaw roboclaw(&Serial,10000);
//Display Encoder and Speed for Motor 1
void displayspeed(void)
{
uint8_t status1,status2;
bool valid1,valid2;
int32_t enc1 = roboclaw.ReadEncM1(address, &status1, &valid1);
int32_t speed1 = roboclaw.ReadSpeedM1(address, &status2, &valid2);
if(valid1){
Serial.print(F("Encoder1:"));
Serial.print(enc1,DEC);
Serial.print(F(" "));
Serial.print(status1,HEX);
Serial.print(F(" "));
}
if(valid2){
Serial.print(F("Speed1:"));
Serial.print(speed1,DEC);
Serial.print(F(" "));
}
Serial.println();
}
//This is the first function arduino runs on reset/power up
void setup() {
//Open Serial and roboclaw at 38400bps
Serial.begin(115200);
delay(100);
Serial.println(F("Starting..."));
roboclaw.begin(38400);
delay(50);
}
void loop() {
roboclaw.SpeedAccelDeccelPositionM1(address,0,12000,0,11000,1);
roboclaw.SpeedAccelDeccelPositionM1(address,0,12000,0,1000,0);
roboclaw.SpeedAccelDeccelPositionM1(address,32000,12000,32000,11000,0);
roboclaw.SpeedAccelDeccelPositionM1(address,32000,12000,32000,1000,0);
long last = millis();
while(millis()-last<5000){
displayspeed();
delay(50);
}
}
Just to clarify, are you saying the problem persists even after making that change?
It looks like there are a couple other modifications to the code aside from the address value. If you’re still having problems, could you try keeping everything except the address value in the example unmodified (or using the completely unmodified example and changing the address on you RoboClaw to match instead)? Also, are you still using the Arduino Mega 2560 as mentioned in your other thread?
Brandon
Yes, I’m actually using an Arduino Mega, sorry for the confusion.
I conected Pins 11(S1-RX) and 10(S2-TX) and did as you said and used the original code only changing the adress value but it still didn’t work and the monitor printed as follow, and then just blank:
Sorry for the delayed response; are you still having problems getting the serial communication to work?
I looked back through your settings and noticed you have S3 configured as a latching E-Stop (in the “General Settings” tab of the Basicmicro Motion Studio software), but nothing is connected to S3. So, you might try changing the mode of that pin to “Disabled”.
If that doesn’t help, could you run your Arudino program while monitoring the “Device Status” tab of the software and seeing if any problems are reported there?
Brandon