Skip to content
Parallax Learn (Stage)

Parallax Learn (Stage)

This is the staging site. Please see https://learn.parallax.com for the official site.

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence Tutorial Series
          • Cybersecurity: Radio Data tutorialCybersecurity Tutorial Series
          • cyber:bot Tutorial Series
          • Boe-Bot Tutorial SeriesBoe-Bot Tutorial Series
          • Arduino Shield-Bot Tutorial Series
          • ActivityBot with C TutorialsActivityBot with C Tutorials
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot with BlocklyProp Tutorial Series
          • Scribbler 3 Tutorial SeriesScribbler 3 Tutorial Series
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education Tutorial Series
          • Propeller C-Language BasicsPropeller C Basics and Projects
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit C Tutorial Series
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit BlocklyProp Tutorials
          • Badge WX Tutorial SeriesBadge WX Tutorial Series
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics and Projects
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Robotics with the Board of Education Shield for Arduino

Robotics with the Board of Education Shield for Arduino

A Look Inside Proportional Control

Closed loop control—repeatedly measuring a value and adjusting output in proportion to error for maintaining a set point—works very well for the BOE Shield-Bot shadow vehicle.  In fact, the majority of the control loop shown in the diagram below reduces to just one line of code in a sketch.  This block diagram describes the proportional control process that the BOE Shield-Bot will use to control the wheel speed based on detection distance measured with the IR LED/receiver pairs.  

This block diagram could apply to either the left IR distance sensor and servo output or the right.  In fact, your code will maintain two identical control loops, one for each side of the BOE Shield-Bot. Let’s walk through this example.

In the upper left, the set point = 2; we want the BOE Shield-Bot to maintain a zone-2 distance between itself and its leader-object.  Below that, the measured distance is zone 4, so the leader-object is too far away. The arrows towards the symbols in the circle (called a summing junction)  indicate that you add (+) the set point and subtract (-) the measured distance together to get the error, in this case  2 – 4 = -2. 

Next, the error value feeds into the top square—an operator block.  This block shows that the error gets multiplied by -50, a proportionality constant (Kp). In this example, the operator block gives us -2 × -50 = 100, so 100 is the output.  In a sketch, this output value gets passed to the maneuver function. It turns the servo full speed forward to move the BOE Shield bot closer to the leader-object.

The next block diagram shows another example.  This time, the measured distance is 1, meaning the leader-object is too close.  So, the error is 1, and 1×–50 = -50.  Passing -50 to the maneuver function turns the servo half-speed in reverse, backing the BOE Shield-Bot away from the leader-object.

The next time through the loop, the measured distance might change, but that’s okay.  Regardless of the measured distance, this control loop will calculate a value that will cause the servo to move to correct any error.  The correction is always proportional to the error.  The two calculations involved: 

set point – measured distance = error;  error x Kp = output for maneuver

…can be easily combined and re-ordered into one expression for your sketch:

Output for maneuver   = (Distance set point – Measured distance) x Kp

If you want to take a look at the sketch in detail, see How FollowingShieldBot Works.

Your Turn – Verify Control Loop with Other Distances

  • To prove that the proportional control loop responds correctly to all six measured distances, fill in the table below.  The block diagrams have been solved for two of the six conditions, so you’ve only got four to try.

 


Printer-friendly version
Activity 2: BOE Shield-Bot Shadow Vehicle
Prev
Example Sketch: FollowingShieldBot
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn (Stage) • Built with GeneratePress