-
Notifications
You must be signed in to change notification settings - Fork 0
Class EncoderMotorL298
Hans Rothenbuehler edited this page Oct 22, 2023
·
2 revisions
| Topic | Specification |
|---|---|
| Description | This class controls a rotating drive. The motor is controlled with a L298N H-bridge. This is able to control up to 2 motors. It uses a digital and a PWM pin to control one motor. The digital pin defines the direction, the PWM the speed. Create two objects of this class to control both motors. An encoder motor has a rotary encoder to control the speed. The logic contains a PID regulator to hold the speed on the demanded value. Sketch Made EASY supports up to 6 encoders in a sketch. This means that up to 6 encoder motors can be operated at the same time. |
| Constructor |
EncoderMotorL298(int DirectionPin, int SpeedPin, int SensorAPin, int SensorBPin, int aPPR, int GearRatio, int MaxSpeed) Parameter DirectionPin: Digital (Out) PinSpeedPin: Digital (Out) Pin with PWMSensorAPin: Rotary Encoder A-SignalSensorBPin: Rotary Encoder B-SignalPPR: Pulses per Revolution of the rotary encoderGearRatio: GearRatio: Gear ration of the motorMaxSpeed: Sketch Made EASY includes an auto map from input to actuator. When set value to > 0, the map is active and maps speed to 0…MaxSpeed depending on the assigned input. When set value to 0, the logic takes the value of the input, assigned by a relation without map. |
| Range | 0…255 |
| Samples | EncoderMotorL298* encoderMotor = new EncoderMotorL298(12, 10, 3, 4, 7, 34, 0); |
| Examples | Test 40 |
| Advanced |
More encoder motors: Increase the const EASY_MAX_ENCODERS in the file “src\Kernel\RotaryEncoder.h” of the library. Plot: In the test are two #defines: define PLOT_ENCODERMOTOR and PLOT_ROTARYENCODER in the file “Common/BuildDefinition.h”. Uncomment one of them to plot with the Arduino IDE. ![]() PLOT_ENCODERMOTOR T: Target rotational speed [1/min]REr: Rotary encoder rotational speed [1/min]Ref: Filtered rotational speed (includes a low-pass filter) [1/min]CS: Calculated speed, set by PID<BRP: Proportional term P of the regulatorI: Integrates past term I of the regulatorD: Diverential future term D of the regulatorThere’s a constructor with the PID-factors (default 10/0/50): EncoderMotorL298 (int DirectionPin, int SpeedPin, int SensorAPin, int SensorBPin, int PPR, int GearRatio, int MaxSpeed, float KP, float KI, float KD) ![]() PLOT_ROTARYENCODER Pos: Pulse CounterRPMr: Rotational speed [1/min]RPMf: Filtered rotational speed (includes a low-pass filter) [1/min] |
Wiki
Getting started
Classes
Input
- Calculate
- ConditionInput
- DependentInput
- DigitalInput
- FixValue
- Inverter
- IteratorValue
- JoystickAxis
- LoopSwitch
- MonoFlop
- Switch2Position
- Switch3Position
- Timer
- ToggleSwitch
- UltrasonicRangefinder
- VariableInput
Actuator
- ActuatorCollection
- Buzzer
- DigitalOutput
- EncoderMotorI2C
- EncoderMotorL298
- EncoderMotorL9110
- MotorI2C
- MotorL298
- MotorL9110
- MotorStepperRotate
- MotorStepperRotateI2C
- Servo360I2C
- Servo360PWM
- Servo360T1
- Servo360T2
- ServoPWM
- ServoStepperPosition
- ServoStepperPositionI2C
- ServoI2C
- ServoT1
- ServoT2
- VariableOutput
Condition
Relation
RemoteControl
Common
Sketches
Templates
Examples
- 01-Switch and Lamp
- 02-Dimming LED
- 03-Dimming LED with Switch
- 04-Blinking LED
- 05‐Motor fix speed, direction‐switch
- 06‐Motor variable speed, direction‐switch
- 07‐Motor variable speed, direction‐ and main‐switch
- 08‐Motor toggles between limit switches
- 09‐Motor toggles between limit switches, main switch
- 10‐Main Motor turns between limit switches, second follows
- 11-Two motors, one turns after the other
- 12-Servo360 controlled by a Joystick
- 13-Stepper motor with variable speed
- 14-RemoteControl of a motor with FlySky FS-i6X
- 15-RemoteControl of a motor with an App
- 16-EncoderMotor and LED controlled by FlySky-RemoteControl
- 17-Servo position in relation to a potentiometer
- 18-Stepper angle controlled by joystick
- 19-Buzzer tone in relation to distance
- 20-Dependent input
- 21-Alternate blink

