Position control by serial

General discussion of the MCP motion controller product line
Post Reply
fausto.tromba
Posts: 37
Joined: Wed Jul 31, 2019 7:24 am
Position control by serial

Post by fausto.tromba »

I configured the PID position control by BasicMicro. Moving the Control in the software all works, and the Motor moves in the position wished.

speed_P = 5.73
speed_I = 0.697
speed_D = 0
QPPS = 5960 (3350 rpm)

pos_P = 20
pos_P = 0.1
pos_P = 0
Deadzone = 50

Using the serial commands in the library (SpeedDistanceM1 and SpeedAccelDistanceM1) I have not the same behaviours. See the table. For SpeedAccelDistanceM1 the acceleration is calculated v*v/(2a)


What is wrong?
Attachments
Unbenannt.PNG
Unbenannt.PNG (8.54 KiB) Viewed 7846 times
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Position control by serial

Post by Basicmicro Support »

You need to convert the decimal values into fixed point numbers as defined in the user manual. Note that the velocity and position PID settings use different fixed point multipliers.

Also the Distance commands do no use the Position PID at all. Distance commands only use the velocity PID and you must send two distance commands to make a proper point to point movement. If you only send a single distance command it will finish with a non-zero velocity and then the controller will automatically slow to a stop in 1 second. This is explained in this post: viewtopic.php?f=2&t=46&p=158&hilit=calc ... tance#p158

Position commands are the only commands that use the position PID control(eg M1SpeedAccelDecelPosition ...)
fausto.tromba
Posts: 37
Joined: Wed Jul 31, 2019 7:24 am
Re: Position control by serial

Post by fausto.tromba »

Can you please specify the subject of "You need to convert the decimal values into fixed point numbers as defined in the user manual. Note that the velocity and position PID settings use different fixed point multipliers.". Where?

About the distance command, I used also M1SpeedAccelDecelPosition without any success.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Position control by serial

Post by Basicmicro Support »

Actually, I must correct myself. If you are using the Arduino or Python library you do provide floating point values and the library converts the values to fixed point. See the underlying code for the conversion.

I'll need to see your code to determine why you are getting different results from setting them in Motion studio vs in your code.

Please provide the simplest example that shows the problem you are experiencing.
fausto.tromba
Posts: 37
Joined: Wed Jul 31, 2019 7:24 am
Re: Position control by serial

Post by fausto.tromba »

I have found the error.
Sometimes the motor didn't run anymore because the error "M1 Position Error Limit" came up.
I didn't find any documentation about it. To avoid this error I increase the "Error Limit". I didn't find any documentation about it, either.

Can you please explain to me what are?
Attachments
ErrorLimit.PNG
ErrorLimit.PNG (6.14 KiB) Viewed 7837 times
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Position control by serial

Post by Basicmicro Support »

I see the confusion. Ignore my previous posts. I misunderstood your problem.

The problem is the commands you are using(Distance commands) use Velocity PID only. You need to use Position commands which will use the position PID settings.

Switch to one of the three position commands(m1, m2 or mixed) and you should be able to reproduce the movements you made in Motion Studio.

If you really want to use distance commands let me know. It is more complex but for some applications, it makes more sense. Distance commands do no make a point to point movement. They move a specific distance at a velocity with an initial accel/decel. If you do not chain at least two distance commands together, the second command being a move to 0 speed, your distance will be longer than expected because the motor controller will automatically add a slow down to 0 speed in 1 second if the end speed of the chain of distance commands is not 0.
fausto.tromba
Posts: 37
Joined: Wed Jul 31, 2019 7:24 am
Re: Position control by serial

Post by fausto.tromba »

I have used the command SpeedAccelDeccelPositionM1(). Now all is fine.
Sometimes the motor driver went in error: M1 Position Error Limit. In the manual, I don't' find any explanation about it. The same for Error Limit.

I just noticed that increasing Error Limit, the Position Error Limit Error decrease the chance to come up.
Given that I would like to know, what I'm doing, Can you explain to me them?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Position control by serial

Post by Basicmicro Support »

You shouldn't set an error limit unless you read the functionality. Error Limit should default to off(0).

The Position Error Limit sets how much error there can be between the instantaneous target position and the actual encoder position. To use it you MUST use accel/decel settings. Otherwise the instantaneous error will be very high when you start a move(motors dont accelerate instantaneously).

Also, if your PID settings are not very good the Error Limit will help catch/diagnose the problem.

The Position Error Limit is in encoder counts.

Post Reply