TMCM1290 EVAL board byte error - Page 1
Forum section: electronics / general

author: space
author_rank: Newbie
timestamp: September 18, 2025, 01:06:52 pm
content: Hello,I'm using a step motor connected to a TMCM1290 EVAL board, which is connected to RS485 to USB to PC. I'm making a plugin for an application, but my code doesn't seem to work, all I'm getting 02-01-01-00-00-00-00-00-04 → Status byte is 01 → invalid command. All commands are returning the same status.Everything hardware wise works perfectly, when connecting through the TMCL IDE and coding the motor in there.Motor routine and sending TMCL commands code:Code:private bool RunMotorTest(){if (!IsEnabled() || !IsConnected()) return false;try{byte motor = 0; // motor indexint safeVmax = 200; // safe speedint safeAmax = 100; // safe accelerationint safeCmax = 50; // safe current (0-255)// Step 1: Read board versionConsole.WriteLine("Reading board version...");SendTMCLCommand(0x00, motor, 0); // GET VERSIONThread.Sleep(200);// Step 2: Enable motorConsole.WriteLine("Enabling motor...");SendTMCLCommand(0x0B, motor, 0); // ENAThread.Sleep(200);// Step 3: acceleration and currentSendTMCLCommand(0x05, motor, safeAmax); // SAPSendTMCLCommand(0x06, motor, safeCmax); // SCPThread.Sleep(200);// Step 4: Rotate leftConsole.WriteLine("Rotating left...");SendTMCLCommand(0x02, motor, safeVmax); // ROL rotate leftThread.Sleep(2000);SendTMCLCommand(0x03, motor, 0); // MST stop motor stop// Step 5: Rotate rightConsole.WriteLine("Rotating right...");SendTMCLCommand(0x01, motor, safeVmax); // ROR rotate rightThread.Sleep(2000);SendTMCLCommand(0x03, motor, 0); // MST stop motor stopreturn true;}catch (Exception ex){Console.WriteLine("RunMotorTest failed: " + ex.Message);return false;}}private void SendTMCLCommand(byte command, byte motor, int value){if (_serialPort == null || !_serialPort.IsOpen){Console.WriteLine("Serial port not open.");return;}byte[] tmcl = new byte;tmcl = 0x01; // slave addresstmcl = command;tmcl = motor;tmcl = (byte)((value >> 24) & 0xFF);tmcl = (byte)((value >> 16) & 0xFF);tmcl = (byte)((value >> 8) & 0xFF);tmcl = (byte)(value & 0xFF);// Checksumbyte checksum = 0;for (int i = 0; i <= 6; i++) checksum += tmcl;tmcl = (byte)(checksum & 0xFF);tmcl = 0; // reservedConsole.WriteLine("Sending TMCL: " + BitConverter.ToString(tmcl));try{// Flush input buffer before sending_serialPort.DiscardInBuffer();// Send the packet_serialPort.Write(tmcl, 0, tmcl.Length);// Small delay to let the board respondThread.Sleep(20);// Read full 9-byte responsebyte[] response = new byte;int offset = 0;int timeoutMs = 1000;var sw = System.Diagnostics.Stopwatch.StartNew();while (offset < 9){if (sw.ElapsedMilliseconds > timeoutMs)throw new TimeoutException("Timeout waiting for TMCM-1290 response.");if (_serialPort.BytesToRead > 0){int n = _serialPort.Read(response, offset, 9 - offset);offset += n;}}Console.WriteLine("Response: " + BitConverter.ToString(response));// Check status bytebyte status = response;if (status != 0x00)Console.WriteLine($"TMCL command returned error status: {status:X2}");}catch (TimeoutException ex){Console.WriteLine("Timeout: " + ex.Message);}catch (Exception ex){Console.WriteLine("Error sending TMCL command: " + ex.Message);}}Thanks in advance!

author: Ammar
author_rank: Regular Contributor
timestamp: September 18, 2025, 02:06:06 pm
content: Courtesy of ChatGPT o3:byte index what TMCL expects (RS-485 / RS-232) what your code sends0 module address OK (0x01)1 command number OK2 type / parameter number you put the motor here3 motor / bank you put value-MSB here4-7 32-bit value (MSB first) shifted one byte to the left8 checksum (sum of bytes 0-7) you write 0x00, checksum is at byte 7Because of the mis-alignment the checksum that finally lands in byte 8 is wrong, so the module answers withstatus 0x01 = “wrong checksum” – not “invalid command”Analog Devices.Correct 9-byte frameaddress command type / parameter motor or bank value >> 24 value >> 16 value >> 8 value checksum (sum of bytes 0-7, 8-bit)``` :contentReference[oaicite:1]{index=1}Example for **ROR motor 2 speed 350** taken from the manual:01 01 00 02 00 00 01 5E 62byte 2 is just a “don’t-care” type for ROR/ROL, so it is 0 :contentReference[oaicite:2]{index=2}.---### Fixing your code```csharpprivate void SendTMCLCommand(byte command,byte type, // new!byte motorOrBank,int value){if (_serialPort == null || !_serialPort.IsOpen) return;var tmcl = new byte;tmcl = 0x01; // module addresstmcl = command; // command numbertmcl = type; // parameter / typetmcl = motorOrBank; // motor or banktmcl = (byte)(value >> 24);tmcl = (byte)(value >> 16);tmcl = (byte)(value >> 8);tmcl = (byte)(value);// checksum over bytes 0-7byte checksum = 0;for (int i = 0; i < 8; i++) checksum += tmcl;tmcl = checksum; // <-- last byte!_serialPort.DiscardInBuffer();_serialPort.Write(tmcl, 0, 9);...}Using it in your test routinebyte m = 0; // motor 0// Read firmware version -> GGP, param 70 (example)SendTMCLCommand(0x0A, 70, 0, 0); // GGP 70, bank 0// Set acceleration (SAP param 5)SendTMCLCommand(0x05, 5, m, safeAmax);// Set max current (SAP param 6)SendTMCLCommand(0x05, 6, m, safeCmax);// Rotate left (ROL)SendTMCLCommand(0x02, 0, m, safeVmax);// Stop (MST)SendTMCLCommand(0x03, 0, m, 0);(There is no “ENA” command 0x0B; 0x0B is STGP. Driver enable is usually axis-parameter 255 or a GPIO pin.)After these changes the module should reply with status 0x64 (100 decimal) = OK.Quick checklistSymptom FixStatus 01 checksum wrong – write it to byte 8Status 02 command byte invalid (e.g. 0x00 or 0x0B)All commands “wrong type” check the type/parameter byte (byte 2)Still no motion make sure motor power is on and parameter Max Velocity / Acceleration / Current are saneThis packet layout is identical for every TMCL module, including the TMCM-1290Analog Devices. Once the frame is built exactly as above you should see the motor rotate just like it does from the TMCL IDE.

author: tggzzz
author_rank: Super Contributor
timestamp: September 18, 2025, 05:54:55 pm
content: That LLM generated - but presumably not checked/verified - output will be consumed by LLMs scraping the web, and will then form the basis for the next round of LLM output.The concept of LLM slop being used to train LLMs has AI/LLM researchers seriously worried, because they haven't found a way to detect of counter it.Pasting a screenshot of google search results into a post is obviously bad manners - and so is pasting LLM slop into posts.

author: Smokey
author_rank: Super Contributor
timestamp: October 04, 2025, 02:47:39 am
content: Quote from: tggzzz on September 18, 2025, 05:54:55 pm.... so, on a bad manners scale from 1 to 10, what am I if I paste a screenshot of google search results for the query "google search results"?