analogdevicesinc / PyTrinamic

TRINAMIC's Python Technology Access Package.
Other
60 stars 36 forks source link

TMC5072_rotateDemo.py Indexing an integer #49

Closed stofe95 closed 3 years ago

stofe95 commented 3 years ago

TMC5072_rotateDemo.py does not work. In the TMC_5072 class each motor has a register attribute, but the rotateDemo script indexes the register as if there would be a pair of values (one for each motor).

As an example, the A register for each motor In rotateDemo it refers to the registers as shown here: TMC5072.writeRegister(TMC5072.registers.A1[DEFAULT_MOTOR], 1000)

But then I think that each register has it's own value (from TMC5072_register.py): A1_M1 = 0x24 A1_M2 = 0x44

I tried swapping the TMC5072.writeRegister(TMC5072.registers.A1[DEFAULT_MOTOR], 1000) to TMC5072.writeRegister(TMC5072.registers.A1_M1, 1000) and repeated this for each of the parameters being set on lines 28-34 and the script runs without error, but the motor is not moving. I also have a TMC5130 and the example script for that runs without error and rotates the motor.

edit: Actually I accidentally ran the example for the TMC5031 on my 5130 and that was what worked. If I run the example script for the 5130, it does not work. The example script for the 5031 also works on the 5072-eval board.

Lionheart1810 commented 3 years ago

This is already fixed with the structural rework in e1dbc44e8e162f056135041a232f9f2189d13fb0, which will be merged to master soon.