Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change speed whilst the motor is moving. #4

Open
AndyThirtover opened this issue Jul 20, 2019 · 1 comment
Open

Cannot change speed whilst the motor is moving. #4

AndyThirtover opened this issue Jul 20, 2019 · 1 comment

Comments

@AndyThirtover
Copy link

AndyThirtover commented Jul 20, 2019

Consider:

print("Set speed to 40")
mot.updateSettings({'maxrpm':40})
time.sleep(1) # in case it takes time to make a difference
print("Goto 10")
mot.async_goto(10)
while mot.are_we_there_yet() != 0:
time.sleep(0.05)

print("STOPPED - SPEED CHANGE ON THE FLY")
print("Set speed to 80")
mot.updateSettings({'maxrpm':80})
print("Goto 50")
mot.async_goto(50)

time.sleep(5)
print("Set speed to 160")
mot.updateSettings({'maxrpm':160})

In the first case the speed change is safe. In the second case the speed change causes the motor to squeal but not move. There is a little movement after about 0.5 second.

It is possible that the chip has to do a pile of calculations when speed is changed and during this time it does not service the motor.

It is more probable that I've misunderstood what updateSettings actually does.

I expected to see something like: self.md.readWriteMultiple(regsettings,regactions)
Where VMAX would get written to the register.

Regards

Andy

@AndyThirtover
Copy link
Author

Here's how I got it to work:

def set_speed(speedval):
    regsettings=OrderedDict((
        ('A1', 12000),
        ('V1', 4000),
        ('AMAX', 20000),
        ('VMAX', speedval),
        ('DMAX', 9000),
        ('D1', 600)
         ))
    regactions='WWWWWW'
    assert len(regsettings)==len(regactions)
    currently=mot.md.readWriteMultiple(regsettings,regactions)

Once again crude - but I shall think about it some more.

Regards

Andy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant