pimoroni-pico/micropython/examples/motor2040/README.md

148 lines
4.4 KiB
Markdown
Raw Normal View History

2022-04-07 17:57:38 +01:00
# Motor 2040 Micropython Examples <!-- omit in toc -->
- [Motor Examples](#motor-examples)
- [Single Motor](#single-motor)
- [Multiple Motors](#multiple-motors)
- [Motor Cluster](#motor-cluster)
- [Motor Wave](#motor-wave)
2022-04-25 12:28:42 +01:00
- [Stop Motors](#stop-motors)
2022-04-07 17:57:38 +01:00
- [Function Examples](#function-examples)
- [Read Sensors](#read-sensors)
2022-04-26 12:52:28 +01:00
- [Read Encoders](#read-encoders)
- [Motor Profiler](#motor-profiler)
2022-04-07 17:57:38 +01:00
- [LED Rainbow](#led-rainbow)
- [Turn Off LEDs](#turn-off-leds)
2022-04-21 21:14:41 +01:00
- [Control Examples](#control-examples)
- [Position Control](#position-control)
- [Velocity Control](#velocity-control)
- [Position on Velocity Control](#position-on-velocity-control)
- [Reactive Encoder](#reactive-encoder)
2022-04-25 12:28:42 +01:00
- [Quad Position Wave](#quad-position-wave)
2022-04-26 12:52:28 +01:00
- [Quad Velocity Sequence](#quad-velocity-sequence)
2022-04-21 21:14:41 +01:00
- [Tuning Examples](#tuning-examples)
- [Position Tuning](#position-tuning)
- [Velocity Tuning](#velocity-tuning)
- [Position on Velocity Tuning](#position-on-velocity-tuning)
2022-04-07 17:57:38 +01:00
## Motor Examples
### Single Motor
[single_motor.py](single_motor.py)
Demonstrates how to create a Motor object and control it.
### Multiple Motors
[multiple_motors.py](multiple_motors.py)
Demonstrates how to create multiple Motor objects and control them together.
### Motor Cluster
[motor_cluster.py](motor_cluster.py)
Demonstrates how to create a MotorCluster object to control multiple motors at once.
### Motor Wave
[motor_wave.py](motor_wave.py)
An example of applying a wave pattern to a group of motors and the LEDs.
2022-04-25 12:28:42 +01:00
### Stop Motors
[stop_motors.py](stop_motors.py)
2022-04-21 21:14:41 +01:00
2022-04-25 12:28:42 +01:00
A simple program that stops the motors.
2022-04-21 21:14:41 +01:00
2022-04-26 12:52:28 +01:00
## Function Examples
### Read Sensors
[read_sensors.py](read_sensors.py)
Shows how to initialise and read the 2 external and 6 internal sensors of Motor 2040.
2022-04-21 21:14:41 +01:00
2022-04-25 12:28:42 +01:00
### Read Encoders
[read_encoders.py](read_encoders.py)
2022-04-21 21:14:41 +01:00
Demonstrates how to read the angles of Motor 2040's four encoders.
2022-04-07 17:57:38 +01:00
2022-04-21 21:14:41 +01:00
### Motor Profiler
[motor_profiler.py](motor_profiler.py)
A program that profiles the speed of a motor across its PWM
duty cycle range using the attached encoder for feedback.
2022-04-07 17:57:38 +01:00
### LED Rainbow
[led_rainbow.py](led_rainbow.py)
Displays a rotating rainbow pattern on the Motor 2040's onboard LED.
### Turn Off LED
[turn_off_led.py](turn_off_led.py)
A simple program that turns off the onboard LED.
2022-04-21 21:14:41 +01:00
## Control Examples
### Position Control
[position_control.py](position_control.py)
An example of how to move a motor smoothly between random positions, with the help of it's attached encoder and PID control.
### Velocity Control
[velocity_control.py](velocity_control.py)
An example of how to drive a motor smoothly between random speeds, with the help of it's attached encoder and PID control.
### Position on Velocity Control
[position_on_velocity_control.py](position_on_velocity_control.py)
An example of how to move a motor smoothly between random positions, with velocity limits, with the help of it's attached encoder and PID control.
### Reactive Encoder
[reactive_encoder.py](reactive_encoder.py)
A demonstration of how a motor with an encoder can be used as a programmable rotary encoder for user input, with force-feedback for arbitrary detents and end stops.
2022-04-25 12:28:42 +01:00
### Quad Position Wave
[quad_position_wave.py](quad_position_wave.py)
2022-04-26 12:52:28 +01:00
A demonstration of driving all four of Motor 2040's motor outputs between positions, with the help of their attached encoders and PID control.
### Quad Velocity Sequence
[quad_velocity_sequence.py](quad_velocity_sequence.py)
A demonstration of driving all four of Motor 2040's motor outputs through a sequence of velocities, with the help of their attached encoders and PID control.
2022-04-25 12:28:42 +01:00
2022-04-21 21:14:41 +01:00
## Tuning Examples
### Position Tuning
[position_tuning.py](position_tuning.py)
A program to aid in the discovery and tuning of motor PID values for position control. It does this by commanding the motor to move repeatedly between two setpoint angles and plots the measured response.
2022-04-21 21:14:41 +01:00
### Velocity Tuning
[velocity_tuning.py](velocity_tuning.py)
A program to aid in the discovery and tuning of motor PID values for velocity control. It does this by commanding the motor to drive repeatedly between two setpoint speeds and plots the measured response.
2022-04-21 21:14:41 +01:00
### Position on Velocity Tuning
[position_on_velocity_tuning.py](position_on_velocity_tuning.py)
A program to aid in the discovery and tuning of motor PID values for position on velocity control. It does this by commanding the motor to move repeatedly between two setpoint angles and plots the measured response.