Forum

How do you switch b...
 
Notifications
Clear all

[Solved] How do you switch between Speed and Position mode while the motor controller is running?

6 Posts
2 Users
0 Reactions
409 Views
Forum 1
(@baymax)
Eminent Member
Joined: 1 year ago
Posts: 12
Topic starter  

I am using the solo mini v2 with SoloPy = 3.1.0.

So I am sending speed commands in speed control mode, that part is working.

But in my code I need to switch back to Position control mode in order to reach the home encoder position 0, no matter what the encoder position is.
The process I use to switch is:

  1. Use the 0x16 command "set_control _mode" to "solo.CONTROL_MODE.POSITION_MODE"
  2. Use the 0x11 command "set_speed_limit" to a reasonable value (300) to sets the allowed speed during trajectory following in closed-loop position controlling mode
  3. Send target position using the 0x1B command "set_position_reference".

My problem is that I cannot get the motor to go to the encoder position I want.

When I power cycle and run only position control code, it runs, no problem. When I run speed commands only, it runs, no problem. I even have a piece of code where I start in position mode, do some stuff, then switch back to speed mode and send instructions, no problem.

I added print statements everywhere and I am checking the returned boolean associated with each command call. It seems like that the command to set the target is sent and that all the above commands are sent correctly.

The problem seems to happen somehow on the solo side, like something going on due to that transition Speed mode to Position mode.

Any idea what could cause this behavior?


   
SOLO Team
(@milad)
Illustrious Member Admin
Joined: 4 years ago
Posts: 603
 

Hi @baymax,

To switch back from Speed mode to position mode a safe process will be:

1- Before doing any action, look at the Position feedback ( the number of pulses) and save it somewhere ( counted_pulses) 

2- Set the Position reference equal to counted_pulses ( like this once you switch to position mode, as the position reference is not set, or maybe it's zero, the controller will go back to zero, but you want the controller to stay in position)

3- Switch the command mode to Position Mode

4- Apply the desired positions

The steps 1,2,3 are better to be taken with minimum delay in between or instantaneously so the motor doesn't move far from where you measure the 1st step.

This should work, and let me know if you have any questions, you can also share the code with us for this part to have a look at it.

Milad

 

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.


   
Forum 1
(@baymax)
Eminent Member
Joined: 1 year ago
Posts: 12
Topic starter  

Hi Milad and thanks for the reply.

That was a good suggestion and I updated my code accordingly.

I found the origin of the problem. I used the command 0x11 set_speed_limit (in position control mode) with a very small speed like 5 rpm. I am using a motor that can go up to 2000 rpm. I assume the PID couldn't really do much with such limited margin. It is working much better now.

Thanks!


   
SOLO Team
(@milad)
Illustrious Member Admin
Joined: 4 years ago
Posts: 603
 

@baymax ,

Ok, great, and thanks for letting me know.

Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.


   
SOLO Team
(@milad)
Illustrious Member Admin
Joined: 4 years ago
Posts: 603
 

Btw,

Posted by: @baymax

with a very small speed like 5 rpm

You can actually achieve that speed ( if you use Incremental Encoders), but the tuning of the Speed PI controller will be different, especially for Kp, in low-speed cases usually the Kp will be much higher, you can also tune the speed controller Kp and Ki on the fly for low speed or high-speed operations.

Milad

 

If you found the answers helpful and you could solve your problems, please kindly verify here to help others in the future.


   
Forum 1
(@baymax)
Eminent Member
Joined: 1 year ago
Posts: 12
Topic starter  

@milad 

Thanks for the tip. It's noted.


   
Share: