BrickPi3 set_motor_position speed?

Hey there, just a quick question:
Can I set the speed while setting a position?

BP.set_motor_position(BP.PORT_A, 1000 [degrees])

Where would the speed fit in there? I currently am programming the arm of my Bobcat and can’t have it going up and down with speed set to 100.
Thanks!

I don’t have a BrickPi3 but from examining the code I would try inserting a call to:

BP.set_motor_dps(BP.PORT_A, target)     # set the target speed for motor A in Degrees Per Second

before your call to:

BP.set_motor_position(BP.PORT_A, 1000 [degrees])

-Kevin

2 Likes

more useful info on this topic here:
https://forum.dexterindustries.com/t/solved-relationship-between-set-motor-power-set-motor-dps-and-set-motor-limits/5196/3

Hmm, interesting. Putting the BP.set_motor_dps... in front of the position command makes it very weird, running very slowly when not called and when called it doesn’t do what you said above. But thanks anyway for the help.

Sorry for the bad info.

Try this code:

# turn degrees
TargetDegrees = 180

# seconds to reach target
TimeToTarget = 6

# degrees per second
DegreesPerSecond = TargetDegrees / TimeToTarget

# read the starting position
StartingPosition = BP.get_motor_encoder(BP.PORT_A)

# add target rotation to starting position to get absolute target
FinalPosition = StartingPosition + TargetDegrees

# set the DPS limit
BP.set_motor_limits(BP.PORT_A, dps = DegreesPerSecond)

# set the absolute target
BP.set_motor_position(BP.PORT_A, FinalPosition)

From @Matt (Dexter Industries Engineer) in this post: https://forum.dexterindustries.com/t/rotating-motor-certain-angle-in-a-certain-amount-of-time/4823/2

-Kevin

3 Likes

Thank you so much. It works! :smile:

1 Like