Open nicksauerwein opened 6 years ago
TrinamicException
instances are raised when the controller module responds to a command, but with a non-success status code. This implies that the python code is functioning properly, but that the module is unwilling to execute the command (however I can't hypothesise as to why at this time).
Response status codes are mapped in accordance with the TMCL docs (http://www.mctechnology.nl/pdf/TMCL_reference_2015.pdf#page=7) .
I assume the purpose of multiple high-speed calls to the rotate_right
command are to change the speed of the motor while it is rotating. The rotate_right
method maps to TMCL command ROR
which is described in the docs as follows:
Internal function: First, velocity mode is selected. Then, the velocity value is transferred to axis parameter #0 ("target velocity").
It might be that repeated high-speed attempts to put the module into 'velocity mode' is what is causing the issue (I'm totally guessing here though). You could try calling ROR
only once when motion starts, and then on successive calls update the 'target velocity' axis parameter directly instead.
It seems that every second call I get this error. But the strange thing is that the motor reacts as expected. This error actually arises in all functions that I call. (STOP, ROL, ROR, ...)
I solved this issue. The problem arises when more then one motor is connected. When you send a message at one motor, all the motors are answering. The status byte of the messages of the wrong motors is always 4 ('wrong value'). I modified the bus class so is works fine now.
checksum = self._binaryadd(address, command, type, motorbank, value)
msg = struct.pack(MSG_STRUCTURE, address, command, type, motorbank, value, checksum)
self.serial.write(msg)
while True:
rep = self.serial.read(REPLY_LENGTH)
if len(rep) < 9:
raise ValueError('increase the waiting time!!!')
reply = Reply(struct.unpack(REPLY_STRUCTURE, rep))
if reply.status == 100 and reply.module_address != address:
raise ValueError('two messages interfered: only send one message at the time!')
if reply.module_address == address:
break
#print ('Status: ',reply.status, 'Motor: ',reply.module_address,'Command: ',reply.command,'Value: ',reply.value)
time.sleep(0.01)
return self._handle_reply(reply)
When calling some functions the motor reacts as accepted, but the code trows an error.
For example:
but if I call it again several times I sometimes get:
This seems to be a timing issue.
Thanks for your help.