makerbase-motor / mks-servo57d Goto Github PK
View Code? Open in Web Editor NEWMakerbase MKS SERVO57D NEMA23 closed loop stepper motor Driver FOC quiet and efficient RS485 / CAN
Makerbase MKS SERVO57D NEMA23 closed loop stepper motor Driver FOC quiet and efficient RS485 / CAN
I've been trying to use MKS SERVO42_CAN with an ESP32 but no ideia why I'm getting no response back. It looks like the commands are making to MKS, but not sure whether or not it was sent correctly.
I'm using the lib arduino-CAN.
Here it is the code I've been using:
#include <CAN.h>
#define SERVO_RX_PIN 16
#define SERVO_TX_PIN 17
void setup() {
CAN.setPins(SERVO_RX_PIN, SERVO_TX_PIN);
// start the CAN bus at 500 kbps
if (!CAN.begin(500E3)) {
Serial.println("Starting CAN failed!");
while (1)
;
} else {
Serial.println("CAN Initialized");
}
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
delay(3000);
}
void loop() {
sendCommand();
readResponse();
delay(1000);
}
void sendCommand() {
// CAN.beginPacket(1); // CAN ID
CAN.beginPacket(1, 2, false); // CAN ID, DLC, RTR
CAN.write(0x30); // function code
CAN.write(0x31); // CRC
CAN.endPacket();
}
void readResponse() {
unsigned long sTime; //timing start time
sTime = millis(); //get the current moment
while (1) {
// try to parse packet
int packetSize = CAN.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received ");
if (CAN.packetExtended()) {
Serial.print("extended ");
}
if (CAN.packetRtr()) {
// Remote transmission request, packet contains no data
Serial.print("RTR ");
}
Serial.print("packet with id 0x");
Serial.print(CAN.packetId(), HEX);
if (CAN.packetRtr()) {
Serial.print(" and requested length ");
Serial.println(CAN.packetDlc());
} else {
Serial.print(" and length ");
Serial.println(packetSize);
// only print packet data for non-RTR packets
while (CAN.available()) {
Serial.print((char)CAN.read());
}
Serial.println();
}
Serial.println();
}
if ((millis() - sTime) > 2000) { //Judging whether to time out
break; //timeout, exit while(1)
}
}
}
I appreciate any guidance.
Clear Speed mode command is sent (0xff, 0xca) the motor at first send response with data 0xff, 0x1 = Succes, which is OK.
But only when CanRSP is enabled, there is another can message with data 0xff, 0x2 which is not documented and it probably means Speed mode stop.
And now I see, the undocumented message is also sent when Save speed mode parameter is called. #4
Can you please add to this repository the modbus programs you published on Baidu please?
Why aren't you providing the firmware updates? I understand you may not want to share the code but can't you at least provide the compiled code so we can update the firmware?
Hi, Can you please add motor current to the modbus so we can get the motor running current. Thanks
Is it possible to change the position loops PID parameters? The previous S42C had a control tool available able to do this.
is there a Documentation for all usable Can commands as a table?
It is cumbersome to extract them from the manual
Is this project open source?
Are there plans to upload the source code here?
Can you supply links to an appropriate toolchain for the NATION controller and means to up/download software?
Regards,
Wolf
hi, i have 1.0.5 version of rs485 and i am having issues with responses.
i can calibrate the motor read the encoder and do all sort of things but when i try to move it in position mode or read the motor status i get half a response for example:
01 10 00 F5 00 04 08 00 64 00 00 00 00 00 00
returns:
01 10 00
thats it.
and when i try to read motor status:
01 04 00 F1 00 01
i get
01 04 00
please advise how to proceed
I have Mks servo 57D 1.0.4. Microstepping is set 16. Lock protection is enabled. Mplyer option is disabled. CanRSP is disabled. Motor mode SR_VFOC.
Test case:
What happens:
The motor is not able to fullfill the speed, is rotating on slower speed and the shaft angle error gradually increases. The stall indication error is not indicated and moreover, the motor is still moving even when the status returned is 1 = motor stop.
What should happen:
I think that from very big shaft error for a long time, Stall Error should be set and the status should never return stopped state when the motor is in fact still moving.
With slower speed or higher current, when the motor is able to follow the speed, everything work as expected, but would be nice to have stall indication to be more strict when the speed is for example manually changed by holding the shaft for some time.
Is this a new feature request or can you please provide an example of this with existing capability?
Allow writing a CAN object "motor group".
Only allow two or three motors per group to limit CAN traffic.
If motors belong to the same group, one motor becomes "leader" and transmits its axis position to "follower" motors in the same motor group.
Write config to one motor in the group leader and the rest followers.
If a motor is assigned follower, the motors must synchronize their position with the leader at all times. If they fail, they must tell the leader.
Allow sending position command to the leader motor in any individual group, and the follower motors will automatically follow the leader but be very close to identical position.
Is there a better way to do this?
Closed loop with the same MKS-SERVO57D works fine with <10Ohm motor (coil resistance) but calibration fails with 17Ohm motor with "Reverse Lookup Error". Open loop with the 17Ohm motor works as well. While I'm aware the manual states "Note: The motor internal resistance should be less than 10 ohms.", I don't quite get how the calibration of the sensor depends on it, given that open loop stepping works fine and the motor does move back and forth during the calibration procedure. Has anyone more information about the cause of the error (manual just says "check the shaft") or the <10Ohm limitation?
I find it little strange, that if you want to use speed mode after power up, you have to actually run the motor in speed mode and then call Save (0xff, 0xc8). But calling save also stops the motor!
It would be maybe better to either:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.