pootle / tripipy

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

goto(x,wait=False) Motor does not move, output disabled #3

Open AndyThirtover opened 5 years ago

AndyThirtover commented 5 years ago

Here's the goto function:

def goto(self, targetpos, wait=True):
    self.md.enableOutput(True)
    self.md.writeInt('XTARGET',int(self.ustepsPerRev*targetpos))
    if wait:
        self.wait_reached()
    self.md.enableOutput(False)

If wait is False the output is immediately disabled and hence the motor does not move

I've made another two functions:

def async_goto(self, targetpos):
    self.md.enableOutput(True)
    self.md.writeInt('XTARGET',int(self.ustepsPerRev*targetpos))

def are_we_there_yet(self):
    return self.md.readInt('XACTUAL') - self.md.readInt('XTARGET')

Although this works, I don't consider it elegant, perhaps the name of the second function should be diff_from_target.

Physical tests are showing the the motor and driver are not getting hot.

Regards

Andy

pootle commented 5 years ago

Well that was a silly mistake I made, but I hadn't tested more than the basics.

I'm going to update this software soon as I have a real project to use it on coming up, This current version is really just a proof of concept