Package org.deepjava.runtime.mpc555.sysp
Class SpeedController4DCMotor
- java.lang.Object
-
- org.deepjava.runtime.mpc555.sysp.SpeedController4DCMotor
-
public class SpeedController4DCMotor extends Object
Speed controller (PI control) for DC motor.
This controller uses two channels of the time processor unit and operates in sign-magnitude mode.
IMPORTANT: The motor and the encoder have to be connected carefully. A positive speed control must lead to a positive speed reading. If this is not the case you have to change either the connections to the motor or the signals of the encoder (but not both!).
-
-
Constructor Summary
Constructors Constructor Description SpeedController4DCMotor(float ts, int pwmChannel1, int pwmChannel2, boolean useTPUA4PWM, int encChannelA, boolean useTPUA4Enc, int encTPR, float umax, float i, float kp, float tn)
Create a new speed controller for a DC motor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
getActualPosition()
Returns the current absolute position.float
getActualSpeed()
Returns the current speed.void
run()
Controller task method.void
setDesiredSpeed(float v)
Set desired speed.
-
-
-
Constructor Detail
-
SpeedController4DCMotor
public SpeedController4DCMotor(float ts, int pwmChannel1, int pwmChannel2, boolean useTPUA4PWM, int encChannelA, boolean useTPUA4Enc, int encTPR, float umax, float i, float kp, float tn)
Create a new speed controller for a DC motor.- Parameters:
ts
- task period in seconds [s]pwmChannel1
- TPU channel for the first PWM signal.pwmChannel2
- TPU channel for the second PWM signal.useTPUA4PWM
- Time processing unit to use for PWM signals: true for TPU-A and false for TPU-B.encChannelA
- TPU channel for the encoder signal A. For the signal B the channel of A + 1 will be used.useTPUA4Enc
- Time processing unit to use for FQD: true for TPU-A and false for TPU-B.encTPR
- impulse/ticks per rotation of the encoder.umax
- maximum output voltage of set value.i
- gear transmission ratio.kp
- controller gain factor. For experimental evaluating the controller parameters, begin with kp = 1.tn
- time constant of the controller. For experimental evaluating the controller parameters, set tn to the mechanical time constant of your axis. If the motor has a gear it's assumed that the torque of inertia of the rotor is dominant. That means you can set tn equals to the mechanical time constant of your motor.
-
-
Method Detail
-
run
public void run()
Controller task method. Call this method periodically with the given period time (ts)!
-
setDesiredSpeed
public void setDesiredSpeed(float v)
Set desired speed.- Parameters:
v
- desired speed in radian per second [1/s]
-
getActualSpeed
public float getActualSpeed()
Returns the current speed.- Returns:
- current speed in radian per second [1/s]
-
getActualPosition
public float getActualPosition()
Returns the current absolute position.- Returns:
- absolute position in radian
-
-