diff --git a/FTC-Single-Hub.md b/FTC-Single-Hub.md new file mode 100644 index 0000000..d58d443 --- /dev/null +++ b/FTC-Single-Hub.md @@ -0,0 +1,219 @@ +## Introduction + +In a 2022 [**"Share the Spare"**](http://firsttechchallenge.blogspot.com/2022/06/share-spare-control-and-expansion-hub.html) universe, some FTC teams this season may temporarily have **only one REV Hub** available. Does this mean the robot can use only 4 DC motors? + +Not to worry! This tutorial shows how to run **more than 4** DC motors on a single REV Control Hub or REV Expansion Hub. + +========== + +The key is a REV Robotics device allowing a DC motor to be controlled from a **servo port**. + +

[[/images/FTC-Single-Hub/010_SPARKmini_photo.png|SPARKmini]] + +The [**SPARKmini**](https://www.revrobotics.com/rev-31-1230/) needs **two inputs**: 12V DC power and a control signal (from a servo port). A **single output** sends the **controlled power** to the motor. + +

[[/images/FTC-Single-Hub/020_SPARKmini_connections_labeled.png|SPARKmini connections]] + +_Reminder: only 8 DC motors are allowed on an FTC robot. So, don't add 6 SPARKmini units..._ + +[

Return to Top](#introduction)

+ +## Power Input + +The 12V input originates at the robot battery, passing through the robot's power switch and one or more power junctions. Such junctions simply split off, or share, the 12V power with other devices (including the REV Hub itself). + +You're already familiar with the simple in-and-out power junction at the top left corner of the REV Hub. + +

[[/images/FTC-Single-Hub/030_Hub_power_connector_circled.png|Hub power corner]] + +Simply connect the SPARKmini **power input** to this yellow-orange port on the REV Hub. + +See far below for other power connection options. + +[

Return to Top](#introduction)

+ +## Control Input + +The SPARKmini's control input originates from any servo port, located along the bottom edge of a REV Hub. + +Plug the SPARKmini **servo connector** into the selected port, with the correct orientation. See the small legend at the left side: + +

[[/images/FTC-Single-Hub/040_Hub_servo_legend_circled.png|Hub servo legend]] + +The simple rule is to place the black or darkest servo wire **to the left**. + +If using a servo extension cable, perhaps with different wire colors, make sure the black or brown "ground" wires line up. Secure those connections. + +Does it matter **which port**? See far below for further discussion. + +[

Return to Top](#introduction)

+ +## Motor Output + +Connect the SPARKmini's **output power cable** directly to the DC motor. Change or adapt the white JST-VH connector with PowerPole if needed. + +That's it! Your SPARKmini is ready to configure and program. + +Note: the SPARKmini's small **C-B switch** will be discussed below, in the section called “Zero-Power Behavior”. + +[

Return to Top](#introduction)

+ +## Configure the Motor + +Before you dive into programming, the robot's **configuration** must reflect the presence of a DC motor connected via SPARKmini. + +Open the FTC Driver Station app, on a Driver Station (DS) device that's connected/paired (via Wi-Fi) with a Robot Controller -- either the REV Control Hub or an Android RC phone plugged into the REV Expansion Hub. + +**Or**, open the FTC Robot Controller app on the Android RC phone. + +In either app, touch the three-dots icon, open Configure Robot. Create or edit the desired configuration, navigate to the Control Hub or Expansion Hub, and open the **Servos menu**. + +

[[/images/FTC-Single-Hub/050_SPARKmini_config_landscape_circled.png|configuration]] + +Choose `REV SPARKmini Controller` and name the DC motor. + +Save and activate that configuration. Done! + +[

Return to Top](#introduction)

+ +## Programming with SPARKmini + +In the **FTC Blocks** command palette or menu, open `Actuators`, and `CR Servo`. Here you will find the Blocks available to control your SPARKmini DC motor. + +

[[/images/FTC-Single-Hub/100_Blocks_CRServo_orig.png|Blocks palette]] + +These 5 commands allows **basic control** of the DC motor, without encoder position and its associated features such as RunModes and `isBusy` status. Also missing is `ZeroPowerBehavior`, discussed below. + +Likewise in **Java**, use all commands for CR Servo; do not use the `DcMotor` class. Here’s a simple example for a SPARKmini DC motor named “Spool”: + +

[[/images/FTC-Single-Hub/110_Java_CRServo.png|Java code]] + +[

Return to Top](#introduction)

+ +## Power Distribution + +Each SPARKmini needs its own 12V input. You may find it convenient to add another 12V power junction: + +

[[/images/FTC-Single-Hub/200_Distro-first-group.png|Distro first group]] +
images not to scale

+ +- left image, **XT30** from [REV](https://www.revrobotics.com/rev-31-1293/) or [AndyMark](https://www.andymark.com/products/xt30-power-distribution-block) +- middle image, **XT30** from [AndyMark](https://www.andymark.com/products/andymark-xt30-distribution-board) +- right image, **PowerPole** from [AndyMark](https://www.andymark.com/products/powerpole-distribution-board) + +

[[/images/FTC-Single-Hub/210_Distro-second-group.png|Distro second group]] +
images not to scale

+ +- left image, **XT30** from [goBILDA](https://www.servocity.com/xt30-power-distribution-board-xt30-input-8-x-xt30-outputs/) +- middle image, **PowerPole** from [PowerWerx](https://powerwerx.com/4-position-powerpole-distribution-block) or [Amazon](https://www.amazon.com/Position-Distribution-Powerpole-Connectors-PD-4/dp/B071LHY6MV) +- right image, **PowerPole** from [PowerWerx](https://powerwerx.com/8-position-powerpole-distribution-block) or [Amazon](https://www.amazon.com/Powerwerx-Distribution-Positions-Powerpole-Connectors/dp/B088LJXCJV) + +Other devices and arrangements are possible, but the robot must meet all FTC wiring and safety rules. Careful **wire management** pays for itself. + +You may change or adapt the SPARKmini's yellow-orange XT-30 connector to PowerPole, if needed. + +[

Return to Top](#introduction)

+ +## Servo Port Management + +Some teams should choose the SPARKmini port carefully. + +Each **pair of servo ports** offers a maximum **2 Amps** (2A or 2000mA) of current draw for servos. Namely, the 0-and-1 pair offers **2000mA**, likewise the 2-and-3 pair, and the 4-and-5 pair. + +Why does this matter? The SPARKmini's control line draws very little current; the **other** input provides the DC motor's power. But... if the **other/paired servo port** is overloaded by a stalled high-power servo, the port pair may be automatically (temporarily) **disabled for safety** by the REV Hub. This could affect your DC motor performance. + +How easy is it to **overload** the ports with high-performance servos? + +

[[/images/FTC-Single-Hub/250 servo stall specs.png|Servo stall specs]] +
images not to scale

+ +So, connect the SPARKmini to a lightly loaded port pair if possible. In general, it's wise to consider the **peak power demand** (and timing) for all devices, ports and the overall robot. Limits and problems may appear, far below the robot battery's 20A fuse protection! + +[

Return to Top](#introduction)

+ +## Servo Power Offload + +On the subject of high-power servos, this product can help: + +

[[/images/FTC-Single-Hub/270_REV_SPM.png|Servo Power Module]] + +The [**REV Servo Power Module (SPM)**](https://www.revrobotics.com/rev-11-1144/) doesn't directly interact with **extra DC motors** on a REV Hub, but it does **offload electrical load** from REV Hub servo ports. This in turn can allow SPARKmini DC motors to operate **unaffected** by overloaded/high-power servos, as described above. + +The SPM needs **two inputs**: 12V DC power and a control signal (from a servo port). A **single output** sends the **controlled power** to the servo. REV Robotics calls this a **power injector** arrangement, similar to the SPARKmini. + +

[[/images/FTC-Single-Hub/280_REV_SPM_diagram.png|SPM diagram]] + +SPM documentation is [**here**](https://www.revrobotics.com/content/docs/REV-11-1144-QS.pdf). + +If the robot electrical load is very high, the SPM may not eliminate temporary power reductions ('brownouts') or control system shutdown. Again, consider and test the **peak power demands** (and their in-match **timing**) for all devices, ports and the overall robot. Limits and problems may appear, far below the SPM's 15A rating, or the robot battery's 20A fuse protection. + +Such issues have become more common in recent competitions, as FTC teams reach for extreme performance from new high-power devices. Before immediately blaming a "disconnect", check the **power consumption**. + +[

Return to Top](#introduction)

+ +## Motor Encoders + +REV Hubs have 4 **motor encoder** ports, alongside the power ports at the REV Hub's left edge. The REV Hub's sensor ports (right edge) **cannot directly read** DC motor encoder data. + +A technical solution has been developed by [**Digital Chicken Labs**](https://www.tindie.com/stores/digitalchickenlabs/), a collaboration of [@Windwoes](https://github.com/Windwoes) and [@gearsincorg](https://github.com/gearsincorg/). @Windwoes is the developer of [EasyOpenCV](https://github.com/OpenFTC/EasyOpenCV) and other valuable programming tools. + +

[[/images/FTC-Single-Hub/300_OctoQuad_orig.png|OctoQuad]] + +From the [public announcement](https://www.reddit.com/r/FTC/comments/x3oerb/introducing_the_octoquad_8ch_quadrature_encoder/): + +> Introducing: The **OctoQuad** - a low-cost 8 channel encoder sensor, which is fully compatible with the FTC control system, and directly compatible with any encoder that works with the Control Hub / Expansion Hub. + +The OctoQuad accepts input from **DC motor encoders**, using the same cables/connectors as the REV Hubs. The encoder values are provided to your Java code through the REV Hub's **I2C sensor port**. + +As an alternate, the OctoQuad also accepts input from a **REV Through-Bore Encoder**, usually available [**here**](https://www.revrobotics.com/rev-11-1271/) and [**here**](https://www.andymark.com/products/through-bore-encoder). + +

[[/images/FTC-Single-Hub/310_REV-through-bore-encoder+inserts.png|REV encoder]] + +The [**OctoQuad**](https://www.tindie.com/products/digitalchickenlabs/octoquad-8-channel-encoder-sensor/) was released Sept. 1, 2022, and cannot be used in FTC competition. You may find this device useful for development projects and debugging. Documentation is [**here**](https://github.com/DigitalChickenLabs/OctoQuadFtcDriver). + +Use the SPARKmini for DC motors that **don't need encoders**. Reserve the standard REV Hub ports for each DC motor that **does need** an encoder and its associated features (RunModes and `isBusy` status). + +[

Return to Top](#introduction)

+ +## Other Sensors + +Besides encoder data, **feedback** is still available for SPARKmini DC motors. You can use other sensors for motor axle or mechanism position. + +For example, a limit switch or touch sensor can detect **end-of-travel** or a **key intermediate position**: +- [**Mechanical limit switch**](https://www.andymark.com/products/push-switch) +- [**Magnetic limit switch**](https://www.revrobotics.com/rev-31-1462/) +- [**Touch sensor**](https://www.revrobotics.com/rev-31-1425/) + +Also, the [**REV Potentiometer**](https://www.revrobotics.com/rev-31-1155/) reports **shaft rotation** within a 270-degree range of motion. This could be used in a mechanism with hard stops and/or limit switches to keep rotation well within the pot's range. + +_Tip: REV Hubs accept **two sensors** at each Analog and Digital sensor port._ + +Use programming logic to determine what the DC motor should do, when these sensors report certain values. + +[

Return to Top](#introduction)

+ +## Zero-Power Behavior + +The FTC SDK provides two choices for DC motor behavior when its Power is set to zero: FLOAT and BRAKE. Under **FLOAT**, the motor will come to rest from natural effects of friction. Under **BRAKE**, the motor will resist rotating, thus stopping sooner. + +These programmed choices are not available for DC motors controlled with SPARKmini. Fortunately, the device itself can be **manually set** to one mode or the other. + +

[[/images/FTC-Single-Hub/400_SPARKmini_C-B_switch_circled.png|C-B switch]] + +The letter "C" is for **Coast**, same as FLOAT. The letter "B" is for **Brake**. + +Carefully slide each unit's switch to your preferred mode for its DC motor. Add a comment in your programming code, telling the reader which setting is selected for each motor. It might be difficult to find out later! + +[

Return to Top](#introduction)

+ +## Summary + +This tutorial showed how to run **more than 4** DC motors on a single REV Control Hub or REV Expansion Hub. This may help teams who temporarily have only one REV Hub available, during FTC’s [**“Share the Spare!”**](http://firsttechchallenge.blogspot.com/2022/06/share-spare-control-and-expansion-hub.html) environment in 2022. + +Much of this information, and more, is presented in REV Robotics’ comprehensive [**documentation site**](https://docs.revrobotics.com/duo-control/adding-more-motors/sparkmini-motor-controller). Recommended reading! + +[

Return to Top](#introduction)

+ +=========== + +_Questions, comments and corrections to: westsiderobotics@verizon.net_