From c6dedb1658850cf02670743adcc3c6014698c426 Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Fri, 3 Nov 2023 16:32:49 +0000 Subject: [PATCH] Example tidy up --- docs/serial_servo.md | 3 - examples/board/blink_led.py | 2 + examples/board/i2c/bme280_via_expansion.py | 2 + examples/board/i2c/bme280_via_qwst.py | 2 + examples/board/monitor_internals.py | 2 + examples/board/read_buttons.py | 2 + examples/board/read_expansion.py | 2 + examples/board/read_internals.py | 2 + examples/board/read_slot.py | 2 + examples/board/set_expansion.py | 2 + examples/board/set_slot.py | 2 + examples/modules/README.md | 141 +++++++++++++++--- examples/modules/audio_amp/tone_song.py | 5 +- examples/modules/audio_amp/wav_play.py | 6 +- .../modules/bench_power/controllable_power.py | 4 +- .../modules/bench_power/multiple_powers.py | 4 +- examples/modules/bench_power/single_power.py | 7 +- .../big_motor/all_motors_no_encoders.py | 5 +- examples/modules/big_motor/multiple_motors.py | 4 +- .../modules/big_motor/position_control.py | 2 +- .../big_motor/position_on_velocity_control.py | 2 +- examples/modules/big_motor/single_motor.py | 4 +- .../big_motor/tuning/motor_profiler.py | 5 +- .../tuning/position_on_velocity_tuning.py | 3 +- .../big_motor/tuning/position_tuning.py | 3 +- .../big_motor/tuning/velocity_tuning.py | 3 +- .../modules/big_motor/velocity_control.py | 2 +- examples/modules/dual_motor/all_motors.py | 4 +- .../modules/dual_motor/multiple_motors.py | 4 +- examples/modules/dual_motor/single_stepper.py | 4 +- examples/modules/dual_motor/two_motors.py | 4 +- .../modules/dual_output/actioned_output.py | 4 +- .../modules/dual_output/multiple_outputs.py | 4 +- examples/modules/dual_output/pwm_output.py | 4 +- examples/modules/dual_output/two_outputs.py | 7 +- examples/modules/led_strip/multiple_strips.py | 4 +- examples/modules/led_strip/single_strip.py | 4 +- examples/modules/quad_servo/all_servos.py | 4 +- examples/modules/quad_servo/four_servos.py | 4 +- .../modules/quad_servo/multiple_servos.py | 4 +- examples/modules/quad_servo/servo_feedback.py | 4 +- examples/yukon_adaptive_big_motor.py | 75 ---------- examples/yukon_adaptive_serial_servo.py | 76 ---------- firmware/PIMORONI_YUKON/manifest.py | 2 +- 44 files changed, 226 insertions(+), 209 deletions(-) delete mode 100644 docs/serial_servo.md delete mode 100644 examples/yukon_adaptive_big_motor.py delete mode 100644 examples/yukon_adaptive_serial_servo.py diff --git a/docs/serial_servo.md b/docs/serial_servo.md deleted file mode 100644 index 4bf7ea3..0000000 --- a/docs/serial_servo.md +++ /dev/null @@ -1,3 +0,0 @@ - Serial Bus Servo Module - Library Reference - -This is the library reference for the [Serial Bus Servo Module for Yukon](https://pimoroni.com/yukon). diff --git a/examples/board/blink_led.py b/examples/board/blink_led.py index 8665679..8d3ebf6 100644 --- a/examples/board/blink_led.py +++ b/examples/board/blink_led.py @@ -3,6 +3,8 @@ """ Blink one of Yukon's onboard LEDs. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/i2c/bme280_via_expansion.py b/examples/board/i2c/bme280_via_expansion.py index e8b5c67..9f0cb22 100644 --- a/examples/board/i2c/bme280_via_expansion.py +++ b/examples/board/i2c/bme280_via_expansion.py @@ -5,6 +5,8 @@ """ Read a BME280 sensor attached to the Expansion header. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/i2c/bme280_via_qwst.py b/examples/board/i2c/bme280_via_qwst.py index 11fad90..0155e51 100644 --- a/examples/board/i2c/bme280_via_qwst.py +++ b/examples/board/i2c/bme280_via_qwst.py @@ -4,6 +4,8 @@ """ Read a BME280 sensor attached to the QwST connectors or Breakout Garden header. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/monitor_internals.py b/examples/board/monitor_internals.py index 71f5b27..188fecb 100644 --- a/examples/board/monitor_internals.py +++ b/examples/board/monitor_internals.py @@ -4,6 +4,8 @@ Use Yukon's monitoring function to read the internal sensors. Power needs to be provided to the XT30 connector, otherwise the monitoring will raise an UnderVoltageError. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/read_buttons.py b/examples/board/read_buttons.py index 4e0785f..f5876ef 100644 --- a/examples/board/read_buttons.py +++ b/examples/board/read_buttons.py @@ -3,6 +3,8 @@ """ Read Yukon's onboard Buttons. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/read_expansion.py b/examples/board/read_expansion.py index 4349b6f..a2be4d6 100644 --- a/examples/board/read_expansion.py +++ b/examples/board/read_expansion.py @@ -4,6 +4,8 @@ """ Read the IO pins on Yukon's expansion header. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/read_internals.py b/examples/board/read_internals.py index 3a3f617..428112e 100644 --- a/examples/board/read_internals.py +++ b/examples/board/read_internals.py @@ -3,6 +3,8 @@ """ Read the internal sensors of Yukon. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/read_slot.py b/examples/board/read_slot.py index dd0a59b..db925cc 100644 --- a/examples/board/read_slot.py +++ b/examples/board/read_slot.py @@ -5,6 +5,8 @@ """ Read the IO pins of a single Yukon slot. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/set_expansion.py b/examples/board/set_expansion.py index 6997774..3a6fe26 100644 --- a/examples/board/set_expansion.py +++ b/examples/board/set_expansion.py @@ -4,6 +4,8 @@ """ Initialise the IO pins on Yukon's expansion header as outputs and set them. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/board/set_slot.py b/examples/board/set_slot.py index 83d7aca..0c74ed1 100644 --- a/examples/board/set_slot.py +++ b/examples/board/set_slot.py @@ -5,6 +5,8 @@ """ Initialise the IO pins on a Yukon slot as outputs and set them. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/README.md b/examples/modules/README.md index c372998..2b21ad4 100644 --- a/examples/modules/README.md +++ b/examples/modules/README.md @@ -1,15 +1,29 @@ # Yukon Micropython Module Examples - [Audio Amp Module](#audio-amp-module) + - [Tone Song](#tone-song) + - [Wav Play](#wav-play) - [Bench Power Module](#bench-power-module) - [Single Power](#single-power) - [Multiple Powers](#multiple-powers) - [Controllable Power](#controllable-power) - [Big Motor + Encoder Module](#big-motor--encoder-module) + - [Single Motor](#single-motor) + - [Multiple Motors](#multiple-motors) + - [All Motors (No Encoders)](#all-motors-no-encoders) + - [Position Control](#position-control) + - [Velocity Control](#velocity-control) + - [Position on Velocity Control](#position-on-velocity-control) + - [Tuning](#tuning) + - [Motor Profiler](#motor-profiler) + - [Position Tuning](#position-tuning) + - [Velocity Tuning](#velocity-tuning) + - [Position on Velocity Tuning](#position-on-velocity-tuning) - [Dual Motor / Bipolar Stepper Module](#dual-motor--bipolar-stepper-module) - [Two Motors](#two-motors) - - [Multiple Motors](#multiple-motors) + - [Multiple Motors](#multiple-motors-1) - [All Motors](#all-motors) + - [Single Stepper](#single-stepper) - [Dual Switched Output Module](#dual-switched-output-module) - [Two Outputs](#two-outputs) - [Multiple Outputs](#multiple-outputs) @@ -29,80 +43,169 @@ ## Audio Amp Module +### Tone Song +[audio_amp/tone_song.py](audio_amp/tone_song.py) + +Play a sequence of tones out of an Audio Amp Module connected to Slot1. + +### Wav Play +[audio_amp/wav_play.py](audio_amp/wav_play.py) + +Play wave files out of an Audio Amp Module connected to Slot1. + + ## Bench Power Module ### Single Power [bench_power/single_power.py](bench_power/single_power.py) -How to control the variable output of a Bench Power Module connected to Slot1. -Use the A and B buttons to increase and decrease the output voltage. +Control the variable output of a Bench Power Module connected to Slot1. ### Multiple Powers [bench_power/multiple_powers.py](bench_power/multiple_powers.py) -How to drive up to 4 variable outputs from a set of Bench Power Modules connected to Slots. +Control up to 4 variable outputs from a set of Bench Power Modules connected to Slots. A wave pattern will be played on the attached outputs. ### Controllable Power [bench_power/controllable_power.py](bench_power/controllable_power.py) -How to control the variable output of a Bench Power Module connected to Slot1. +Control the variable output of a Bench Power Module connected to Slot1. A potentiometer on a Proto Module connected to Slot2 is used for input. ## Big Motor + Encoder Module +### Single Motor +[big_motor/single_motor.py](big_motor/single_motor.py) + +Drive a single motor from a Big Motor + Encoder Module connected to Slot1. +A wave pattern will be played on the attached motor, and its speed printed out. + + +### Multiple Motors +[big_motor/multiple_motors.py](big_motor/multiple_motors.py) + +Drive up to 4 motors from a set of Big Motor + Encoder Modules connected to Slots. +A wave pattern will be played on the attached motors, and their speeds printed out. + + +### All Motors (No Encoders) +[big_motor/all_motors_no_encoders.py](big_motor/all_motors_no_encoders.py) + +Drive up to 6 motors from a set of Big Motor + Encoder Modules connected to Slots, using a MotorCluster. +A wave pattern will be played on the attached motors. + + +### Position Control +[big_motor/position_control.py](big_motor/position_control.py) + +Drive a motor smoothly between random positions, with the help of it's attached encoder and PID control. +This uses a Big Motor + Encoder Module connected to Slot1. + + +### Velocity Control +[big_motor/velocity_control.py](big_motor/velocity_control.py) + +Drive a motor smoothly between random speeds, with the help of it's attached encoder and PID control. +This uses a Big Motor + Encoder Module connected to Slot1. + +### Position on Velocity Control +[big_motor/position_on_velocity_control.py](big_motor/position_on_velocity_control.py) + +Drive a motor smoothly between random positions, with velocity limits, with the help of it's attached encoder and PID control. +This uses a Big Motor + Encoder Module connected to Slot1. + + +### Tuning + +#### Motor Profiler +[big_motor/tuning/motor_profiler.py](big_motor/tuning/motor_profiler.py) + +Profile the speed of a motor across its PWM duty cycle range using its attached encoder for feedback. +This uses a Big Motor + Encoder Module connected to Slot1. + + +#### Position Tuning +[big_motor/tuning/position_tuning.py](big_motor/tuning/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. This uses a Big Motor + Encoder Module connected to Slot1. + + +#### Velocity Tuning +[big_motor/tuning/velocity_tuning.py](big_motor/tuning/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. This uses a Big Motor + Encoder Module connected to Slot1. + +#### Position on Velocity Tuning +[big_motor/tuning/position_on_velocity_tuning.py](big_motor/tuning/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. This uses a Big Motor + Encoder Module connected to Slot1. + + ## Dual Motor / Bipolar Stepper Module ### Two Motors [dual_motor/two_motors.py](dual_motor/two_motors.py) -How to drive up to 2 motors from a Dual Motor Module connected to Slot1. +Drive up to 2 motors from a Dual Motor Module connected to Slot1. A wave pattern will be played on the attached motors. ### Multiple Motors [dual_motor/multiple_motors.py](dual_motor/multiple_motors.py) -How to drive up to 8 motors from a set of Dual Motor Module connected to Slots. +Drive up to 8 motors from a set of Dual Motor Modules connected to Slots. A wave pattern will be played on the attached motors. ### All Motors [dual_motor/all_motors.py](dual_motor/all_motors.py) -How to drive up to 12 motors from a set of Dual Motor Modules connected to Slots, using a MotorCluster. +Drive up to 12 motors from a set of Dual Motor Modules connected to Slots, using a MotorCluster. A wave pattern will be played on the attached motors. +### Single Stepper +[dual_motor/single_stepper.py](dual_motor/single_stepper.py) + +Drive a stepper motor from a Dual Motor Module connected to Slot1. +A sequence of movements will be played. + + ## Dual Switched Output Module ### Two Outputs [dual_output/two_outputs.py](dual_output/two_outputs.py) -How to control up to 2 powered outputs from a Dual Output Module connected to Slot1. -Buttons 'A' and 'B' toggle the state of each output. +Control up to 2 powered outputs from a Dual Output Module connected to Slot1. ### Multiple Outputs [dual_output/multiple_outputs.py](dual_output/multiple_outputs.py) -How to drive up to 12 powered outputs from a set of Dual Output Modules connected to Slots. +Control up to 12 powered outputs from a set of Dual Output Modules connected to Slots. A cycling pattern will be played on the attached outputs. ### Actioned Output [dual_output/actioned_output.py](dual_output/actioned_output.py) -How to control a powered output from a Dual Output Module connected to Slot1, using a monitor action. +Control a powered output from a Dual Output Module connected to Slot1, using a monitor action. ### PWM Output [dual_output/pwm_output.py](dual_output/pwm_output.py) -How to control a powered output from a Dual Output Module connected to Slot1, using PWM. +Control a powered output from a Dual Output Module connected to Slot1, using PWM. ## LED Strip Module @@ -110,14 +213,14 @@ How to control a powered output from a Dual Output Module connected to Slot1, us ### Single Strip [led_strip/single_strip.py](led_strip/single_strip.py) -How to drive a Neopixel or Dotstar LED strip with a LED Strip Module connected to Slot1. +Drive a Neopixel or Dotstar LED strip with a LED Strip Module connected to Slot1. A cycling rainbow pattern will be played on the attached strip(s). ### Multiple Strips [led_strip/multiple_strips.py](led_strip/multiple_strips.py) -How to drive multiple Neopixel or Dotstar LED strips with a set of LED Strip Modules connected to slots. +Drive multiple Neopixel or Dotstar LED strips with a set of LED Strip Modules connected to slots. A cycling rainbow pattern will be played on the attached strips. @@ -126,28 +229,28 @@ A cycling rainbow pattern will be played on the attached strips. ### Four Servos [quad_servo/four_servos.py](quad_servo/four_servos.py) -How to drive up to four servos from a Quad Servo Module connected to Slot1. +Drive up to four servos from a Quad Servo Module connected to Slot1. A wave pattern will be played on the attached servos. ### Multiple Servos [quad_servo/multiple_servos.py](quad_servo/multiple_servos.py) -How to drive up to 16 servos from a set of Quad Servo Modules connected to Slots. +Drive up to 16 servos from a set of Quad Servo Modules connected to Slots. A wave pattern will be played on the attached servos. ### All Servos [quad_servo/all_servos.py](quad_servo/all_servos.py) -How to drive up to 24 servos from a set of Quad Servo Modules connected to Slots, using a ServoCluster. +Drive up to 24 servos from a set of Quad Servo Modules connected to Slots, using a ServoCluster. A wave pattern will be played on the attached servos. ### Servo Feedback [quad_servo/servo_feedback.py](quad_servo/servo_feedback.py) -How to read the analog inputs on Quad Servo Direct modules connected to Slots. +Read the analog inputs of Quad Servo Direct modules connected to Slots. ## Serial Servo Module diff --git a/examples/modules/audio_amp/tone_song.py b/examples/modules/audio_amp/tone_song.py index abfed76..d7e2364 100644 --- a/examples/modules/audio_amp/tone_song.py +++ b/examples/modules/audio_amp/tone_song.py @@ -3,7 +3,10 @@ from pimoroni_yukon.modules import AudioAmpModule """ -How to play a sequence of tones out of an Audio Amp Module connected to Slot1. +Play a sequence of tones out of an Audio Amp Module connected to Slot1. + +Press "A" to start or stop the tone song. +Press "Boot/User" to exit the program. """ # This handy list converts notes into frequencies, which you can use with the inventor.play_tone function diff --git a/examples/modules/audio_amp/wav_play.py b/examples/modules/audio_amp/wav_play.py index 5123556..99206f2 100644 --- a/examples/modules/audio_amp/wav_play.py +++ b/examples/modules/audio_amp/wav_play.py @@ -3,7 +3,11 @@ from pimoroni_yukon.modules import AudioAmpModule """ -How to play wave files out of an Audio Amp Module connected to Slot1. +Play wave files out of an Audio Amp Module connected to Slot1. + +Press "A" to start the first WAV file, or stop if anything is already playing. +Press "B" to start the second WAV file, or stop if anything is already playing. +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/bench_power/controllable_power.py b/examples/modules/bench_power/controllable_power.py index 00254d0..72ae5c8 100644 --- a/examples/modules/bench_power/controllable_power.py +++ b/examples/modules/bench_power/controllable_power.py @@ -5,8 +5,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to control the variable output of a Bench Power Module connected to Slot1. +Control the variable output of a Bench Power Module connected to Slot1. A potentiometer on a Proto Module connected to Slot2 is used for input. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/bench_power/multiple_powers.py b/examples/modules/bench_power/multiple_powers.py index 578ae69..f332dc1 100644 --- a/examples/modules/bench_power/multiple_powers.py +++ b/examples/modules/bench_power/multiple_powers.py @@ -4,8 +4,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive up to 4 variable outputs from a set of Bench Power Modules connected to Slots. +Control up to 4 variable outputs from a set of Bench Power Modules connected to Slots. A wave pattern will be played on the attached outputs. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/bench_power/single_power.py b/examples/modules/bench_power/single_power.py index 3934003..e05c617 100644 --- a/examples/modules/bench_power/single_power.py +++ b/examples/modules/bench_power/single_power.py @@ -3,8 +3,11 @@ from pimoroni_yukon.modules import BenchPowerModule """ -How to control the variable output of a Bench Power Module connected to Slot1. -Use the A and B buttons to increase and decrease the output voltage. +Control the variable output of a Bench Power Module connected to Slot1. + +Press "A" to increase the output voltage. +Press "B" to decrease the output voltage. +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/big_motor/all_motors_no_encoders.py b/examples/modules/big_motor/all_motors_no_encoders.py index 92041ac..95309ff 100644 --- a/examples/modules/big_motor/all_motors_no_encoders.py +++ b/examples/modules/big_motor/all_motors_no_encoders.py @@ -5,9 +5,11 @@ from motor import MotorCluster """ -How to drive up to 6 motors from a set of Big Motor + Encoder Modules connected to Slots, using a MotorCluster. +Drive up to 6 motors from a set of Big Motor + Encoder Modules connected to Slots, using a MotorCluster. A wave pattern will be played on the attached motors. +Press "Boot/User" to exit the program. + The MotorCluster controls the whole set of motors using PIO. Note: Is not possible to use more than 4 encoders whilst using a motor cluster, hence encoders being omitted from this example. @@ -35,6 +37,7 @@ def speed_from_index(index, offset=0.0): speed = math.sin(phase) * SPEED_EXTENT return speed + # Wrap the code in a try block, to catch any exceptions (including KeyboardInterrupt) try: # Find out which slots of Yukon have BigMotorModule attached diff --git a/examples/modules/big_motor/multiple_motors.py b/examples/modules/big_motor/multiple_motors.py index 12ef3a6..5098a55 100644 --- a/examples/modules/big_motor/multiple_motors.py +++ b/examples/modules/big_motor/multiple_motors.py @@ -4,9 +4,11 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive up to 4 motors from a set of Big Motor + Encoder Modules connected to Slots. +Drive up to 4 motors from a set of Big Motor + Encoder Modules connected to Slots. A wave pattern will be played on the attached motors, and their speeds printed out. +Press "Boot/User" to exit the program. + To use more motors, look at the all_motors_no_encoders.py example. """ diff --git a/examples/modules/big_motor/position_control.py b/examples/modules/big_motor/position_control.py index cf0053e..afd8181 100644 --- a/examples/modules/big_motor/position_control.py +++ b/examples/modules/big_motor/position_control.py @@ -7,7 +7,7 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive a motor smoothly between random positions, with the help of it's attached encoder and PID control. +Drive a motor smoothly between random positions, with the help of it's attached encoder and PID control. This uses a Big Motor + Encoder Module connected to Slot1. Press "Boot/User" to exit the program. diff --git a/examples/modules/big_motor/position_on_velocity_control.py b/examples/modules/big_motor/position_on_velocity_control.py index a872d26..c005359 100644 --- a/examples/modules/big_motor/position_on_velocity_control.py +++ b/examples/modules/big_motor/position_on_velocity_control.py @@ -7,7 +7,7 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to move a motor smoothly between random positions, with velocity limits, with the help of it's attached encoder and PID control. +Drive a motor smoothly between random positions, with velocity limits, with the help of it's attached encoder and PID control. This uses a Big Motor + Encoder Module connected to Slot1. Press "Boot/User" to exit the program. diff --git a/examples/modules/big_motor/single_motor.py b/examples/modules/big_motor/single_motor.py index dc55299..374a17a 100644 --- a/examples/modules/big_motor/single_motor.py +++ b/examples/modules/big_motor/single_motor.py @@ -5,8 +5,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive a single motor from a Big Motor + Encoder Module connected to Slot1. +Drive a single motor from a Big Motor + Encoder Module connected to Slot1. A wave pattern will be played on the attached motor, and its speed printed out. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/big_motor/tuning/motor_profiler.py b/examples/modules/big_motor/tuning/motor_profiler.py index 90bd2fe..8a1ba52 100644 --- a/examples/modules/big_motor/tuning/motor_profiler.py +++ b/examples/modules/big_motor/tuning/motor_profiler.py @@ -4,9 +4,10 @@ from pimoroni_yukon.modules import BigMotorModule """ -A program that profiles the speed of a motor across its PWM duty cycle range using the attached encoder for feedback. -Note that the returned readings will only be valid for a single input voltage. +Profile the speed of a motor across its PWM duty cycle range using its attached encoder for feedback. This uses a Big Motor + Encoder Module connected to Slot1. + +Note that the returned readings will only be valid for a single input voltage. """ # Constants diff --git a/examples/modules/big_motor/tuning/position_on_velocity_tuning.py b/examples/modules/big_motor/tuning/position_on_velocity_tuning.py index 44fa119..76a0070 100644 --- a/examples/modules/big_motor/tuning/position_on_velocity_tuning.py +++ b/examples/modules/big_motor/tuning/position_on_velocity_tuning.py @@ -7,8 +7,7 @@ """ 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. -This uses a Big Motor + Encoder Module connected to Slot1. +the measured response. This uses a Big Motor + Encoder Module connected to Slot1. Press "Boot/User" to exit the program. """ diff --git a/examples/modules/big_motor/tuning/position_tuning.py b/examples/modules/big_motor/tuning/position_tuning.py index 31e32d0..01d0341 100644 --- a/examples/modules/big_motor/tuning/position_tuning.py +++ b/examples/modules/big_motor/tuning/position_tuning.py @@ -7,8 +7,7 @@ """ 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. -This uses a Big Motor + Encoder Module connected to Slot1. +plots the measured response. This uses a Big Motor + Encoder Module connected to Slot1. Press "Boot/User" to exit the program. """ diff --git a/examples/modules/big_motor/tuning/velocity_tuning.py b/examples/modules/big_motor/tuning/velocity_tuning.py index 4940cdd..b0517f9 100644 --- a/examples/modules/big_motor/tuning/velocity_tuning.py +++ b/examples/modules/big_motor/tuning/velocity_tuning.py @@ -7,8 +7,7 @@ """ 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. -This uses a Big Motor + Encoder Module connected to Slot1. +plots the measured response. This uses a Big Motor + Encoder Module connected to Slot1. Press "Boot/User" to exit the program. """ diff --git a/examples/modules/big_motor/velocity_control.py b/examples/modules/big_motor/velocity_control.py index eba5ba5..de50f5c 100644 --- a/examples/modules/big_motor/velocity_control.py +++ b/examples/modules/big_motor/velocity_control.py @@ -7,7 +7,7 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive a motor smoothly between random speeds, with the help of it's attached encoder and PID control. +Drive a motor smoothly between random speeds, with the help of it's attached encoder and PID control. This uses a Big Motor + Encoder Module connected to Slot1. Press "Boot/User" to exit the program. diff --git a/examples/modules/dual_motor/all_motors.py b/examples/modules/dual_motor/all_motors.py index 0f05874..c2416c6 100644 --- a/examples/modules/dual_motor/all_motors.py +++ b/examples/modules/dual_motor/all_motors.py @@ -5,9 +5,11 @@ from motor import MotorCluster """ -How to drive up to 12 motors from a set of Dual Motor Modules connected to Slots, using a MotorCluster. +Drive up to 12 motors from a set of Dual Motor Modules connected to Slots, using a MotorCluster. A wave pattern will be played on the attached motors. +Press "Boot/User" to exit the program. + The MotorCluster controls the whole set of motors using PIO. """ diff --git a/examples/modules/dual_motor/multiple_motors.py b/examples/modules/dual_motor/multiple_motors.py index 35ab8d5..451694f 100644 --- a/examples/modules/dual_motor/multiple_motors.py +++ b/examples/modules/dual_motor/multiple_motors.py @@ -4,9 +4,11 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive up to 8 motors from a set of Dual Motor Modules connected to Slots. +Drive up to 8 motors from a set of Dual Motor Modules connected to Slots. A wave pattern will be played on the attached motors. +Press "Boot/User" to exit the program. + To use more motors, look at the all_motors.py example. """ diff --git a/examples/modules/dual_motor/single_stepper.py b/examples/modules/dual_motor/single_stepper.py index 6d25051..d1e5e15 100644 --- a/examples/modules/dual_motor/single_stepper.py +++ b/examples/modules/dual_motor/single_stepper.py @@ -4,8 +4,10 @@ from pimoroni_yukon.extras.stepper import OkayStepper """ -How to drive a stepper motor from a Dual Motor Module connected to Slot1. +Drive a stepper motor from a Dual Motor Module connected to Slot1. A sequence of movements will be played. + +Press "Boot/User" to exit the program. """ # Put your movements here! diff --git a/examples/modules/dual_motor/two_motors.py b/examples/modules/dual_motor/two_motors.py index 77b53a6..bb48107 100644 --- a/examples/modules/dual_motor/two_motors.py +++ b/examples/modules/dual_motor/two_motors.py @@ -5,8 +5,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive up to 2 motors from a Dual Motor Module connected to Slot1. +Drive up to 2 motors from a Dual Motor Module connected to Slot1. A wave pattern will be played on the attached motors. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/dual_output/actioned_output.py b/examples/modules/dual_output/actioned_output.py index b7994c0..3c10465 100644 --- a/examples/modules/dual_output/actioned_output.py +++ b/examples/modules/dual_output/actioned_output.py @@ -3,7 +3,9 @@ from pimoroni_yukon.modules import DualOutputModule """ -How to control a powered output from a Dual Output Module connected to Slot1, using a monitor action. +Control a powered output from a Dual Output Module connected to Slot1, using a monitor action. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/dual_output/multiple_outputs.py b/examples/modules/dual_output/multiple_outputs.py index 4ef5a48..6d2858f 100644 --- a/examples/modules/dual_output/multiple_outputs.py +++ b/examples/modules/dual_output/multiple_outputs.py @@ -4,8 +4,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive up to 12 powered outputs from a set of Dual Output Modules connected to Slots. +Control up to 12 powered outputs from a set of Dual Output Modules connected to Slots. A cycling pattern will be played on the attached outputs. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/dual_output/pwm_output.py b/examples/modules/dual_output/pwm_output.py index b8517f6..b36d2a8 100644 --- a/examples/modules/dual_output/pwm_output.py +++ b/examples/modules/dual_output/pwm_output.py @@ -4,7 +4,9 @@ from pimoroni_yukon.modules import DualOutputModule """ -How to control a powered output from a Dual Output Module connected to Slot1, using PWM. +Control a powered output from a Dual Output Module connected to Slot1, using PWM. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/dual_output/two_outputs.py b/examples/modules/dual_output/two_outputs.py index 72f9edd..1697814 100644 --- a/examples/modules/dual_output/two_outputs.py +++ b/examples/modules/dual_output/two_outputs.py @@ -3,8 +3,11 @@ from pimoroni_yukon.modules import DualOutputModule """ -How to control up to 2 powered outputs from a Dual Output Module connected to Slot1. -Buttons 'A' and 'B' toggle the state of each output. +Control up to 2 powered outputs from a Dual Output Module connected to Slot1. + +Press "A" to toggle the state of Output 1. +Press "B" to toggle the state of Output 2. +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/led_strip/multiple_strips.py b/examples/modules/led_strip/multiple_strips.py index a60c20c..0241403 100644 --- a/examples/modules/led_strip/multiple_strips.py +++ b/examples/modules/led_strip/multiple_strips.py @@ -3,8 +3,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive multiple Neopixel or Dotstar LED strips with a set of LED Strip Modules connected to slots. +Drive multiple Neopixel or Dotstar LED strips with a set of LED Strip Modules connected to slots. A cycling rainbow pattern will be played on the attached strips. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/led_strip/single_strip.py b/examples/modules/led_strip/single_strip.py index f84d822..086db0f 100644 --- a/examples/modules/led_strip/single_strip.py +++ b/examples/modules/led_strip/single_strip.py @@ -4,8 +4,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive a Neopixel or Dotstar LED strip with a LED Strip Module connected to Slot1. +Drive a Neopixel or Dotstar LED strip with a LED Strip Module connected to Slot1. A cycling rainbow pattern will be played on the attached strip(s). + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/quad_servo/all_servos.py b/examples/modules/quad_servo/all_servos.py index 1c4f799..7439dfb 100644 --- a/examples/modules/quad_servo/all_servos.py +++ b/examples/modules/quad_servo/all_servos.py @@ -5,9 +5,11 @@ from servo import ServoCluster """ -How to drive up to 24 servos from a set of Quad Servo Modules connected to Slots, using a ServoCluster. +Drive up to 24 servos from a set of Quad Servo Modules connected to Slots, using a ServoCluster. A wave pattern will be played on the attached servos. +Press "Boot/User" to exit the program. + The ServoCluster controls the whole set of servos using PIO. It also staggers the updates of each servo to reduce peak current draw. """ diff --git a/examples/modules/quad_servo/four_servos.py b/examples/modules/quad_servo/four_servos.py index a0e7e3d..85b34d0 100644 --- a/examples/modules/quad_servo/four_servos.py +++ b/examples/modules/quad_servo/four_servos.py @@ -9,8 +9,10 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive up to four servos from a Quad Servo Module connected to Slot1. +Drive up to four servos from a Quad Servo Module connected to Slot1. A wave pattern will be played on the attached servos. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/modules/quad_servo/multiple_servos.py b/examples/modules/quad_servo/multiple_servos.py index fd731b7..5cf00eb 100644 --- a/examples/modules/quad_servo/multiple_servos.py +++ b/examples/modules/quad_servo/multiple_servos.py @@ -4,9 +4,11 @@ from pimoroni_yukon.timing import ticks_ms, ticks_add """ -How to drive up to 16 servos from a set of Quad Servo Modules connected to Slots. +Drive up to 16 servos from a set of Quad Servo Modules connected to Slots. A wave pattern will be played on the attached servos. +Press "Boot/User" to exit the program. + To use more servos, or to reduce peak current draw, look at the all_servos.py example. """ diff --git a/examples/modules/quad_servo/servo_feedback.py b/examples/modules/quad_servo/servo_feedback.py index f3ae118..dcbdc12 100644 --- a/examples/modules/quad_servo/servo_feedback.py +++ b/examples/modules/quad_servo/servo_feedback.py @@ -2,7 +2,9 @@ from pimoroni_yukon.modules import QuadServoDirectModule """ -How to read the analog inputs on Quad Servo Direct modules connected to Slots. +Read the analog inputs of Quad Servo Direct modules connected to Slots. + +Press "Boot/User" to exit the program. """ # Constants diff --git a/examples/yukon_adaptive_big_motor.py b/examples/yukon_adaptive_big_motor.py deleted file mode 100644 index 690c374..0000000 --- a/examples/yukon_adaptive_big_motor.py +++ /dev/null @@ -1,75 +0,0 @@ -import math -from pimoroni_yukon import Yukon -from pimoroni_yukon.modules import BigMotorModule -import tca - -SPEED = 5 # The speed that the motors will cycle at -UPDATES = 50 # How many times to update LEDs and Servos per second -MOTOR_EXTENT = 0.4 # How far from zero to drive the motors - -# Create a Yukon object to begin using the board -yukon = Yukon(logging_level=6) - -# List to store the modules -motor_modules = [] - - -def print_tca(message=""): - print(f"---- {message} -----") - #print(f"Stored Dir = [0]{tca.stored_config(0):0{16}b} [1]{tca.stored_config(1):0{16}b}") - print(f"True Dir = [0]{tca.read_config(0):0{16}b} [1]{tca.read_config(1):0{16}b}") - print() - #print(f"Stored Out = [0]{tca.stored_output(0):0{16}b} [1]{tca.stored_output(1):0{16}b}") - print(f"True Out = [0]{tca.read_output(0):0{16}b} [1]{tca.read_output(1):0{16}b}") - print("-----------") - print("\n") - -try: - #print_tca() - - # Create a Quad Servo Direct class for each populated module slot - for slot in yukon.find_slots_with_module(BigMotorModule): - big_motor = BigMotorModule() - yukon.register_with_slot(big_motor, slot) - motor_modules.append(big_motor) - - # Initialise Yukon's registered modules - yukon.initialise_modules(allow_unregistered=True) - - NUM_MOTORS = len(motor_modules) - print(f"Up to {NUM_MOTORS} motors available") - - #time.sleep(5) - - # Turn on the module power - yukon.enable_main_output() - - #print_tca() - - # Enable the outputs on the regulated servo modules - for module in motor_modules: - try: - module.enable() - except AttributeError: - # No enable function - pass - - #print_tca("post_enable_motors") - - offset = 0 - while not yukon.is_boot_pressed(): - offset += SPEED / 1000.0 - - # Update all the Motors - i = 0 - for module in motor_modules: - angle = ((i / NUM_MOTORS) + offset) * math.pi * 2 - module.motor.speed(math.sin(angle) * MOTOR_EXTENT) - i += 1 - - #yukon.monitored_sleep(1.0 / UPDATES, allowed=("T_avg", "Fault")) - yukon.monitored_sleep(1.0, allowed=("T_avg", "Fault")) - -finally: - # Put the board back into a safe state, regardless of how the program may have ended - yukon.reset() diff --git a/examples/yukon_adaptive_serial_servo.py b/examples/yukon_adaptive_serial_servo.py deleted file mode 100644 index f53ab4b..0000000 --- a/examples/yukon_adaptive_serial_servo.py +++ /dev/null @@ -1,76 +0,0 @@ -import time -from pimoroni_yukon import Yukon -from pimoroni_yukon.modules import SerialServoModule -from pimoroni_yukon.protocols.lx_servos import SerialServoReadPosition, SerialServoReadVin, SerialServoReadTemperature, SerialServoMove, SerialServoActivateLED, SerialServoDeactivateLED - -SPEED = 5 # The speed that the servos will cycle at -UPDATES = 5 # How many times to update LEDs and Servos per second -SERVO_EXTENT = 80.0 # How far from zero to move the servos - -# Create a Yukon object to begin using the board -yukon = Yukon(logging_level=1) - -# List to store the modules -servo_modules = [] - -try: - # Create a Quad Servo Direct class for each populated module slot - for slot in yukon.find_slots_with_module(SerialServoModule): - serial_servo = SerialServoModule() - yukon.register_with_slot(serial_servo, slot) - servo_modules.append(serial_servo) - - # Initialise Yukon's registered modules - yukon.initialise_modules(allow_unregistered=True) - - # Turn on the module power - yukon.enable_main_output() - - time.sleep(1) - - old_id = 1 - new_id = 11 - - servo_ids = [1, 2, 3] - - #for module in servo_modules: - # module.send_on_data() - # SerialServoSetID(module.uart, old_id, new_id) - - # for module in servo_modules: - # module.send_on_data() - # SerialServoSetMode(module.uart, 2, 1, 1000) - - offset = 0 - toggle = False - while not yukon.is_boot_pressed(): - offset += SPEED / 1000.0 - - # Update all the Servos - for module in servo_modules: - for sid in servo_ids: - angle = SerialServoReadPosition(module.uart, module.send_on_data, module.receive_on_data, sid) - angle = ((angle - 500) / 360) * 90 - voltage = SerialServoReadVin(module.uart, module.send_on_data, module.receive_on_data, sid) - voltage = (voltage / 1000) - temp = SerialServoReadTemperature(module.uart, module.send_on_data, module.receive_on_data, sid) - print(f"ID: {sid}, Angle: {angle}, Vin: {voltage}, Temp: {temp}", end=", ") - print() - - if yukon.is_pressed('A'): - SerialServoMove(module.uart, 1, 500, 1000) - - if yukon.is_pressed('B'): - SerialServoMove(module.uart, 1, 800, 1000) - - toggle = not toggle - if toggle: - SerialServoActivateLED(module.uart, 1) - else: - SerialServoDeactivateLED(module.uart, 1) - - yukon.monitored_sleep(1.0 / UPDATES) - -finally: - # Put the board back into a safe state, regardless of how the program may have ended - yukon.reset() diff --git a/firmware/PIMORONI_YUKON/manifest.py b/firmware/PIMORONI_YUKON/manifest.py index 74dc402..79d67b4 100644 --- a/firmware/PIMORONI_YUKON/manifest.py +++ b/firmware/PIMORONI_YUKON/manifest.py @@ -2,4 +2,4 @@ freeze("$(BOARD_DIR)/../frozen/") -require("sdcard") \ No newline at end of file +require("sdcard")