Wheel Motor: Unterschied zwischen den Versionen
(→Wiring) |
(→Programming) |
||
Zeile 47: | Zeile 47: | ||
= Programming = | = Programming = | ||
− | / | + | == Motor variable == |
+ | |||
+ | // --------- wheel motor state ---------------------------- | ||
+ | // wheel motor speed ( <0 backward, >0 forward); range -motorSpeedMaxRpm..motorSpeedMaxRpm | ||
+ | float motorAccel ; // motor wheel acceleration (warning: do not set too high) | ||
+ | int motorSpeedMaxRpm ; // motor wheel max RPM | ||
+ | int motorSpeedMaxPwm ; // motor wheel max Pwm (8-bit PWM=255, 10-bit PWM=1023) | ||
+ | float motorPowerMax ; // motor wheel max power (Watt) | ||
+ | PID motorLeftPID; // motor left wheel PID controller | ||
+ | PID motorRightPID; // motor right wheel PID controller | ||
+ | float motorSenseRightScale ; // motor right sense scale (mA=(ADC-zero)/scale) | ||
+ | float motorSenseLeftScale ; // motor left sense scale (mA=(ADC-zero)/scale) | ||
+ | int motorRollTimeMax ; // max. roll time (ms) | ||
+ | int motorRollTimeMin ; // min. roll time (ms) | ||
+ | int motorReverseTime ; // max. reverse time (ms) | ||
+ | long motorForwTimeMax; // max. forward time (ms) / timeout | ||
+ | float motorBiDirSpeedRatio1 ; // bidir mow pattern speed ratio 1 | ||
+ | float motorBiDirSpeedRatio2 ; // bidir mow pattern speed ratio 2 | ||
+ | bool motorRightSwapDir ; // inverse right motor direction? | ||
+ | bool motorLeftSwapDir ; // inverse left motor direction? | ||
+ | int motorLeftSpeedRpmSet ; // set speed | ||
+ | int motorRightSpeedRpmSet ; | ||
+ | float motorLeftPWMCurr ; // current speed | ||
+ | float motorRightPWMCurr ; | ||
+ | int motorRightSenseADC ; | ||
+ | int motorLeftSenseADC ; | ||
+ | float motorLeftSenseCurrent ; | ||
+ | float motorRightSenseCurrent ; | ||
+ | float motorLeftSense ; // motor power (range 0..MAX_MOTOR_POWER) | ||
+ | float motorRightSense ; | ||
+ | int motorPowerIgnoreTime; | ||
+ | int motorZeroSettleTime; // how long (ms) to wait for motor to settle at zero speed | ||
+ | int motorLeftSenseCounter ; // motor current counter | ||
+ | int motorRightSenseCounter ; | ||
+ | unsigned long nextTimeMotorSense ; | ||
+ | unsigned long lastSetMotorSpeedTime; | ||
+ | unsigned long motorLeftZeroTimeout; | ||
+ | unsigned long motorRightZeroTimeout; | ||
+ | boolean rotateLeft; | ||
+ | unsigned long nextTimeRotationChange; |
Version vom 6. Dezember 2015, 19:33 Uhr
Inhaltsverzeichnis
Wheel motors caracteristics & driver
The two left and right gear motors are controlled independently (aka 'differential driving') to:
- drive the robot forward/backward
- steer the robot left/right
The Ardumower wheel motor features:
- A rotation speed up to 31 rpm allows to move the robot at sufficient speed (at up to meter/sec = 31rpm/60 * PI * 0.25m = 0.4m/sec using 250mm diameter wheels)
- A high torque (2.45Nm) guarantees that the robot can climb small hills as well (with 2 motors, 0.125 radius wheel, 31rpm = 0.4m/s, acceleration = 0.2 ( 1/2 of nomeinal speed) up to 14 degree) see calculator
- Integrated encoders, so it can measure the rotation speed, the distance and the direction (see Odometry for more information) - Encoders are REQUIRED for Ardumower software.
- 24V (load current ~1A)
Wiring
One pin controls the direction (forward/backward), the other pin controls the speed. One analog input pin is connected to the current sensor. The current sensor module (ACS712-05A) is connected in series with the motor.
NOTE: only for demonstration! See real schematics for concrete wiring
Protector board is adviced to be used between controler and motor.
Control principal : PWM frequency
The speed of the motor is controlled by a PWM duty signal. We use the Arduino default PWM frequency (490 Hz) to control the motor drivers.
Motor controller (PID)
The speed of the motors is controlled by a software PID controller. You can monitor the quality of the motor speed control via pfodApp (Plot->Motor control):
Programming
Motor variable
// --------- wheel motor state ---------------------------- // wheel motor speed ( <0 backward, >0 forward); range -motorSpeedMaxRpm..motorSpeedMaxRpm float motorAccel ; // motor wheel acceleration (warning: do not set too high) int motorSpeedMaxRpm ; // motor wheel max RPM int motorSpeedMaxPwm ; // motor wheel max Pwm (8-bit PWM=255, 10-bit PWM=1023) float motorPowerMax ; // motor wheel max power (Watt) PID motorLeftPID; // motor left wheel PID controller PID motorRightPID; // motor right wheel PID controller float motorSenseRightScale ; // motor right sense scale (mA=(ADC-zero)/scale) float motorSenseLeftScale ; // motor left sense scale (mA=(ADC-zero)/scale) int motorRollTimeMax ; // max. roll time (ms) int motorRollTimeMin ; // min. roll time (ms) int motorReverseTime ; // max. reverse time (ms) long motorForwTimeMax; // max. forward time (ms) / timeout float motorBiDirSpeedRatio1 ; // bidir mow pattern speed ratio 1 float motorBiDirSpeedRatio2 ; // bidir mow pattern speed ratio 2 bool motorRightSwapDir ; // inverse right motor direction? bool motorLeftSwapDir ; // inverse left motor direction? int motorLeftSpeedRpmSet ; // set speed int motorRightSpeedRpmSet ; float motorLeftPWMCurr ; // current speed float motorRightPWMCurr ; int motorRightSenseADC ; int motorLeftSenseADC ; float motorLeftSenseCurrent ; float motorRightSenseCurrent ; float motorLeftSense ; // motor power (range 0..MAX_MOTOR_POWER) float motorRightSense ; int motorPowerIgnoreTime; int motorZeroSettleTime; // how long (ms) to wait for motor to settle at zero speed int motorLeftSenseCounter ; // motor current counter int motorRightSenseCounter ; unsigned long nextTimeMotorSense ; unsigned long lastSetMotorSpeedTime; unsigned long motorLeftZeroTimeout; unsigned long motorRightZeroTimeout; boolean rotateLeft; unsigned long nextTimeRotationChange;