pootle / tripipy

Simple python driver for Trinamic tmc5130 connected to Raspberry Pi
The Unlicense
37 stars 14 forks source link

Q: Two motors #11

Open SCiunczyk opened 4 years ago

SCiunczyk commented 4 years ago

Hi,

I have working "Pi HAT" now - both drivers are working perfectly on RPi4 . As I'm not very strong in python .... yet ;-) I'm not sure what is the best approach to have two channels working on this same time. It's possible to pass parameters to chipdrive.tmc5130 constructor? I mean something like this

motorpan=chipdrive.tmc5130(drvenpin=12, spiChannel=1) motortilt=chipdrive.tmc5130(drvenpin=24, spiChannel=0)

Thanks for your indulgence.

Slawek

IMAG1778

IMAG1779

pootle commented 4 years ago

Well done. Yes you're right - those parameters should give you control of the 2 motors.

SCiunczyk commented 4 years ago

Just that simple ??? Wow! Thanks.

I will try tomorrow morning. Now is to risky ;-) I'm a little bit tired.

SCiunczyk commented 4 years ago

Hi @pootle, what is the propoer syntax that should I use to create two motors with two different names and two different drvenpin and spiChannel?

When I try to use in motors2.py construction:

motorpan=motorPanel(motor=chipdrive.tmc5130(drvenpin=12, spiChannel=1), gridx=1, pfields=pfields, panel=mpanel)

I get: TypeError: init() got an unexpected keyword argument 'drvenpin'

SCiunczyk commented 4 years ago

I know that I should learn the lesson "Python class constructor (default) parameters " ;-)

pootle commented 4 years ago

Ah! silly code - the params aren't getting passed through - and I haven't got a test rig running just now.

I can put a couple of edits into github, but can't test them just now....

SCiunczyk commented 4 years ago

Heheheh maybe I'm not so stupid as I was thinking.

I will test. The hardware is on my desk now.

I'm in the middle of this article: http://www.memonic.com/user/pneff/folder/python/id/1tHgm now.

SCiunczyk commented 4 years ago

I mean I will test any changes if you will find time to make them.

pootle commented 4 years ago

I've done the updates - not been able to test though - give it a go.

SCiunczyk commented 4 years ago

I can confirm - it works as expected. Many thanks for your effort. I'm surprise how smooth the driver power motors.

Now I'm programming two motors demo. When will be ready I'll share it with you.

One more question: In chipdrive.py line 136 you are using: name='fred' If we have more than one motor maybe we should use separate names ? Or it doesn't matter at all because is inside the object?

Have nice evening and thanks again.

pootle commented 4 years ago

name is used for log messages, so not vital, but helps if it is different.

These chips are really great at driving steppers - but getting all the reg settings right to get the best from the motor can take a while.

Enjoy!

SCiunczyk commented 4 years ago

So probably we can close the issue. What do you think about making the name "passed through" parameter as well ?