2024-03-22 02:35 PM
Hi,
I am trying to understand the protocol, especially how to interpret the data packets to have custom code for auto motor ramp-up.
I see there are some documents under MC workbench -> About. However, I still cannot find the details about the data packet structure.
For instance: Upon executing a sample project through MC Workbench, Cubemx, and CubeIDE, and subsequently initiating the motor using Pilot. I observed the initial packet captured from the UART TX pin as 0x05, 0xC3, 0x00, 0xD4(using a logic analyzer). I speculate this to be a beacon, as indicated by beacon 0x05 from aspep.h, and the Motor Control Protocol Suite documentation mentions the initialization of a beacon from the host. Despite this, I've been unable to locate any documentation detailing the composition of the other three bytes or any specifics regarding the structure of the data packet. The SDK is very complicated as well. It takes too long to understand what each packet means.
[VERSION]: MCSDK 6.2.1
[TOOL]: MCSDK, STM32CUBEMX, STM32CUBEIDE, Pilot from MCSDK
Thanks
Solved! Go to Solution.
2024-03-29 12:03 PM
2024-03-26 05:22 PM - edited 2024-03-26 05:22 PM
The document "Motor Control Protocol Suite" under the help you mentioned contains (almost) all the details needed to build the communication protocol in Arduino. Yes, it is complicated, but that is the cost of a robust and versatile system.
The protocol essentially multiplexes a serial port into 3 channels, a control channel (for maintaining the connection), a sync channel (for sending commands), and an async channel (for sending oscilloscope-like readings). Your first step is to learn and understand how to send and receive Beacon and Ping packets to initialize the connection. Until this connection is made, you cannot do anything else.
You then need to be able to send request packets, and interpret response packets. The payload of the request and response packets is the commands listed under command service. These request and response packets make up the synchronous channel. A good first command to try is GET_MCP_VERSION, as it consists only of the command and no additional data.
I am several weeks into making a C# implementation of Motor Pilot. It's certainly a journey. So far, I have identified several discrepancies.
1: CRC polynomial used for the headers is 0b10111, not 10011.
2: Generated code (at least for FOC) doesn't properly generate ping packets for anything other than a ping packet indicating a last sync packet of 0. There is an error in the generated code, that I explain here.
Bug Report - ASPEP Protocol Ping Packets - STMicroelectronics Community
So far, I am able to initialize the connection, and read some registers. That's about it.
Good luck to you.
2024-03-27 09:14 PM
2024-03-27 09:15 PM
2024-03-29 12:03 PM
2024-04-03 09:55 AM
Hi @ccut93 ,
Thanks for answering.
I agree with your answer, the ID 6 of RAW Structure is defined as MC_REG_SPEED_RAMP
#define MC_REG_SPEED_RAMP ((6U << ELT_IDENTIFIER_POS) | TYPE_DATA_RAW)
The size is indeed 6 bytes. 4 bytes for coding the speen in rpm, and 2 bytes for coding the duration.
This register does not exist in HSO flavor.
Regarding the duplication of motor number, it is mainly due to the fact that we need in some cases to fully defined the register, for instance when we configure the Datalog.
Regards
Cedric
2024-04-03 10:03 AM
Hi Cedric,
Thanks for the confirmation. That is a milestone for my research and learning.
Do you know where I can find the register information you mention?
"
The size is indeed 6 bytes. 4 bytes for coding the speen in rpm, and 2 bytes for coding the duration.
"
Thanks
2024-04-04 05:51 AM
Hi,
All registers can be viewed from the STMotorPilot\RegisterList folder.
In your case you will find :
{
"Id": 6,
"Name" : "SPEED_RAMP",
"Description" : "Parameters of a speed ramp to apply to the motor",
"Type" : "RAWSTRUCTURE",
"Unit" : "",
"Access" : "RW",
"Scope": "Motor",
"Structure": [
"S32",
"U16"
]
}
For the detail of the structure, the best is to quickly look at the register_interface.c code:
case MC_REG_SPEED_RAMP:
{
int32_t rpm;
uint16_t duration;
rpm = *(int32_t *)rawData; //cstat !MISRAC2012-Rule-11.3
duration = *(uint16_t *)&rawData[4]; //cstat !MISRAC2012-Rule-11.3
MCI_ExecSpeedRamp(pMCIN, (int16_t)((rpm * SPEED_UNIT) / U_RPM), duration);
break;
}
Hope it helps.
Cedric
2024-10-08 02:26 PM
Thank you for the info @ccut93 . I've gotten the BEACON and PING packets to work and get connected to the MCU. But I can't get request packets to get a response.
Can you share any code you got working with the MCP? Or perhaps just some exchanges of RX/TX bytes so I can try sending individual commands?